babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616
  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. * Moves the observable to the top of the observer list making it get called first when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverTopPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Moves the observable to the bottom of the observer list making it get called last when notified
  4361. * @param observer the observer to move
  4362. */
  4363. makeObserverBottomPriority(observer: Observer<T>): void;
  4364. /**
  4365. * Notify all Observers by calling their respective callback with the given data
  4366. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4367. * @param eventData defines the data to send to all observers
  4368. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4369. * @param target defines the original target of the state
  4370. * @param currentTarget defines the current target of the state
  4371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4372. */
  4373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4374. /**
  4375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4378. * and it is crucial that all callbacks will be executed.
  4379. * The order of the callbacks is kept, callbacks are not executed parallel.
  4380. *
  4381. * @param eventData The data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. * @param target defines the callback target (see EventState)
  4384. * @param currentTarget defines he current object in the bubbling phase
  4385. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4386. */
  4387. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4388. /**
  4389. * Notify a specific observer
  4390. * @param observer defines the observer to notify
  4391. * @param eventData defines the data to be sent to each callback
  4392. * @param mask is used to filter observers defaults to -1
  4393. */
  4394. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4395. /**
  4396. * Gets a boolean indicating if the observable has at least one observer
  4397. * @returns true is the Observable has at least one Observer registered
  4398. */
  4399. hasObservers(): boolean;
  4400. /**
  4401. * Clear the list of observers
  4402. */
  4403. clear(): void;
  4404. /**
  4405. * Clone the current observable
  4406. * @returns a new observable
  4407. */
  4408. clone(): Observable<T>;
  4409. /**
  4410. * Does this observable handles observer registered with a given mask
  4411. * @param mask defines the mask to be tested
  4412. * @return whether or not one observer registered with the given mask is handeled
  4413. **/
  4414. hasSpecificMask(mask?: number): boolean;
  4415. }
  4416. }
  4417. declare module "babylonjs/Misc/filesInputStore" {
  4418. /**
  4419. * Class used to help managing file picking and drag'n'drop
  4420. * File Storage
  4421. */
  4422. export class FilesInputStore {
  4423. /**
  4424. * List of files ready to be loaded
  4425. */
  4426. static FilesToLoad: {
  4427. [key: string]: File;
  4428. };
  4429. }
  4430. }
  4431. declare module "babylonjs/Engines/constants" {
  4432. /** Defines the cross module used constants to avoid circular dependncies */
  4433. export class Constants {
  4434. /** Defines that alpha blending is disabled */
  4435. static readonly ALPHA_DISABLE: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4437. static readonly ALPHA_ADD: number;
  4438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_COMBINE: number;
  4440. /** Defines that alpha blending to DEST - SRC * DEST */
  4441. static readonly ALPHA_SUBTRACT: number;
  4442. /** Defines that alpha blending to SRC * DEST */
  4443. static readonly ALPHA_MULTIPLY: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. /** Defines that alpha blending to SRC + DEST */
  4447. static readonly ALPHA_ONEONE: number;
  4448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4449. static readonly ALPHA_PREMULTIPLIED: number;
  4450. /**
  4451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4453. */
  4454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4456. static readonly ALPHA_INTERPOLATE: number;
  4457. /**
  4458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4460. */
  4461. static readonly ALPHA_SCREENMODE: number;
  4462. /** Defines that the ressource is not delayed*/
  4463. static readonly DELAYLOADSTATE_NONE: number;
  4464. /** Defines that the ressource was successfully delay loaded */
  4465. static readonly DELAYLOADSTATE_LOADED: number;
  4466. /** Defines that the ressource is currently delay loading */
  4467. static readonly DELAYLOADSTATE_LOADING: number;
  4468. /** Defines that the ressource is delayed and has not started loading */
  4469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4471. static readonly NEVER: number;
  4472. /** 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 */
  4473. static readonly ALWAYS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4475. static readonly LESS: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4477. static readonly EQUAL: number;
  4478. /** 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 */
  4479. static readonly LEQUAL: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4481. static readonly GREATER: number;
  4482. /** 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 */
  4483. static readonly GEQUAL: number;
  4484. /** 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 */
  4485. static readonly NOTEQUAL: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be kept */
  4487. static readonly KEEP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4489. static readonly REPLACE: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4491. static readonly INCR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4493. static readonly DECR: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4495. static readonly INVERT: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4497. static readonly INCR_WRAP: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4499. static readonly DECR_WRAP: number;
  4500. /** Texture is not repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4502. /** Texture is repeating outside of 0..1 UVs */
  4503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4504. /** Texture is repeating and mirrored */
  4505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4506. /** ALPHA */
  4507. static readonly TEXTUREFORMAT_ALPHA: number;
  4508. /** LUMINANCE */
  4509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4510. /** LUMINANCE_ALPHA */
  4511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4512. /** RGB */
  4513. static readonly TEXTUREFORMAT_RGB: number;
  4514. /** RGBA */
  4515. static readonly TEXTUREFORMAT_RGBA: number;
  4516. /** RED */
  4517. static readonly TEXTUREFORMAT_RED: number;
  4518. /** RED (2nd reference) */
  4519. static readonly TEXTUREFORMAT_R: number;
  4520. /** RG */
  4521. static readonly TEXTUREFORMAT_RG: number;
  4522. /** RED_INTEGER */
  4523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4524. /** RED_INTEGER (2nd reference) */
  4525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4526. /** RG_INTEGER */
  4527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4528. /** RGB_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4530. /** RGBA_INTEGER */
  4531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4532. /** UNSIGNED_BYTE */
  4533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4534. /** UNSIGNED_BYTE (2nd reference) */
  4535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4536. /** FLOAT */
  4537. static readonly TEXTURETYPE_FLOAT: number;
  4538. /** HALF_FLOAT */
  4539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4540. /** BYTE */
  4541. static readonly TEXTURETYPE_BYTE: number;
  4542. /** SHORT */
  4543. static readonly TEXTURETYPE_SHORT: number;
  4544. /** UNSIGNED_SHORT */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4546. /** INT */
  4547. static readonly TEXTURETYPE_INT: number;
  4548. /** UNSIGNED_INT */
  4549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4550. /** UNSIGNED_SHORT_4_4_4_4 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4552. /** UNSIGNED_SHORT_5_5_5_1 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4554. /** UNSIGNED_SHORT_5_6_5 */
  4555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4556. /** UNSIGNED_INT_2_10_10_10_REV */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4558. /** UNSIGNED_INT_24_8 */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4560. /** UNSIGNED_INT_10F_11F_11F_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4562. /** UNSIGNED_INT_5_9_9_9_REV */
  4563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4566. /** nearest is mag = nearest and min = nearest and mip = linear */
  4567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4570. /** Trilinear is mag = linear and min = linear and mip = linear */
  4571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4572. /** nearest is mag = nearest and min = nearest and mip = linear */
  4573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4576. /** Trilinear is mag = linear and min = linear and mip = linear */
  4577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4578. /** mag = nearest and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = nearest */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4582. /** mag = nearest and min = linear and mip = linear */
  4583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4584. /** mag = nearest and min = linear and mip = none */
  4585. static readonly TEXTURE_NEAREST_LINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = none */
  4587. static readonly TEXTURE_NEAREST_NEAREST: number;
  4588. /** mag = linear and min = nearest and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4590. /** mag = linear and min = nearest and mip = linear */
  4591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4592. /** mag = linear and min = linear and mip = none */
  4593. static readonly TEXTURE_LINEAR_LINEAR: number;
  4594. /** mag = linear and min = nearest and mip = none */
  4595. static readonly TEXTURE_LINEAR_NEAREST: number;
  4596. /** Explicit coordinates mode */
  4597. static readonly TEXTURE_EXPLICIT_MODE: number;
  4598. /** Spherical coordinates mode */
  4599. static readonly TEXTURE_SPHERICAL_MODE: number;
  4600. /** Planar coordinates mode */
  4601. static readonly TEXTURE_PLANAR_MODE: number;
  4602. /** Cubic coordinates mode */
  4603. static readonly TEXTURE_CUBIC_MODE: number;
  4604. /** Projection coordinates mode */
  4605. static readonly TEXTURE_PROJECTION_MODE: number;
  4606. /** Skybox coordinates mode */
  4607. static readonly TEXTURE_SKYBOX_MODE: number;
  4608. /** Inverse Cubic coordinates mode */
  4609. static readonly TEXTURE_INVCUBIC_MODE: number;
  4610. /** Equirectangular coordinates mode */
  4611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4614. /** Equirectangular Fixed Mirrored coordinates mode */
  4615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4617. static readonly SCALEMODE_FLOOR: number;
  4618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4619. static readonly SCALEMODE_NEAREST: number;
  4620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4621. static readonly SCALEMODE_CEILING: number;
  4622. /**
  4623. * The dirty texture flag value
  4624. */
  4625. static readonly MATERIAL_TextureDirtyFlag: number;
  4626. /**
  4627. * The dirty light flag value
  4628. */
  4629. static readonly MATERIAL_LightDirtyFlag: number;
  4630. /**
  4631. * The dirty fresnel flag value
  4632. */
  4633. static readonly MATERIAL_FresnelDirtyFlag: number;
  4634. /**
  4635. * The dirty attribute flag value
  4636. */
  4637. static readonly MATERIAL_AttributesDirtyFlag: number;
  4638. /**
  4639. * The dirty misc flag value
  4640. */
  4641. static readonly MATERIAL_MiscDirtyFlag: number;
  4642. /**
  4643. * The all dirty flag value
  4644. */
  4645. static readonly MATERIAL_AllDirtyFlag: number;
  4646. /**
  4647. * Returns the triangle fill mode
  4648. */
  4649. static readonly MATERIAL_TriangleFillMode: number;
  4650. /**
  4651. * Returns the wireframe mode
  4652. */
  4653. static readonly MATERIAL_WireFrameFillMode: number;
  4654. /**
  4655. * Returns the point fill mode
  4656. */
  4657. static readonly MATERIAL_PointFillMode: number;
  4658. /**
  4659. * Returns the point list draw mode
  4660. */
  4661. static readonly MATERIAL_PointListDrawMode: number;
  4662. /**
  4663. * Returns the line list draw mode
  4664. */
  4665. static readonly MATERIAL_LineListDrawMode: number;
  4666. /**
  4667. * Returns the line loop draw mode
  4668. */
  4669. static readonly MATERIAL_LineLoopDrawMode: number;
  4670. /**
  4671. * Returns the line strip draw mode
  4672. */
  4673. static readonly MATERIAL_LineStripDrawMode: number;
  4674. /**
  4675. * Returns the triangle strip draw mode
  4676. */
  4677. static readonly MATERIAL_TriangleStripDrawMode: number;
  4678. /**
  4679. * Returns the triangle fan draw mode
  4680. */
  4681. static readonly MATERIAL_TriangleFanDrawMode: number;
  4682. /**
  4683. * Stores the clock-wise side orientation
  4684. */
  4685. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4686. /**
  4687. * Stores the counter clock-wise side orientation
  4688. */
  4689. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4690. /**
  4691. * Nothing
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_NothingTrigger: number;
  4695. /**
  4696. * On pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPickTrigger: number;
  4700. /**
  4701. * On left pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnLeftPickTrigger: number;
  4705. /**
  4706. * On right pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnRightPickTrigger: number;
  4710. /**
  4711. * On center pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnCenterPickTrigger: number;
  4715. /**
  4716. * On pick down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickDownTrigger: number;
  4720. /**
  4721. * On double pick
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnDoublePickTrigger: number;
  4725. /**
  4726. * On pick up
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnPickUpTrigger: number;
  4730. /**
  4731. * On pick out.
  4732. * This trigger will only be raised if you also declared a OnPickDown
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPickOutTrigger: number;
  4736. /**
  4737. * On long press
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnLongPressTrigger: number;
  4741. /**
  4742. * On pointer over
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOverTrigger: number;
  4746. /**
  4747. * On pointer out
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnPointerOutTrigger: number;
  4751. /**
  4752. * On every frame
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnEveryFrameTrigger: number;
  4756. /**
  4757. * On intersection enter
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4761. /**
  4762. * On intersection exit
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnIntersectionExitTrigger: number;
  4766. /**
  4767. * On key down
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyDownTrigger: number;
  4771. /**
  4772. * On key up
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnKeyUpTrigger: number;
  4776. /**
  4777. * Billboard mode will only apply to Y axis
  4778. */
  4779. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4780. /**
  4781. * Billboard mode will apply to all axes
  4782. */
  4783. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4784. /**
  4785. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4788. /**
  4789. * Gets or sets base Assets URL
  4790. */
  4791. static readonly PARTICLES_BaseAssetsUrl: string;
  4792. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4793. * Test order :
  4794. * Is the bounding sphere outside the frustum ?
  4795. * If not, are the bounding box vertices outside the frustum ?
  4796. * It not, then the cullable object is in the frustum.
  4797. */
  4798. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4799. /** Culling strategy : Bounding Sphere Only.
  4800. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4801. * It's also less accurate than the standard because some not visible objects can still be selected.
  4802. * Test : is the bounding sphere outside the frustum ?
  4803. * If not, then the cullable object is in the frustum.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4806. /** Culling strategy : Optimistic Inclusion.
  4807. * This in an inclusion test first, then the standard exclusion test.
  4808. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * Anyway, it's as accurate as the standard strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the default culling strategy.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4816. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4817. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4818. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4819. * 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.
  4820. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4821. * Test :
  4822. * Is the cullable object bounding sphere center in the frustum ?
  4823. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4824. */
  4825. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4826. /**
  4827. * No logging while loading
  4828. */
  4829. static readonly SCENELOADER_NO_LOGGING: number;
  4830. /**
  4831. * Minimal logging while loading
  4832. */
  4833. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4834. /**
  4835. * Summary logging while loading
  4836. */
  4837. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4838. /**
  4839. * Detailled logging while loading
  4840. */
  4841. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4842. }
  4843. }
  4844. declare module "babylonjs/Misc/domManagement" {
  4845. /**
  4846. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4847. * Babylon.js
  4848. */
  4849. export class DomManagement {
  4850. /**
  4851. * Checks if the window object exists
  4852. * @returns true if the window object exists
  4853. */
  4854. static IsWindowObjectExist(): boolean;
  4855. /**
  4856. * Extracts text content from a DOM element hierarchy
  4857. * @param element defines the root element
  4858. * @returns a string
  4859. */
  4860. static GetDOMTextContent(element: HTMLElement): string;
  4861. }
  4862. }
  4863. declare module "babylonjs/Misc/logger" {
  4864. /**
  4865. * Logger used througouht the application to allow configuration of
  4866. * the log level required for the messages.
  4867. */
  4868. export class Logger {
  4869. /**
  4870. * No log
  4871. */
  4872. static readonly NoneLogLevel: number;
  4873. /**
  4874. * Only message logs
  4875. */
  4876. static readonly MessageLogLevel: number;
  4877. /**
  4878. * Only warning logs
  4879. */
  4880. static readonly WarningLogLevel: number;
  4881. /**
  4882. * Only error logs
  4883. */
  4884. static readonly ErrorLogLevel: number;
  4885. /**
  4886. * All logs
  4887. */
  4888. static readonly AllLogLevel: number;
  4889. private static _LogCache;
  4890. /**
  4891. * Gets a value indicating the number of loading errors
  4892. * @ignorenaming
  4893. */
  4894. static errorsCount: number;
  4895. /**
  4896. * Callback called when a new log is added
  4897. */
  4898. static OnNewCacheEntry: (entry: string) => void;
  4899. private static _AddLogEntry;
  4900. private static _FormatMessage;
  4901. private static _LogDisabled;
  4902. private static _LogEnabled;
  4903. private static _WarnDisabled;
  4904. private static _WarnEnabled;
  4905. private static _ErrorDisabled;
  4906. private static _ErrorEnabled;
  4907. /**
  4908. * Log a message to the console
  4909. */
  4910. static Log: (message: string) => void;
  4911. /**
  4912. * Write a warning message to the console
  4913. */
  4914. static Warn: (message: string) => void;
  4915. /**
  4916. * Write an error message to the console
  4917. */
  4918. static Error: (message: string) => void;
  4919. /**
  4920. * Gets current log cache (list of logs)
  4921. */
  4922. static readonly LogCache: string;
  4923. /**
  4924. * Clears the log cache
  4925. */
  4926. static ClearLogCache(): void;
  4927. /**
  4928. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4929. */
  4930. static LogLevels: number;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/typeStore" {
  4934. /** @hidden */
  4935. export class _TypeStore {
  4936. /** @hidden */
  4937. static RegisteredTypes: {
  4938. [key: string]: Object;
  4939. };
  4940. /** @hidden */
  4941. static GetClass(fqdn: string): any;
  4942. }
  4943. }
  4944. declare module "babylonjs/Misc/deepCopier" {
  4945. /**
  4946. * Class containing a set of static utilities functions for deep copy.
  4947. */
  4948. export class DeepCopier {
  4949. /**
  4950. * Tries to copy an object by duplicating every property
  4951. * @param source defines the source object
  4952. * @param destination defines the target object
  4953. * @param doNotCopyList defines a list of properties to avoid
  4954. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4955. */
  4956. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/precisionDate" {
  4960. /**
  4961. * Class containing a set of static utilities functions for precision date
  4962. */
  4963. export class PrecisionDate {
  4964. /**
  4965. * Gets either window.performance.now() if supported or Date.now() else
  4966. */
  4967. static readonly Now: number;
  4968. }
  4969. }
  4970. declare module "babylonjs/Misc/devTools" {
  4971. /** @hidden */
  4972. export class _DevTools {
  4973. static WarnImport(name: string): string;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/webRequest" {
  4977. /**
  4978. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4979. */
  4980. export class WebRequest {
  4981. private _xhr;
  4982. /**
  4983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4984. * i.e. when loading files, where the server/service expects an Authorization header
  4985. */
  4986. static CustomRequestHeaders: {
  4987. [key: string]: string;
  4988. };
  4989. /**
  4990. * Add callback functions in this array to update all the requests before they get sent to the network
  4991. */
  4992. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4993. private _injectCustomRequestHeaders;
  4994. /**
  4995. * Gets or sets a function to be called when loading progress changes
  4996. */
  4997. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4998. /**
  4999. * Returns client's state
  5000. */
  5001. readonly readyState: number;
  5002. /**
  5003. * Returns client's status
  5004. */
  5005. readonly status: number;
  5006. /**
  5007. * Returns client's status as a text
  5008. */
  5009. readonly statusText: string;
  5010. /**
  5011. * Returns client's response
  5012. */
  5013. readonly response: any;
  5014. /**
  5015. * Returns client's response url
  5016. */
  5017. readonly responseURL: string;
  5018. /**
  5019. * Returns client's response as text
  5020. */
  5021. readonly responseText: string;
  5022. /**
  5023. * Gets or sets the expected response type
  5024. */
  5025. responseType: XMLHttpRequestResponseType;
  5026. /** @hidden */
  5027. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5028. /** @hidden */
  5029. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5030. /**
  5031. * Cancels any network activity
  5032. */
  5033. abort(): void;
  5034. /**
  5035. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5036. * @param body defines an optional request body
  5037. */
  5038. send(body?: Document | BodyInit | null): void;
  5039. /**
  5040. * Sets the request method, request URL
  5041. * @param method defines the method to use (GET, POST, etc..)
  5042. * @param url defines the url to connect with
  5043. */
  5044. open(method: string, url: string): void;
  5045. }
  5046. }
  5047. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5048. /**
  5049. * Class used to evalaute queries containing `and` and `or` operators
  5050. */
  5051. export class AndOrNotEvaluator {
  5052. /**
  5053. * Evaluate a query
  5054. * @param query defines the query to evaluate
  5055. * @param evaluateCallback defines the callback used to filter result
  5056. * @returns true if the query matches
  5057. */
  5058. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5059. private static _HandleParenthesisContent;
  5060. private static _SimplifyNegation;
  5061. }
  5062. }
  5063. declare module "babylonjs/Misc/tags" {
  5064. /**
  5065. * Class used to store custom tags
  5066. */
  5067. export class Tags {
  5068. /**
  5069. * Adds support for tags on the given object
  5070. * @param obj defines the object to use
  5071. */
  5072. static EnableFor(obj: any): void;
  5073. /**
  5074. * Removes tags support
  5075. * @param obj defines the object to use
  5076. */
  5077. static DisableFor(obj: any): void;
  5078. /**
  5079. * Gets a boolean indicating if the given object has tags
  5080. * @param obj defines the object to use
  5081. * @returns a boolean
  5082. */
  5083. static HasTags(obj: any): boolean;
  5084. /**
  5085. * Gets the tags available on a given object
  5086. * @param obj defines the object to use
  5087. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5088. * @returns the tags
  5089. */
  5090. static GetTags(obj: any, asString?: boolean): any;
  5091. /**
  5092. * Adds tags to an object
  5093. * @param obj defines the object to use
  5094. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5095. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5096. */
  5097. static AddTagsTo(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _AddTagTo(obj: any, tag: string): void;
  5102. /**
  5103. * Removes specific tags from a specific object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tags to remove
  5106. */
  5107. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5108. /**
  5109. * @hidden
  5110. */
  5111. static _RemoveTagFrom(obj: any, tag: string): void;
  5112. /**
  5113. * Defines if tags hosted on an object match a given query
  5114. * @param obj defines the object to use
  5115. * @param tagsQuery defines the tag query
  5116. * @returns a boolean
  5117. */
  5118. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5119. }
  5120. }
  5121. declare module "babylonjs/Materials/materialDefines" {
  5122. /**
  5123. * Manages the defines for the Material
  5124. */
  5125. export class MaterialDefines {
  5126. private _keys;
  5127. private _isDirty;
  5128. /** @hidden */
  5129. _renderId: number;
  5130. /** @hidden */
  5131. _areLightsDirty: boolean;
  5132. /** @hidden */
  5133. _areAttributesDirty: boolean;
  5134. /** @hidden */
  5135. _areTexturesDirty: boolean;
  5136. /** @hidden */
  5137. _areFresnelDirty: boolean;
  5138. /** @hidden */
  5139. _areMiscDirty: boolean;
  5140. /** @hidden */
  5141. _areImageProcessingDirty: boolean;
  5142. /** @hidden */
  5143. _normals: boolean;
  5144. /** @hidden */
  5145. _uvs: boolean;
  5146. /** @hidden */
  5147. _needNormals: boolean;
  5148. /** @hidden */
  5149. _needUVs: boolean;
  5150. /**
  5151. * Specifies if the material needs to be re-calculated
  5152. */
  5153. readonly isDirty: boolean;
  5154. /**
  5155. * Marks the material to indicate that it has been re-calculated
  5156. */
  5157. markAsProcessed(): void;
  5158. /**
  5159. * Marks the material to indicate that it needs to be re-calculated
  5160. */
  5161. markAsUnprocessed(): void;
  5162. /**
  5163. * Marks the material to indicate all of its defines need to be re-calculated
  5164. */
  5165. markAllAsDirty(): void;
  5166. /**
  5167. * Marks the material to indicate that image processing needs to be re-calculated
  5168. */
  5169. markAsImageProcessingDirty(): void;
  5170. /**
  5171. * Marks the material to indicate the lights need to be re-calculated
  5172. */
  5173. markAsLightDirty(): void;
  5174. /**
  5175. * Marks the attribute state as changed
  5176. */
  5177. markAsAttributesDirty(): void;
  5178. /**
  5179. * Marks the texture state as changed
  5180. */
  5181. markAsTexturesDirty(): void;
  5182. /**
  5183. * Marks the fresnel state as changed
  5184. */
  5185. markAsFresnelDirty(): void;
  5186. /**
  5187. * Marks the misc state as changed
  5188. */
  5189. markAsMiscDirty(): void;
  5190. /**
  5191. * Rebuilds the material defines
  5192. */
  5193. rebuild(): void;
  5194. /**
  5195. * Specifies if two material defines are equal
  5196. * @param other - A material define instance to compare to
  5197. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5198. */
  5199. isEqual(other: MaterialDefines): boolean;
  5200. /**
  5201. * Clones this instance's defines to another instance
  5202. * @param other - material defines to clone values to
  5203. */
  5204. cloneTo(other: MaterialDefines): void;
  5205. /**
  5206. * Resets the material define values
  5207. */
  5208. reset(): void;
  5209. /**
  5210. * Converts the material define values to a string
  5211. * @returns - String of material define information
  5212. */
  5213. toString(): string;
  5214. }
  5215. }
  5216. declare module "babylonjs/Misc/performanceMonitor" {
  5217. /**
  5218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5219. */
  5220. export class PerformanceMonitor {
  5221. private _enabled;
  5222. private _rollingFrameTime;
  5223. private _lastFrameTimeMs;
  5224. /**
  5225. * constructor
  5226. * @param frameSampleSize The number of samples required to saturate the sliding window
  5227. */
  5228. constructor(frameSampleSize?: number);
  5229. /**
  5230. * Samples current frame
  5231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5232. */
  5233. sampleFrame(timeMs?: number): void;
  5234. /**
  5235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5236. */
  5237. readonly averageFrameTime: number;
  5238. /**
  5239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5240. */
  5241. readonly averageFrameTimeVariance: number;
  5242. /**
  5243. * Returns the frame time of the most recent frame
  5244. */
  5245. readonly instantaneousFrameTime: number;
  5246. /**
  5247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFPS: number;
  5250. /**
  5251. * Returns the average framerate in frames per second using the most recent frame time
  5252. */
  5253. readonly instantaneousFPS: number;
  5254. /**
  5255. * Returns true if enough samples have been taken to completely fill the sliding window
  5256. */
  5257. readonly isSaturated: boolean;
  5258. /**
  5259. * Enables contributions to the sliding window sample set
  5260. */
  5261. enable(): void;
  5262. /**
  5263. * Disables contributions to the sliding window sample set
  5264. * Samples will not be interpolated over the disabled period
  5265. */
  5266. disable(): void;
  5267. /**
  5268. * Returns true if sampling is enabled
  5269. */
  5270. readonly isEnabled: boolean;
  5271. /**
  5272. * Resets performance monitor
  5273. */
  5274. reset(): void;
  5275. }
  5276. /**
  5277. * RollingAverage
  5278. *
  5279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5280. */
  5281. export class RollingAverage {
  5282. /**
  5283. * Current average
  5284. */
  5285. average: number;
  5286. /**
  5287. * Current variance
  5288. */
  5289. variance: number;
  5290. protected _samples: Array<number>;
  5291. protected _sampleCount: number;
  5292. protected _pos: number;
  5293. protected _m2: number;
  5294. /**
  5295. * constructor
  5296. * @param length The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(length: number);
  5299. /**
  5300. * Adds a sample to the sample set
  5301. * @param v The sample value
  5302. */
  5303. add(v: number): void;
  5304. /**
  5305. * Returns previously added values or null if outside of history or outside the sliding window domain
  5306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5307. * @return Value previously recorded with add() or null if outside of range
  5308. */
  5309. history(i: number): number;
  5310. /**
  5311. * Returns true if enough samples have been taken to completely fill the sliding window
  5312. * @return true if sample-set saturated
  5313. */
  5314. isSaturated(): boolean;
  5315. /**
  5316. * Resets the rolling average (equivalent to 0 samples taken so far)
  5317. */
  5318. reset(): void;
  5319. /**
  5320. * Wraps a value around the sample range boundaries
  5321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5322. * @return Wrapped position in sample range
  5323. */
  5324. protected _wrapPosition(i: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Misc/stringDictionary" {
  5328. import { Nullable } from "babylonjs/types";
  5329. /**
  5330. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5331. * The underlying implementation relies on an associative array to ensure the best performances.
  5332. * The value can be anything including 'null' but except 'undefined'
  5333. */
  5334. export class StringDictionary<T> {
  5335. /**
  5336. * This will clear this dictionary and copy the content from the 'source' one.
  5337. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5338. * @param source the dictionary to take the content from and copy to this dictionary
  5339. */
  5340. copyFrom(source: StringDictionary<T>): void;
  5341. /**
  5342. * Get a value based from its key
  5343. * @param key the given key to get the matching value from
  5344. * @return the value if found, otherwise undefined is returned
  5345. */
  5346. get(key: string): T | undefined;
  5347. /**
  5348. * Get a value from its key or add it if it doesn't exist.
  5349. * This method will ensure you that a given key/data will be present in the dictionary.
  5350. * @param key the given key to get the matching value from
  5351. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5352. * The factory will only be invoked if there's no data for the given key.
  5353. * @return the value corresponding to the key.
  5354. */
  5355. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5356. /**
  5357. * Get a value from its key if present in the dictionary otherwise add it
  5358. * @param key the key to get the value from
  5359. * @param val if there's no such key/value pair in the dictionary add it with this value
  5360. * @return the value corresponding to the key
  5361. */
  5362. getOrAdd(key: string, val: T): T;
  5363. /**
  5364. * Check if there's a given key in the dictionary
  5365. * @param key the key to check for
  5366. * @return true if the key is present, false otherwise
  5367. */
  5368. contains(key: string): boolean;
  5369. /**
  5370. * Add a new key and its corresponding value
  5371. * @param key the key to add
  5372. * @param value the value corresponding to the key
  5373. * @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
  5374. */
  5375. add(key: string, value: T): boolean;
  5376. /**
  5377. * Update a specific value associated to a key
  5378. * @param key defines the key to use
  5379. * @param value defines the value to store
  5380. * @returns true if the value was updated (or false if the key was not found)
  5381. */
  5382. set(key: string, value: T): boolean;
  5383. /**
  5384. * Get the element of the given key and remove it from the dictionary
  5385. * @param key defines the key to search
  5386. * @returns the value associated with the key or null if not found
  5387. */
  5388. getAndRemove(key: string): Nullable<T>;
  5389. /**
  5390. * Remove a key/value from the dictionary.
  5391. * @param key the key to remove
  5392. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5393. */
  5394. remove(key: string): boolean;
  5395. /**
  5396. * Clear the whole content of the dictionary
  5397. */
  5398. clear(): void;
  5399. /**
  5400. * Gets the current count
  5401. */
  5402. readonly count: number;
  5403. /**
  5404. * Execute a callback on each key/val of the dictionary.
  5405. * Note that you can remove any element in this dictionary in the callback implementation
  5406. * @param callback the callback to execute on a given key/value pair
  5407. */
  5408. forEach(callback: (key: string, val: T) => void): void;
  5409. /**
  5410. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5411. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5412. * Note that you can remove any element in this dictionary in the callback implementation
  5413. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5414. * @returns the first item
  5415. */
  5416. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5417. private _count;
  5418. private _data;
  5419. }
  5420. }
  5421. declare module "babylonjs/Misc/promise" {
  5422. /**
  5423. * Helper class that provides a small promise polyfill
  5424. */
  5425. export class PromisePolyfill {
  5426. /**
  5427. * Static function used to check if the polyfill is required
  5428. * If this is the case then the function will inject the polyfill to window.Promise
  5429. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5430. */
  5431. static Apply(force?: boolean): void;
  5432. }
  5433. }
  5434. declare module "babylonjs/Meshes/buffer" {
  5435. import { Nullable, DataArray } from "babylonjs/types";
  5436. /**
  5437. * Class used to store data that will be store in GPU memory
  5438. */
  5439. export class Buffer {
  5440. private _engine;
  5441. private _buffer;
  5442. /** @hidden */
  5443. _data: Nullable<DataArray>;
  5444. private _updatable;
  5445. private _instanced;
  5446. /**
  5447. * Gets the byte stride.
  5448. */
  5449. readonly byteStride: number;
  5450. /**
  5451. * Constructor
  5452. * @param engine the engine
  5453. * @param data the data to use for this buffer
  5454. * @param updatable whether the data is updatable
  5455. * @param stride the stride (optional)
  5456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5457. * @param instanced whether the buffer is instanced (optional)
  5458. * @param useBytes set to true if the stride in in bytes (optional)
  5459. */
  5460. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5461. /**
  5462. * Create a new VertexBuffer based on the current buffer
  5463. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5464. * @param offset defines offset in the buffer (0 by default)
  5465. * @param size defines the size in floats of attributes (position is 3 for instance)
  5466. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5467. * @param instanced defines if the vertex buffer contains indexed data
  5468. * @param useBytes defines if the offset and stride are in bytes
  5469. * @returns the new vertex buffer
  5470. */
  5471. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5472. /**
  5473. * Gets a boolean indicating if the Buffer is updatable?
  5474. * @returns true if the buffer is updatable
  5475. */
  5476. isUpdatable(): boolean;
  5477. /**
  5478. * Gets current buffer's data
  5479. * @returns a DataArray or null
  5480. */
  5481. getData(): Nullable<DataArray>;
  5482. /**
  5483. * Gets underlying native buffer
  5484. * @returns underlying native buffer
  5485. */
  5486. getBuffer(): Nullable<WebGLBuffer>;
  5487. /**
  5488. * Gets the stride in float32 units (i.e. byte stride / 4).
  5489. * May not be an integer if the byte stride is not divisible by 4.
  5490. * DEPRECATED. Use byteStride instead.
  5491. * @returns the stride in float32 units
  5492. */
  5493. getStrideSize(): number;
  5494. /**
  5495. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5496. * @param data defines the data to store
  5497. */
  5498. create(data?: Nullable<DataArray>): void;
  5499. /** @hidden */
  5500. _rebuild(): void;
  5501. /**
  5502. * Update current buffer data
  5503. * @param data defines the data to store
  5504. */
  5505. update(data: DataArray): void;
  5506. /**
  5507. * Updates the data directly.
  5508. * @param data the new data
  5509. * @param offset the new offset
  5510. * @param vertexCount the vertex count (optional)
  5511. * @param useBytes set to true if the offset is in bytes
  5512. */
  5513. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5514. /**
  5515. * Release all resources
  5516. */
  5517. dispose(): void;
  5518. }
  5519. /**
  5520. * Specialized buffer used to store vertex data
  5521. */
  5522. export class VertexBuffer {
  5523. /** @hidden */
  5524. _buffer: Buffer;
  5525. private _kind;
  5526. private _size;
  5527. private _ownsBuffer;
  5528. private _instanced;
  5529. private _instanceDivisor;
  5530. /**
  5531. * The byte type.
  5532. */
  5533. static readonly BYTE: number;
  5534. /**
  5535. * The unsigned byte type.
  5536. */
  5537. static readonly UNSIGNED_BYTE: number;
  5538. /**
  5539. * The short type.
  5540. */
  5541. static readonly SHORT: number;
  5542. /**
  5543. * The unsigned short type.
  5544. */
  5545. static readonly UNSIGNED_SHORT: number;
  5546. /**
  5547. * The integer type.
  5548. */
  5549. static readonly INT: number;
  5550. /**
  5551. * The unsigned integer type.
  5552. */
  5553. static readonly UNSIGNED_INT: number;
  5554. /**
  5555. * The float type.
  5556. */
  5557. static readonly FLOAT: number;
  5558. /**
  5559. * Gets or sets the instance divisor when in instanced mode
  5560. */
  5561. instanceDivisor: number;
  5562. /**
  5563. * Gets the byte stride.
  5564. */
  5565. readonly byteStride: number;
  5566. /**
  5567. * Gets the byte offset.
  5568. */
  5569. readonly byteOffset: number;
  5570. /**
  5571. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5572. */
  5573. readonly normalized: boolean;
  5574. /**
  5575. * Gets the data type of each component in the array.
  5576. */
  5577. readonly type: number;
  5578. /**
  5579. * Constructor
  5580. * @param engine the engine
  5581. * @param data the data to use for this vertex buffer
  5582. * @param kind the vertex buffer kind
  5583. * @param updatable whether the data is updatable
  5584. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5585. * @param stride the stride (optional)
  5586. * @param instanced whether the buffer is instanced (optional)
  5587. * @param offset the offset of the data (optional)
  5588. * @param size the number of components (optional)
  5589. * @param type the type of the component (optional)
  5590. * @param normalized whether the data contains normalized data (optional)
  5591. * @param useBytes set to true if stride and offset are in bytes (optional)
  5592. */
  5593. 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);
  5594. /** @hidden */
  5595. _rebuild(): void;
  5596. /**
  5597. * Returns the kind of the VertexBuffer (string)
  5598. * @returns a string
  5599. */
  5600. getKind(): string;
  5601. /**
  5602. * Gets a boolean indicating if the VertexBuffer is updatable?
  5603. * @returns true if the buffer is updatable
  5604. */
  5605. isUpdatable(): boolean;
  5606. /**
  5607. * Gets current buffer's data
  5608. * @returns a DataArray or null
  5609. */
  5610. getData(): Nullable<DataArray>;
  5611. /**
  5612. * Gets underlying native buffer
  5613. * @returns underlying native buffer
  5614. */
  5615. getBuffer(): Nullable<WebGLBuffer>;
  5616. /**
  5617. * Gets the stride in float32 units (i.e. byte stride / 4).
  5618. * May not be an integer if the byte stride is not divisible by 4.
  5619. * DEPRECATED. Use byteStride instead.
  5620. * @returns the stride in float32 units
  5621. */
  5622. getStrideSize(): number;
  5623. /**
  5624. * Returns the offset as a multiple of the type byte length.
  5625. * DEPRECATED. Use byteOffset instead.
  5626. * @returns the offset in bytes
  5627. */
  5628. getOffset(): number;
  5629. /**
  5630. * Returns the number of components per vertex attribute (integer)
  5631. * @returns the size in float
  5632. */
  5633. getSize(): number;
  5634. /**
  5635. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5636. * @returns true if this buffer is instanced
  5637. */
  5638. getIsInstanced(): boolean;
  5639. /**
  5640. * Returns the instancing divisor, zero for non-instanced (integer).
  5641. * @returns a number
  5642. */
  5643. getInstanceDivisor(): number;
  5644. /**
  5645. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5646. * @param data defines the data to store
  5647. */
  5648. create(data?: DataArray): void;
  5649. /**
  5650. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5651. * This function will create a new buffer if the current one is not updatable
  5652. * @param data defines the data to store
  5653. */
  5654. update(data: DataArray): void;
  5655. /**
  5656. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5657. * Returns the directly updated WebGLBuffer.
  5658. * @param data the new data
  5659. * @param offset the new offset
  5660. * @param useBytes set to true if the offset is in bytes
  5661. */
  5662. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5663. /**
  5664. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5665. */
  5666. dispose(): void;
  5667. /**
  5668. * Enumerates each value of this vertex buffer as numbers.
  5669. * @param count the number of values to enumerate
  5670. * @param callback the callback function called for each value
  5671. */
  5672. forEach(count: number, callback: (value: number, index: number) => void): void;
  5673. /**
  5674. * Positions
  5675. */
  5676. static readonly PositionKind: string;
  5677. /**
  5678. * Normals
  5679. */
  5680. static readonly NormalKind: string;
  5681. /**
  5682. * Tangents
  5683. */
  5684. static readonly TangentKind: string;
  5685. /**
  5686. * Texture coordinates
  5687. */
  5688. static readonly UVKind: string;
  5689. /**
  5690. * Texture coordinates 2
  5691. */
  5692. static readonly UV2Kind: string;
  5693. /**
  5694. * Texture coordinates 3
  5695. */
  5696. static readonly UV3Kind: string;
  5697. /**
  5698. * Texture coordinates 4
  5699. */
  5700. static readonly UV4Kind: string;
  5701. /**
  5702. * Texture coordinates 5
  5703. */
  5704. static readonly UV5Kind: string;
  5705. /**
  5706. * Texture coordinates 6
  5707. */
  5708. static readonly UV6Kind: string;
  5709. /**
  5710. * Colors
  5711. */
  5712. static readonly ColorKind: string;
  5713. /**
  5714. * Matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesKind: string;
  5717. /**
  5718. * Matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsKind: string;
  5721. /**
  5722. * Additional matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesExtraKind: string;
  5725. /**
  5726. * Additional matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsExtraKind: string;
  5729. /**
  5730. * Deduces the stride given a kind.
  5731. * @param kind The kind string to deduce
  5732. * @returns The deduced stride
  5733. */
  5734. static DeduceStride(kind: string): number;
  5735. /**
  5736. * Gets the byte length of the given type.
  5737. * @param type the type
  5738. * @returns the number of bytes
  5739. */
  5740. static GetTypeByteLength(type: number): number;
  5741. /**
  5742. * Enumerates each value of the given parameters as numbers.
  5743. * @param data the data to enumerate
  5744. * @param byteOffset the byte offset of the data
  5745. * @param byteStride the byte stride of the data
  5746. * @param componentCount the number of components per element
  5747. * @param componentType the type of the component
  5748. * @param count the total number of components
  5749. * @param normalized whether the data is normalized
  5750. * @param callback the callback function called for each value
  5751. */
  5752. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5753. private static _GetFloatValue;
  5754. }
  5755. }
  5756. declare module "babylonjs/Maths/sphericalPolynomial" {
  5757. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5758. /**
  5759. * Class representing spherical polynomial coefficients to the 3rd degree
  5760. */
  5761. export class SphericalPolynomial {
  5762. /**
  5763. * The x coefficients of the spherical polynomial
  5764. */
  5765. x: Vector3;
  5766. /**
  5767. * The y coefficients of the spherical polynomial
  5768. */
  5769. y: Vector3;
  5770. /**
  5771. * The z coefficients of the spherical polynomial
  5772. */
  5773. z: Vector3;
  5774. /**
  5775. * The xx coefficients of the spherical polynomial
  5776. */
  5777. xx: Vector3;
  5778. /**
  5779. * The yy coefficients of the spherical polynomial
  5780. */
  5781. yy: Vector3;
  5782. /**
  5783. * The zz coefficients of the spherical polynomial
  5784. */
  5785. zz: Vector3;
  5786. /**
  5787. * The xy coefficients of the spherical polynomial
  5788. */
  5789. xy: Vector3;
  5790. /**
  5791. * The yz coefficients of the spherical polynomial
  5792. */
  5793. yz: Vector3;
  5794. /**
  5795. * The zx coefficients of the spherical polynomial
  5796. */
  5797. zx: Vector3;
  5798. /**
  5799. * Adds an ambient color to the spherical polynomial
  5800. * @param color the color to add
  5801. */
  5802. addAmbient(color: Color3): void;
  5803. /**
  5804. * Scales the spherical polynomial by the given amount
  5805. * @param scale the amount to scale
  5806. */
  5807. scale(scale: number): void;
  5808. /**
  5809. * Gets the spherical polynomial from harmonics
  5810. * @param harmonics the spherical harmonics
  5811. * @returns the spherical polynomial
  5812. */
  5813. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5814. /**
  5815. * Constructs a spherical polynomial from an array.
  5816. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5817. * @returns the spherical polynomial
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5820. }
  5821. /**
  5822. * Class representing spherical harmonics coefficients to the 3rd degree
  5823. */
  5824. export class SphericalHarmonics {
  5825. /**
  5826. * The l0,0 coefficients of the spherical harmonics
  5827. */
  5828. l00: Vector3;
  5829. /**
  5830. * The l1,-1 coefficients of the spherical harmonics
  5831. */
  5832. l1_1: Vector3;
  5833. /**
  5834. * The l1,0 coefficients of the spherical harmonics
  5835. */
  5836. l10: Vector3;
  5837. /**
  5838. * The l1,1 coefficients of the spherical harmonics
  5839. */
  5840. l11: Vector3;
  5841. /**
  5842. * The l2,-2 coefficients of the spherical harmonics
  5843. */
  5844. l2_2: Vector3;
  5845. /**
  5846. * The l2,-1 coefficients of the spherical harmonics
  5847. */
  5848. l2_1: Vector3;
  5849. /**
  5850. * The l2,0 coefficients of the spherical harmonics
  5851. */
  5852. l20: Vector3;
  5853. /**
  5854. * The l2,1 coefficients of the spherical harmonics
  5855. */
  5856. l21: Vector3;
  5857. /**
  5858. * The l2,2 coefficients of the spherical harmonics
  5859. */
  5860. lL22: Vector3;
  5861. /**
  5862. * Adds a light to the spherical harmonics
  5863. * @param direction the direction of the light
  5864. * @param color the color of the light
  5865. * @param deltaSolidAngle the delta solid angle of the light
  5866. */
  5867. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5868. /**
  5869. * Scales the spherical harmonics by the given amount
  5870. * @param scale the amount to scale
  5871. */
  5872. scale(scale: number): void;
  5873. /**
  5874. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5875. *
  5876. * ```
  5877. * E_lm = A_l * L_lm
  5878. * ```
  5879. *
  5880. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5881. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5882. * the scaling factors are given in equation 9.
  5883. */
  5884. convertIncidentRadianceToIrradiance(): void;
  5885. /**
  5886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5887. *
  5888. * ```
  5889. * L = (1/pi) * E * rho
  5890. * ```
  5891. *
  5892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5893. */
  5894. convertIrradianceToLambertianRadiance(): void;
  5895. /**
  5896. * Gets the spherical harmonics from polynomial
  5897. * @param polynomial the spherical polynomial
  5898. * @returns the spherical harmonics
  5899. */
  5900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5901. /**
  5902. * Constructs a spherical harmonics from an array.
  5903. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5904. * @returns the spherical harmonics
  5905. */
  5906. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5907. }
  5908. }
  5909. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5910. import { Nullable } from "babylonjs/types";
  5911. /**
  5912. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5913. */
  5914. export interface CubeMapInfo {
  5915. /**
  5916. * The pixel array for the front face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. front: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the back face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. back: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the left face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. left: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the right face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. right: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the up face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. up: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the down face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. down: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The size of the cubemap stored.
  5947. *
  5948. * Each faces will be size * size pixels.
  5949. */
  5950. size: number;
  5951. /**
  5952. * The format of the texture.
  5953. *
  5954. * RGBA, RGB.
  5955. */
  5956. format: number;
  5957. /**
  5958. * The type of the texture data.
  5959. *
  5960. * UNSIGNED_INT, FLOAT.
  5961. */
  5962. type: number;
  5963. /**
  5964. * Specifies whether the texture is in gamma space.
  5965. */
  5966. gammaSpace: boolean;
  5967. }
  5968. /**
  5969. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5970. */
  5971. export class PanoramaToCubeMapTools {
  5972. private static FACE_FRONT;
  5973. private static FACE_BACK;
  5974. private static FACE_RIGHT;
  5975. private static FACE_LEFT;
  5976. private static FACE_DOWN;
  5977. private static FACE_UP;
  5978. /**
  5979. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5980. *
  5981. * @param float32Array The source data.
  5982. * @param inputWidth The width of the input panorama.
  5983. * @param inputHeight The height of the input panorama.
  5984. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5985. * @return The cubemap data
  5986. */
  5987. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5988. private static CreateCubemapTexture;
  5989. private static CalcProjectionSpherical;
  5990. }
  5991. }
  5992. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5996. /**
  5997. * Helper class dealing with the extraction of spherical polynomial dataArray
  5998. * from a cube map.
  5999. */
  6000. export class CubeMapToSphericalPolynomialTools {
  6001. private static FileFaces;
  6002. /**
  6003. * Converts a texture to the according Spherical Polynomial data.
  6004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6005. *
  6006. * @param texture The texture to extract the information from.
  6007. * @return The Spherical Polynomial data.
  6008. */
  6009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6010. /**
  6011. * Converts a cubemap to the according Spherical Polynomial data.
  6012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6013. *
  6014. * @param cubeInfo The Cube map to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6018. }
  6019. }
  6020. declare module "babylonjs/Engines/engineStore" {
  6021. import { Nullable } from "babylonjs/types";
  6022. import { Engine } from "babylonjs/Engines/engine";
  6023. import { Scene } from "babylonjs/scene";
  6024. /**
  6025. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6026. * during the life time of the application.
  6027. */
  6028. export class EngineStore {
  6029. /** Gets the list of created engines */
  6030. static Instances: import("babylonjs/Engines/engine").Engine[];
  6031. /**
  6032. * Gets the latest created engine
  6033. */
  6034. static readonly LastCreatedEngine: Nullable<Engine>;
  6035. /**
  6036. * Gets the latest created scene
  6037. */
  6038. static readonly LastCreatedScene: Nullable<Scene>;
  6039. }
  6040. }
  6041. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6042. /**
  6043. * Define options used to create a render target texture
  6044. */
  6045. export class RenderTargetCreationOptions {
  6046. /**
  6047. * Specifies is mipmaps must be generated
  6048. */
  6049. generateMipMaps?: boolean;
  6050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6051. generateDepthBuffer?: boolean;
  6052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6053. generateStencilBuffer?: boolean;
  6054. /** Defines texture type (int by default) */
  6055. type?: number;
  6056. /** Defines sampling mode (trilinear by default) */
  6057. samplingMode?: number;
  6058. /** Defines format (RGBA by default) */
  6059. format?: number;
  6060. }
  6061. }
  6062. declare module "babylonjs/States/alphaCullingState" {
  6063. /**
  6064. * @hidden
  6065. **/
  6066. export class _AlphaState {
  6067. private _isAlphaBlendDirty;
  6068. private _isBlendFunctionParametersDirty;
  6069. private _isBlendEquationParametersDirty;
  6070. private _isBlendConstantsDirty;
  6071. private _alphaBlend;
  6072. private _blendFunctionParameters;
  6073. private _blendEquationParameters;
  6074. private _blendConstants;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. alphaBlend: boolean;
  6081. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6082. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6083. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6084. reset(): void;
  6085. apply(gl: WebGLRenderingContext): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/States/depthCullingState" {
  6089. import { Nullable } from "babylonjs/types";
  6090. /**
  6091. * @hidden
  6092. **/
  6093. export class _DepthCullingState {
  6094. private _isDepthTestDirty;
  6095. private _isDepthMaskDirty;
  6096. private _isDepthFuncDirty;
  6097. private _isCullFaceDirty;
  6098. private _isCullDirty;
  6099. private _isZOffsetDirty;
  6100. private _isFrontFaceDirty;
  6101. private _depthTest;
  6102. private _depthMask;
  6103. private _depthFunc;
  6104. private _cull;
  6105. private _cullFace;
  6106. private _zOffset;
  6107. private _frontFace;
  6108. /**
  6109. * Initializes the state.
  6110. */
  6111. constructor();
  6112. readonly isDirty: boolean;
  6113. zOffset: number;
  6114. cullFace: Nullable<number>;
  6115. cull: Nullable<boolean>;
  6116. depthFunc: Nullable<number>;
  6117. depthMask: boolean;
  6118. depthTest: boolean;
  6119. frontFace: Nullable<number>;
  6120. reset(): void;
  6121. apply(gl: WebGLRenderingContext): void;
  6122. }
  6123. }
  6124. declare module "babylonjs/States/stencilState" {
  6125. /**
  6126. * @hidden
  6127. **/
  6128. export class _StencilState {
  6129. /** 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 */
  6130. static readonly ALWAYS: number;
  6131. /** Passed to stencilOperation to specify that stencil value must be kept */
  6132. static readonly KEEP: number;
  6133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6134. static readonly REPLACE: number;
  6135. private _isStencilTestDirty;
  6136. private _isStencilMaskDirty;
  6137. private _isStencilFuncDirty;
  6138. private _isStencilOpDirty;
  6139. private _stencilTest;
  6140. private _stencilMask;
  6141. private _stencilFunc;
  6142. private _stencilFuncRef;
  6143. private _stencilFuncMask;
  6144. private _stencilOpStencilFail;
  6145. private _stencilOpDepthFail;
  6146. private _stencilOpStencilDepthPass;
  6147. readonly isDirty: boolean;
  6148. stencilFunc: number;
  6149. stencilFuncRef: number;
  6150. stencilFuncMask: number;
  6151. stencilOpStencilFail: number;
  6152. stencilOpDepthFail: number;
  6153. stencilOpStencilDepthPass: number;
  6154. stencilMask: number;
  6155. stencilTest: boolean;
  6156. constructor();
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/index" {
  6162. export * from "babylonjs/States/alphaCullingState";
  6163. export * from "babylonjs/States/depthCullingState";
  6164. export * from "babylonjs/States/stencilState";
  6165. }
  6166. declare module "babylonjs/Instrumentation/timeToken" {
  6167. import { Nullable } from "babylonjs/types";
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _TimeToken {
  6172. _startTimeQuery: Nullable<WebGLQuery>;
  6173. _endTimeQuery: Nullable<WebGLQuery>;
  6174. _timeElapsedQuery: Nullable<WebGLQuery>;
  6175. _timeElapsedQueryEnded: boolean;
  6176. }
  6177. }
  6178. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6179. import { Nullable } from "babylonjs/types";
  6180. /**
  6181. * Internal interface used to track InternalTexture already bound to the GL context
  6182. */
  6183. export interface IInternalTextureTracker {
  6184. /**
  6185. * Gets or set the previous tracker in the list
  6186. */
  6187. previous: Nullable<IInternalTextureTracker>;
  6188. /**
  6189. * Gets or set the next tracker in the list
  6190. */
  6191. next: Nullable<IInternalTextureTracker>;
  6192. }
  6193. /**
  6194. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6195. */
  6196. export class DummyInternalTextureTracker {
  6197. /**
  6198. * Gets or set the previous tracker in the list
  6199. */
  6200. previous: Nullable<IInternalTextureTracker>;
  6201. /**
  6202. * Gets or set the next tracker in the list
  6203. */
  6204. next: Nullable<IInternalTextureTracker>;
  6205. }
  6206. }
  6207. declare module "babylonjs/Materials/Textures/internalTexture" {
  6208. import { Observable } from "babylonjs/Misc/observable";
  6209. import { Nullable, int } from "babylonjs/types";
  6210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6211. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6212. import { Engine } from "babylonjs/Engines/engine";
  6213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6214. /**
  6215. * Class used to store data associated with WebGL texture data for the engine
  6216. * This class should not be used directly
  6217. */
  6218. export class InternalTexture implements IInternalTextureTracker {
  6219. /** hidden */
  6220. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6221. /**
  6222. * The source of the texture data is unknown
  6223. */
  6224. static DATASOURCE_UNKNOWN: number;
  6225. /**
  6226. * Texture data comes from an URL
  6227. */
  6228. static DATASOURCE_URL: number;
  6229. /**
  6230. * Texture data is only used for temporary storage
  6231. */
  6232. static DATASOURCE_TEMP: number;
  6233. /**
  6234. * Texture data comes from raw data (ArrayBuffer)
  6235. */
  6236. static DATASOURCE_RAW: number;
  6237. /**
  6238. * Texture content is dynamic (video or dynamic texture)
  6239. */
  6240. static DATASOURCE_DYNAMIC: number;
  6241. /**
  6242. * Texture content is generated by rendering to it
  6243. */
  6244. static DATASOURCE_RENDERTARGET: number;
  6245. /**
  6246. * Texture content is part of a multi render target process
  6247. */
  6248. static DATASOURCE_MULTIRENDERTARGET: number;
  6249. /**
  6250. * Texture data comes from a cube data file
  6251. */
  6252. static DATASOURCE_CUBE: number;
  6253. /**
  6254. * Texture data comes from a raw cube data
  6255. */
  6256. static DATASOURCE_CUBERAW: number;
  6257. /**
  6258. * Texture data come from a prefiltered cube data file
  6259. */
  6260. static DATASOURCE_CUBEPREFILTERED: number;
  6261. /**
  6262. * Texture content is raw 3D data
  6263. */
  6264. static DATASOURCE_RAW3D: number;
  6265. /**
  6266. * Texture content is a depth texture
  6267. */
  6268. static DATASOURCE_DEPTHTEXTURE: number;
  6269. /**
  6270. * Texture data comes from a raw cube data encoded with RGBD
  6271. */
  6272. static DATASOURCE_CUBERAW_RGBD: number;
  6273. /**
  6274. * Defines if the texture is ready
  6275. */
  6276. isReady: boolean;
  6277. /**
  6278. * Defines if the texture is a cube texture
  6279. */
  6280. isCube: boolean;
  6281. /**
  6282. * Defines if the texture contains 3D data
  6283. */
  6284. is3D: boolean;
  6285. /**
  6286. * Defines if the texture contains multiview data
  6287. */
  6288. isMultiview: boolean;
  6289. /**
  6290. * Gets the URL used to load this texture
  6291. */
  6292. url: string;
  6293. /**
  6294. * Gets the sampling mode of the texture
  6295. */
  6296. samplingMode: number;
  6297. /**
  6298. * Gets a boolean indicating if the texture needs mipmaps generation
  6299. */
  6300. generateMipMaps: boolean;
  6301. /**
  6302. * Gets the number of samples used by the texture (WebGL2+ only)
  6303. */
  6304. samples: number;
  6305. /**
  6306. * Gets the type of the texture (int, float...)
  6307. */
  6308. type: number;
  6309. /**
  6310. * Gets the format of the texture (RGB, RGBA...)
  6311. */
  6312. format: number;
  6313. /**
  6314. * Observable called when the texture is loaded
  6315. */
  6316. onLoadedObservable: Observable<InternalTexture>;
  6317. /**
  6318. * Gets the width of the texture
  6319. */
  6320. width: number;
  6321. /**
  6322. * Gets the height of the texture
  6323. */
  6324. height: number;
  6325. /**
  6326. * Gets the depth of the texture
  6327. */
  6328. depth: number;
  6329. /**
  6330. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseWidth: number;
  6333. /**
  6334. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseHeight: number;
  6337. /**
  6338. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6339. */
  6340. baseDepth: number;
  6341. /**
  6342. * Gets a boolean indicating if the texture is inverted on Y axis
  6343. */
  6344. invertY: boolean;
  6345. /**
  6346. * Gets or set the previous tracker in the list
  6347. */
  6348. previous: Nullable<IInternalTextureTracker>;
  6349. /**
  6350. * Gets or set the next tracker in the list
  6351. */
  6352. next: Nullable<IInternalTextureTracker>;
  6353. /** @hidden */
  6354. _invertVScale: boolean;
  6355. /** @hidden */
  6356. _initialSlot: number;
  6357. /** @hidden */
  6358. _designatedSlot: number;
  6359. /** @hidden */
  6360. _dataSource: number;
  6361. /** @hidden */
  6362. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6363. /** @hidden */
  6364. _bufferView: Nullable<ArrayBufferView>;
  6365. /** @hidden */
  6366. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6367. /** @hidden */
  6368. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6369. /** @hidden */
  6370. _size: number;
  6371. /** @hidden */
  6372. _extension: string;
  6373. /** @hidden */
  6374. _files: Nullable<string[]>;
  6375. /** @hidden */
  6376. _workingCanvas: HTMLCanvasElement;
  6377. /** @hidden */
  6378. _workingContext: CanvasRenderingContext2D;
  6379. /** @hidden */
  6380. _framebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6385. /** @hidden */
  6386. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6387. /** @hidden */
  6388. _attachments: Nullable<number[]>;
  6389. /** @hidden */
  6390. _cachedCoordinatesMode: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapU: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedWrapV: Nullable<number>;
  6395. /** @hidden */
  6396. _cachedWrapR: Nullable<number>;
  6397. /** @hidden */
  6398. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6399. /** @hidden */
  6400. _isDisabled: boolean;
  6401. /** @hidden */
  6402. _compression: Nullable<string>;
  6403. /** @hidden */
  6404. _generateStencilBuffer: boolean;
  6405. /** @hidden */
  6406. _generateDepthBuffer: boolean;
  6407. /** @hidden */
  6408. _comparisonFunction: number;
  6409. /** @hidden */
  6410. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6411. /** @hidden */
  6412. _lodGenerationScale: number;
  6413. /** @hidden */
  6414. _lodGenerationOffset: number;
  6415. /** @hidden */
  6416. _colorTextureArray: Nullable<WebGLTexture>;
  6417. /** @hidden */
  6418. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6419. /** @hidden */
  6420. _lodTextureHigh: BaseTexture;
  6421. /** @hidden */
  6422. _lodTextureMid: BaseTexture;
  6423. /** @hidden */
  6424. _lodTextureLow: BaseTexture;
  6425. /** @hidden */
  6426. _isRGBD: boolean;
  6427. /** @hidden */
  6428. _webGLTexture: Nullable<WebGLTexture>;
  6429. /** @hidden */
  6430. _references: number;
  6431. private _engine;
  6432. /**
  6433. * Gets the Engine the texture belongs to.
  6434. * @returns The babylon engine
  6435. */
  6436. getEngine(): Engine;
  6437. /**
  6438. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6439. */
  6440. readonly dataSource: number;
  6441. /**
  6442. * Creates a new InternalTexture
  6443. * @param engine defines the engine to use
  6444. * @param dataSource defines the type of data that will be used
  6445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6446. */
  6447. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6448. /**
  6449. * Increments the number of references (ie. the number of Texture that point to it)
  6450. */
  6451. incrementReferences(): void;
  6452. /**
  6453. * Change the size of the texture (not the size of the content)
  6454. * @param width defines the new width
  6455. * @param height defines the new height
  6456. * @param depth defines the new depth (1 by default)
  6457. */
  6458. updateSize(width: int, height: int, depth?: int): void;
  6459. /** @hidden */
  6460. _rebuild(): void;
  6461. /** @hidden */
  6462. _swapAndDie(target: InternalTexture): void;
  6463. /**
  6464. * Dispose the current allocated resources
  6465. */
  6466. dispose(): void;
  6467. }
  6468. }
  6469. declare module "babylonjs/Animations/easing" {
  6470. /**
  6471. * This represents the main contract an easing function should follow.
  6472. * Easing functions are used throughout the animation system.
  6473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6474. */
  6475. export interface IEasingFunction {
  6476. /**
  6477. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6478. * of the easing function.
  6479. * The link below provides some of the most common examples of easing functions.
  6480. * @see https://easings.net/
  6481. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6482. * @returns the corresponding value on the curve defined by the easing function
  6483. */
  6484. ease(gradient: number): number;
  6485. }
  6486. /**
  6487. * Base class used for every default easing function.
  6488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6489. */
  6490. export class EasingFunction implements IEasingFunction {
  6491. /**
  6492. * Interpolation follows the mathematical formula associated with the easing function.
  6493. */
  6494. static readonly EASINGMODE_EASEIN: number;
  6495. /**
  6496. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6497. */
  6498. static readonly EASINGMODE_EASEOUT: number;
  6499. /**
  6500. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6501. */
  6502. static readonly EASINGMODE_EASEINOUT: number;
  6503. private _easingMode;
  6504. /**
  6505. * Sets the easing mode of the current function.
  6506. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6507. */
  6508. setEasingMode(easingMode: number): void;
  6509. /**
  6510. * Gets the current easing mode.
  6511. * @returns the easing mode
  6512. */
  6513. getEasingMode(): number;
  6514. /**
  6515. * @hidden
  6516. */
  6517. easeInCore(gradient: number): number;
  6518. /**
  6519. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6520. * of the easing function.
  6521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6522. * @returns the corresponding value on the curve defined by the easing function
  6523. */
  6524. ease(gradient: number): number;
  6525. }
  6526. /**
  6527. * Easing function with a circle shape (see link below).
  6528. * @see https://easings.net/#easeInCirc
  6529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6530. */
  6531. export class CircleEase extends EasingFunction implements IEasingFunction {
  6532. /** @hidden */
  6533. easeInCore(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a ease back shape (see link below).
  6537. * @see https://easings.net/#easeInBack
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class BackEase extends EasingFunction implements IEasingFunction {
  6541. /** Defines the amplitude of the function */
  6542. amplitude: number;
  6543. /**
  6544. * Instantiates a back ease easing
  6545. * @see https://easings.net/#easeInBack
  6546. * @param amplitude Defines the amplitude of the function
  6547. */
  6548. constructor(
  6549. /** Defines the amplitude of the function */
  6550. amplitude?: number);
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a bouncing shape (see link below).
  6556. * @see https://easings.net/#easeInBounce
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class BounceEase extends EasingFunction implements IEasingFunction {
  6560. /** Defines the number of bounces */
  6561. bounces: number;
  6562. /** Defines the amplitude of the bounce */
  6563. bounciness: number;
  6564. /**
  6565. * Instantiates a bounce easing
  6566. * @see https://easings.net/#easeInBounce
  6567. * @param bounces Defines the number of bounces
  6568. * @param bounciness Defines the amplitude of the bounce
  6569. */
  6570. constructor(
  6571. /** Defines the number of bounces */
  6572. bounces?: number,
  6573. /** Defines the amplitude of the bounce */
  6574. bounciness?: number);
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 3 shape (see link below).
  6580. * @see https://easings.net/#easeInCubic
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class CubicEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with an elastic shape (see link below).
  6589. * @see https://easings.net/#easeInElastic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of oscillations*/
  6594. oscillations: number;
  6595. /** Defines the amplitude of the oscillations*/
  6596. springiness: number;
  6597. /**
  6598. * Instantiates an elastic easing function
  6599. * @see https://easings.net/#easeInElastic
  6600. * @param oscillations Defines the number of oscillations
  6601. * @param springiness Defines the amplitude of the oscillations
  6602. */
  6603. constructor(
  6604. /** Defines the number of oscillations*/
  6605. oscillations?: number,
  6606. /** Defines the amplitude of the oscillations*/
  6607. springiness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with an exponential shape (see link below).
  6613. * @see https://easings.net/#easeInExpo
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6617. /** Defines the exponent of the function */
  6618. exponent: number;
  6619. /**
  6620. * Instantiates an exponential easing function
  6621. * @see https://easings.net/#easeInExpo
  6622. * @param exponent Defines the exponent of the function
  6623. */
  6624. constructor(
  6625. /** Defines the exponent of the function */
  6626. exponent?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. /**
  6631. * Easing function with a power shape (see link below).
  6632. * @see https://easings.net/#easeInQuad
  6633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6634. */
  6635. export class PowerEase extends EasingFunction implements IEasingFunction {
  6636. /** Defines the power of the function */
  6637. power: number;
  6638. /**
  6639. * Instantiates an power base easing function
  6640. * @see https://easings.net/#easeInQuad
  6641. * @param power Defines the power of the function
  6642. */
  6643. constructor(
  6644. /** Defines the power of the function */
  6645. power?: number);
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 2 shape (see link below).
  6651. * @see https://easings.net/#easeInQuad
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 4 shape (see link below).
  6660. * @see https://easings.net/#easeInQuart
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 5 shape (see link below).
  6669. * @see https://easings.net/#easeInQuint
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a sin shape (see link below).
  6678. * @see https://easings.net/#easeInSine
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class SineEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a bezier shape (see link below).
  6687. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6691. /** Defines the x component of the start tangent in the bezier curve */
  6692. x1: number;
  6693. /** Defines the y component of the start tangent in the bezier curve */
  6694. y1: number;
  6695. /** Defines the x component of the end tangent in the bezier curve */
  6696. x2: number;
  6697. /** Defines the y component of the end tangent in the bezier curve */
  6698. y2: number;
  6699. /**
  6700. * Instantiates a bezier function
  6701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6702. * @param x1 Defines the x component of the start tangent in the bezier curve
  6703. * @param y1 Defines the y component of the start tangent in the bezier curve
  6704. * @param x2 Defines the x component of the end tangent in the bezier curve
  6705. * @param y2 Defines the y component of the end tangent in the bezier curve
  6706. */
  6707. constructor(
  6708. /** Defines the x component of the start tangent in the bezier curve */
  6709. x1?: number,
  6710. /** Defines the y component of the start tangent in the bezier curve */
  6711. y1?: number,
  6712. /** Defines the x component of the end tangent in the bezier curve */
  6713. x2?: number,
  6714. /** Defines the y component of the end tangent in the bezier curve */
  6715. y2?: number);
  6716. /** @hidden */
  6717. easeInCore(gradient: number): number;
  6718. }
  6719. }
  6720. declare module "babylonjs/Animations/animationKey" {
  6721. /**
  6722. * Defines an interface which represents an animation key frame
  6723. */
  6724. export interface IAnimationKey {
  6725. /**
  6726. * Frame of the key frame
  6727. */
  6728. frame: number;
  6729. /**
  6730. * Value at the specifies key frame
  6731. */
  6732. value: any;
  6733. /**
  6734. * The input tangent for the cubic hermite spline
  6735. */
  6736. inTangent?: any;
  6737. /**
  6738. * The output tangent for the cubic hermite spline
  6739. */
  6740. outTangent?: any;
  6741. /**
  6742. * The animation interpolation type
  6743. */
  6744. interpolation?: AnimationKeyInterpolation;
  6745. }
  6746. /**
  6747. * Enum for the animation key frame interpolation type
  6748. */
  6749. export enum AnimationKeyInterpolation {
  6750. /**
  6751. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6752. */
  6753. STEP = 1
  6754. }
  6755. }
  6756. declare module "babylonjs/Animations/animationRange" {
  6757. /**
  6758. * Represents the range of an animation
  6759. */
  6760. export class AnimationRange {
  6761. /**The name of the animation range**/
  6762. name: string;
  6763. /**The starting frame of the animation */
  6764. from: number;
  6765. /**The ending frame of the animation*/
  6766. to: number;
  6767. /**
  6768. * Initializes the range of an animation
  6769. * @param name The name of the animation range
  6770. * @param from The starting frame of the animation
  6771. * @param to The ending frame of the animation
  6772. */
  6773. constructor(
  6774. /**The name of the animation range**/
  6775. name: string,
  6776. /**The starting frame of the animation */
  6777. from: number,
  6778. /**The ending frame of the animation*/
  6779. to: number);
  6780. /**
  6781. * Makes a copy of the animation range
  6782. * @returns A copy of the animation range
  6783. */
  6784. clone(): AnimationRange;
  6785. }
  6786. }
  6787. declare module "babylonjs/Animations/animationEvent" {
  6788. /**
  6789. * Composed of a frame, and an action function
  6790. */
  6791. export class AnimationEvent {
  6792. /** The frame for which the event is triggered **/
  6793. frame: number;
  6794. /** The event to perform when triggered **/
  6795. action: (currentFrame: number) => void;
  6796. /** Specifies if the event should be triggered only once**/
  6797. onlyOnce?: boolean | undefined;
  6798. /**
  6799. * Specifies if the animation event is done
  6800. */
  6801. isDone: boolean;
  6802. /**
  6803. * Initializes the animation event
  6804. * @param frame The frame for which the event is triggered
  6805. * @param action The event to perform when triggered
  6806. * @param onlyOnce Specifies if the event should be triggered only once
  6807. */
  6808. constructor(
  6809. /** The frame for which the event is triggered **/
  6810. frame: number,
  6811. /** The event to perform when triggered **/
  6812. action: (currentFrame: number) => void,
  6813. /** Specifies if the event should be triggered only once**/
  6814. onlyOnce?: boolean | undefined);
  6815. /** @hidden */
  6816. _clone(): AnimationEvent;
  6817. }
  6818. }
  6819. declare module "babylonjs/Behaviors/behavior" {
  6820. import { Nullable } from "babylonjs/types";
  6821. /**
  6822. * Interface used to define a behavior
  6823. */
  6824. export interface Behavior<T> {
  6825. /** gets or sets behavior's name */
  6826. name: string;
  6827. /**
  6828. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6829. */
  6830. init(): void;
  6831. /**
  6832. * Called when the behavior is attached to a target
  6833. * @param target defines the target where the behavior is attached to
  6834. */
  6835. attach(target: T): void;
  6836. /**
  6837. * Called when the behavior is detached from its target
  6838. */
  6839. detach(): void;
  6840. }
  6841. /**
  6842. * Interface implemented by classes supporting behaviors
  6843. */
  6844. export interface IBehaviorAware<T> {
  6845. /**
  6846. * Attach a behavior
  6847. * @param behavior defines the behavior to attach
  6848. * @returns the current host
  6849. */
  6850. addBehavior(behavior: Behavior<T>): T;
  6851. /**
  6852. * Remove a behavior from the current object
  6853. * @param behavior defines the behavior to detach
  6854. * @returns the current host
  6855. */
  6856. removeBehavior(behavior: Behavior<T>): T;
  6857. /**
  6858. * Gets a behavior using its name to search
  6859. * @param name defines the name to search
  6860. * @returns the behavior or null if not found
  6861. */
  6862. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6863. }
  6864. }
  6865. declare module "babylonjs/Collisions/intersectionInfo" {
  6866. import { Nullable } from "babylonjs/types";
  6867. /**
  6868. * @hidden
  6869. */
  6870. export class IntersectionInfo {
  6871. bu: Nullable<number>;
  6872. bv: Nullable<number>;
  6873. distance: number;
  6874. faceId: number;
  6875. subMeshId: number;
  6876. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6882. /**
  6883. * Class used to store bounding sphere information
  6884. */
  6885. export class BoundingSphere {
  6886. /**
  6887. * Gets the center of the bounding sphere in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in local space
  6892. */
  6893. radius: number;
  6894. /**
  6895. * Gets the center of the bounding sphere in world space
  6896. */
  6897. readonly centerWorld: Vector3;
  6898. /**
  6899. * Radius of the bounding sphere in world space
  6900. */
  6901. radiusWorld: number;
  6902. /**
  6903. * Gets the minimum vector in local space
  6904. */
  6905. readonly minimum: Vector3;
  6906. /**
  6907. * Gets the maximum vector in local space
  6908. */
  6909. readonly maximum: Vector3;
  6910. private _worldMatrix;
  6911. private static readonly TmpVector3;
  6912. /**
  6913. * Creates a new bounding sphere
  6914. * @param min defines the minimum vector (in local space)
  6915. * @param max defines the maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6919. /**
  6920. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6921. * @param min defines the new minimum vector (in local space)
  6922. * @param max defines the new maximum vector (in local space)
  6923. * @param worldMatrix defines the new world matrix
  6924. */
  6925. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6926. /**
  6927. * Scale the current bounding sphere by applying a scale factor
  6928. * @param factor defines the scale factor to apply
  6929. * @returns the current bounding box
  6930. */
  6931. scale(factor: number): BoundingSphere;
  6932. /**
  6933. * Gets the world matrix of the bounding box
  6934. * @returns a matrix
  6935. */
  6936. getWorldMatrix(): DeepImmutable<Matrix>;
  6937. /** @hidden */
  6938. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6939. /**
  6940. * Tests if the bounding sphere is intersecting the frustum planes
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @returns true if there is an intersection
  6943. */
  6944. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if the bounding sphere center is in between the frustum planes.
  6947. * Used for optimistic fast inclusion.
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @returns true if the sphere center is in between the frustum planes
  6950. */
  6951. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. /**
  6953. * Tests if a point is inside the bounding sphere
  6954. * @param point defines the point to test
  6955. * @returns true if the point is inside the bounding sphere
  6956. */
  6957. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6958. /**
  6959. * Checks if two sphere intersct
  6960. * @param sphere0 sphere 0
  6961. * @param sphere1 sphere 1
  6962. * @returns true if the speres intersect
  6963. */
  6964. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6965. }
  6966. }
  6967. declare module "babylonjs/Culling/boundingBox" {
  6968. import { DeepImmutable } from "babylonjs/types";
  6969. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6970. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6971. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6972. /**
  6973. * Class used to store bounding box information
  6974. */
  6975. export class BoundingBox implements ICullable {
  6976. /**
  6977. * Gets the 8 vectors representing the bounding box in local space
  6978. */
  6979. readonly vectors: Vector3[];
  6980. /**
  6981. * Gets the center of the bounding box in local space
  6982. */
  6983. readonly center: Vector3;
  6984. /**
  6985. * Gets the center of the bounding box in world space
  6986. */
  6987. readonly centerWorld: Vector3;
  6988. /**
  6989. * Gets the extend size in local space
  6990. */
  6991. readonly extendSize: Vector3;
  6992. /**
  6993. * Gets the extend size in world space
  6994. */
  6995. readonly extendSizeWorld: Vector3;
  6996. /**
  6997. * Gets the OBB (object bounding box) directions
  6998. */
  6999. readonly directions: Vector3[];
  7000. /**
  7001. * Gets the 8 vectors representing the bounding box in world space
  7002. */
  7003. readonly vectorsWorld: Vector3[];
  7004. /**
  7005. * Gets the minimum vector in world space
  7006. */
  7007. readonly minimumWorld: Vector3;
  7008. /**
  7009. * Gets the maximum vector in world space
  7010. */
  7011. readonly maximumWorld: Vector3;
  7012. /**
  7013. * Gets the minimum vector in local space
  7014. */
  7015. readonly minimum: Vector3;
  7016. /**
  7017. * Gets the maximum vector in local space
  7018. */
  7019. readonly maximum: Vector3;
  7020. private _worldMatrix;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * @hidden
  7024. */
  7025. _tag: number;
  7026. /**
  7027. * Creates a new bounding box
  7028. * @param min defines the minimum vector (in local space)
  7029. * @param max defines the maximum vector (in local space)
  7030. * @param worldMatrix defines the new world matrix
  7031. */
  7032. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7033. /**
  7034. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7035. * @param min defines the new minimum vector (in local space)
  7036. * @param max defines the new maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7040. /**
  7041. * Scale the current bounding box by applying a scale factor
  7042. * @param factor defines the scale factor to apply
  7043. * @returns the current bounding box
  7044. */
  7045. scale(factor: number): BoundingBox;
  7046. /**
  7047. * Gets the world matrix of the bounding box
  7048. * @returns a matrix
  7049. */
  7050. getWorldMatrix(): DeepImmutable<Matrix>;
  7051. /** @hidden */
  7052. _update(world: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Tests if the bounding box is intersecting the frustum planes
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. /**
  7060. * Tests if the bounding box is entirely inside the frustum planes
  7061. * @param frustumPlanes defines the frustum planes to test
  7062. * @returns true if there is an inclusion
  7063. */
  7064. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7065. /**
  7066. * Tests if a point is inside the bounding box
  7067. * @param point defines the point to test
  7068. * @returns true if the point is inside the bounding box
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Tests if the bounding box intersects with a bounding sphere
  7073. * @param sphere defines the sphere to test
  7074. * @returns true if there is an intersection
  7075. */
  7076. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7077. /**
  7078. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7079. * @param min defines the min vector to use
  7080. * @param max defines the max vector to use
  7081. * @returns true if there is an intersection
  7082. */
  7083. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Tests if two bounding boxes are intersections
  7086. * @param box0 defines the first box to test
  7087. * @param box1 defines the second box to test
  7088. * @returns true if there is an intersection
  7089. */
  7090. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7091. /**
  7092. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7093. * @param minPoint defines the minimum vector of the bounding box
  7094. * @param maxPoint defines the maximum vector of the bounding box
  7095. * @param sphereCenter defines the sphere center
  7096. * @param sphereRadius defines the sphere radius
  7097. * @returns true if there is an intersection
  7098. */
  7099. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7100. /**
  7101. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7102. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @return true if there is an inclusion
  7105. */
  7106. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @return true if there is an intersection
  7112. */
  7113. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. }
  7115. }
  7116. declare module "babylonjs/Collisions/collider" {
  7117. import { Nullable, IndicesArray } from "babylonjs/types";
  7118. import { Vector3, Plane } from "babylonjs/Maths/math";
  7119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7120. /** @hidden */
  7121. export class Collider {
  7122. /** Define if a collision was found */
  7123. collisionFound: boolean;
  7124. /**
  7125. * Define last intersection point in local space
  7126. */
  7127. intersectionPoint: Vector3;
  7128. /**
  7129. * Define last collided mesh
  7130. */
  7131. collidedMesh: Nullable<AbstractMesh>;
  7132. private _collisionPoint;
  7133. private _planeIntersectionPoint;
  7134. private _tempVector;
  7135. private _tempVector2;
  7136. private _tempVector3;
  7137. private _tempVector4;
  7138. private _edge;
  7139. private _baseToVertex;
  7140. private _destinationPoint;
  7141. private _slidePlaneNormal;
  7142. private _displacementVector;
  7143. /** @hidden */
  7144. _radius: Vector3;
  7145. /** @hidden */
  7146. _retry: number;
  7147. private _velocity;
  7148. private _basePoint;
  7149. private _epsilon;
  7150. /** @hidden */
  7151. _velocityWorldLength: number;
  7152. /** @hidden */
  7153. _basePointWorld: Vector3;
  7154. private _velocityWorld;
  7155. private _normalizedVelocity;
  7156. /** @hidden */
  7157. _initialVelocity: Vector3;
  7158. /** @hidden */
  7159. _initialPosition: Vector3;
  7160. private _nearestDistance;
  7161. private _collisionMask;
  7162. collisionMask: number;
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. readonly slidePlaneNormal: Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Collider } from "babylonjs/Collisions/collider";
  7187. /**
  7188. * Interface for cullable objects
  7189. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7190. */
  7191. export interface ICullable {
  7192. /**
  7193. * Checks if the object or part of the object is in the frustum
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isInFrustum(frustumPlanes: Plane[]): boolean;
  7198. /**
  7199. * Checks if a cullable object (mesh...) is in the camera frustum
  7200. * Unlike isInFrustum this cheks the full bounding box
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7205. }
  7206. /**
  7207. * Info for a bounding data of a mesh
  7208. */
  7209. export class BoundingInfo implements ICullable {
  7210. /**
  7211. * Bounding box for the mesh
  7212. */
  7213. readonly boundingBox: BoundingBox;
  7214. /**
  7215. * Bounding sphere for the mesh
  7216. */
  7217. readonly boundingSphere: BoundingSphere;
  7218. private _isLocked;
  7219. private static readonly TmpVector3;
  7220. /**
  7221. * Constructs bounding info
  7222. * @param minimum min vector of the bounding box/sphere
  7223. * @param maximum max vector of the bounding box/sphere
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7227. /**
  7228. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7229. * @param min defines the new minimum vector (in local space)
  7230. * @param max defines the new maximum vector (in local space)
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7234. /**
  7235. * min vector of the bounding box/sphere
  7236. */
  7237. readonly minimum: Vector3;
  7238. /**
  7239. * max vector of the bounding box/sphere
  7240. */
  7241. readonly maximum: Vector3;
  7242. /**
  7243. * If the info is locked and won't be updated to avoid perf overhead
  7244. */
  7245. isLocked: boolean;
  7246. /**
  7247. * Updates the bounding sphere and box
  7248. * @param world world matrix to be used to update
  7249. */
  7250. update(world: DeepImmutable<Matrix>): void;
  7251. /**
  7252. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7253. * @param center New center of the bounding info
  7254. * @param extend New extend of the bounding info
  7255. * @returns the current bounding info
  7256. */
  7257. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7258. /**
  7259. * Scale the current bounding info by applying a scale factor
  7260. * @param factor defines the scale factor to apply
  7261. * @returns the current bounding info
  7262. */
  7263. scale(factor: number): BoundingInfo;
  7264. /**
  7265. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7266. * @param frustumPlanes defines the frustum to test
  7267. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7268. * @returns true if the bounding info is in the frustum planes
  7269. */
  7270. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7271. /**
  7272. * Gets the world distance between the min and max points of the bounding box
  7273. */
  7274. readonly diagonalLength: number;
  7275. /**
  7276. * Checks if a cullable object (mesh...) is in the camera frustum
  7277. * Unlike isInFrustum this cheks the full bounding box
  7278. * @param frustumPlanes Camera near/planes
  7279. * @returns true if the object is in frustum otherwise false
  7280. */
  7281. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7282. /** @hidden */
  7283. _checkCollision(collider: Collider): boolean;
  7284. /**
  7285. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param point the point to check intersection with
  7288. * @returns if the point intersects
  7289. */
  7290. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7291. /**
  7292. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param boundingInfo the bounding info to check intersection with
  7295. * @param precise if the intersection should be done using OBB
  7296. * @returns if the bounding info intersects
  7297. */
  7298. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7299. }
  7300. }
  7301. declare module "babylonjs/Misc/smartArray" {
  7302. /**
  7303. * Defines an array and its length.
  7304. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7305. */
  7306. export interface ISmartArrayLike<T> {
  7307. /**
  7308. * The data of the array.
  7309. */
  7310. data: Array<T>;
  7311. /**
  7312. * The active length of the array.
  7313. */
  7314. length: number;
  7315. }
  7316. /**
  7317. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7318. */
  7319. export class SmartArray<T> implements ISmartArrayLike<T> {
  7320. /**
  7321. * The full set of data from the array.
  7322. */
  7323. data: Array<T>;
  7324. /**
  7325. * The active length of the array.
  7326. */
  7327. length: number;
  7328. protected _id: number;
  7329. /**
  7330. * Instantiates a Smart Array.
  7331. * @param capacity defines the default capacity of the array.
  7332. */
  7333. constructor(capacity: number);
  7334. /**
  7335. * Pushes a value at the end of the active data.
  7336. * @param value defines the object to push in the array.
  7337. */
  7338. push(value: T): void;
  7339. /**
  7340. * Iterates over the active data and apply the lambda to them.
  7341. * @param func defines the action to apply on each value.
  7342. */
  7343. forEach(func: (content: T) => void): void;
  7344. /**
  7345. * Sorts the full sets of data.
  7346. * @param compareFn defines the comparison function to apply.
  7347. */
  7348. sort(compareFn: (a: T, b: T) => number): void;
  7349. /**
  7350. * Resets the active data to an empty array.
  7351. */
  7352. reset(): void;
  7353. /**
  7354. * Releases all the data from the array as well as the array.
  7355. */
  7356. dispose(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * @param array defines the data to concatenate with.
  7360. */
  7361. concat(array: any): void;
  7362. /**
  7363. * Returns the position of a value in the active data.
  7364. * @param value defines the value to find the index for
  7365. * @returns the index if found in the active data otherwise -1
  7366. */
  7367. indexOf(value: T): number;
  7368. /**
  7369. * Returns whether an element is part of the active data.
  7370. * @param value defines the value to look for
  7371. * @returns true if found in the active data otherwise false
  7372. */
  7373. contains(value: T): boolean;
  7374. private static _GlobalId;
  7375. }
  7376. /**
  7377. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7378. * The data in this array can only be present once
  7379. */
  7380. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7381. private _duplicateId;
  7382. /**
  7383. * Pushes a value at the end of the active data.
  7384. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7385. * @param value defines the object to push in the array.
  7386. */
  7387. push(value: T): void;
  7388. /**
  7389. * Pushes a value at the end of the active data.
  7390. * If the data is already present, it won t be added again
  7391. * @param value defines the object to push in the array.
  7392. * @returns true if added false if it was already present
  7393. */
  7394. pushNoDuplicate(value: T): boolean;
  7395. /**
  7396. * Resets the active data to an empty array.
  7397. */
  7398. reset(): void;
  7399. /**
  7400. * Concats the active data with a given array.
  7401. * This ensures no dupplicate will be present in the result.
  7402. * @param array defines the data to concatenate with.
  7403. */
  7404. concatWithNoDuplicate(array: any): void;
  7405. }
  7406. }
  7407. declare module "babylonjs/Materials/multiMaterial" {
  7408. import { Nullable } from "babylonjs/types";
  7409. import { Scene } from "babylonjs/scene";
  7410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7411. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7413. import { Material } from "babylonjs/Materials/material";
  7414. /**
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. */
  7419. export class MultiMaterial extends Material {
  7420. private _subMaterials;
  7421. /**
  7422. * Gets or Sets the list of Materials used within the multi material.
  7423. * They need to be ordered according to the submeshes order in the associated mesh
  7424. */
  7425. subMaterials: Nullable<Material>[];
  7426. /**
  7427. * Function used to align with Node.getChildren()
  7428. * @returns the list of Materials used within the multi material
  7429. */
  7430. getChildren(): Nullable<Material>[];
  7431. /**
  7432. * Instantiates a new Multi Material
  7433. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7434. * separate meshes. This can be use to improve performances.
  7435. * @see http://doc.babylonjs.com/how_to/multi_materials
  7436. * @param name Define the name in the scene
  7437. * @param scene Define the scene the material belongs to
  7438. */
  7439. constructor(name: string, scene: Scene);
  7440. private _hookArray;
  7441. /**
  7442. * Get one of the submaterial by its index in the submaterials array
  7443. * @param index The index to look the sub material at
  7444. * @returns The Material if the index has been defined
  7445. */
  7446. getSubMaterial(index: number): Nullable<Material>;
  7447. /**
  7448. * Get the list of active textures for the whole sub materials list.
  7449. * @returns All the textures that will be used during the rendering
  7450. */
  7451. getActiveTextures(): BaseTexture[];
  7452. /**
  7453. * Gets the current class name of the material e.g. "MultiMaterial"
  7454. * Mainly use in serialization.
  7455. * @returns the class name
  7456. */
  7457. getClassName(): string;
  7458. /**
  7459. * Checks if the material is ready to render the requested sub mesh
  7460. * @param mesh Define the mesh the submesh belongs to
  7461. * @param subMesh Define the sub mesh to look readyness for
  7462. * @param useInstances Define whether or not the material is used with instances
  7463. * @returns true if ready, otherwise false
  7464. */
  7465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7466. /**
  7467. * Clones the current material and its related sub materials
  7468. * @param name Define the name of the newly cloned material
  7469. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7470. * @returns the cloned material
  7471. */
  7472. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7473. /**
  7474. * Serializes the materials into a JSON representation.
  7475. * @returns the JSON representation
  7476. */
  7477. serialize(): any;
  7478. /**
  7479. * Dispose the material and release its associated resources
  7480. * @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)
  7481. * @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)
  7482. * @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)
  7483. */
  7484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7485. /**
  7486. * Creates a MultiMaterial from parsed MultiMaterial data.
  7487. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7488. * @param scene defines the hosting scene
  7489. * @returns a new MultiMaterial
  7490. */
  7491. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7492. }
  7493. }
  7494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7495. /**
  7496. * Class used to represent data loading progression
  7497. */
  7498. export class SceneLoaderFlags {
  7499. private static _ForceFullSceneLoadingForIncremental;
  7500. private static _ShowLoadingScreen;
  7501. private static _CleanBoneMatrixWeights;
  7502. private static _loggingLevel;
  7503. /**
  7504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7505. */
  7506. static ForceFullSceneLoadingForIncremental: boolean;
  7507. /**
  7508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7509. */
  7510. static ShowLoadingScreen: boolean;
  7511. /**
  7512. * Defines the current logging level (while loading the scene)
  7513. * @ignorenaming
  7514. */
  7515. static loggingLevel: number;
  7516. /**
  7517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7518. */
  7519. static CleanBoneMatrixWeights: boolean;
  7520. }
  7521. }
  7522. declare module "babylonjs/Meshes/transformNode" {
  7523. import { DeepImmutable } from "babylonjs/types";
  7524. import { Observable } from "babylonjs/Misc/observable";
  7525. import { Nullable } from "babylonjs/types";
  7526. import { Camera } from "babylonjs/Cameras/camera";
  7527. import { Scene } from "babylonjs/scene";
  7528. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7529. import { Node } from "babylonjs/node";
  7530. import { Bone } from "babylonjs/Bones/bone";
  7531. /**
  7532. * 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.
  7533. * @see https://doc.babylonjs.com/how_to/transformnode
  7534. */
  7535. export class TransformNode extends Node {
  7536. /**
  7537. * Object will not rotate to face the camera
  7538. */
  7539. static BILLBOARDMODE_NONE: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the x axis
  7542. */
  7543. static BILLBOARDMODE_X: number;
  7544. /**
  7545. * Object will rotate to face the camera but only on the y axis
  7546. */
  7547. static BILLBOARDMODE_Y: number;
  7548. /**
  7549. * Object will rotate to face the camera but only on the z axis
  7550. */
  7551. static BILLBOARDMODE_Z: number;
  7552. /**
  7553. * Object will rotate to face the camera
  7554. */
  7555. static BILLBOARDMODE_ALL: number;
  7556. private _forward;
  7557. private _forwardInverted;
  7558. private _up;
  7559. private _right;
  7560. private _rightInverted;
  7561. private _position;
  7562. private _rotation;
  7563. private _rotationQuaternion;
  7564. protected _scaling: Vector3;
  7565. protected _isDirty: boolean;
  7566. private _transformToBoneReferal;
  7567. /**
  7568. * Set the billboard mode. Default is 0.
  7569. *
  7570. * | Value | Type | Description |
  7571. * | --- | --- | --- |
  7572. * | 0 | BILLBOARDMODE_NONE | |
  7573. * | 1 | BILLBOARDMODE_X | |
  7574. * | 2 | BILLBOARDMODE_Y | |
  7575. * | 4 | BILLBOARDMODE_Z | |
  7576. * | 7 | BILLBOARDMODE_ALL | |
  7577. *
  7578. */
  7579. billboardMode: number;
  7580. /**
  7581. * 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
  7582. */
  7583. scalingDeterminant: number;
  7584. /**
  7585. * Sets the distance of the object to max, often used by skybox
  7586. */
  7587. infiniteDistance: boolean;
  7588. /**
  7589. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7590. * By default the system will update normals to compensate
  7591. */
  7592. ignoreNonUniformScaling: boolean;
  7593. /** @hidden */
  7594. _poseMatrix: Matrix;
  7595. /** @hidden */
  7596. _localMatrix: Matrix;
  7597. private _absolutePosition;
  7598. private _pivotMatrix;
  7599. private _pivotMatrixInverse;
  7600. protected _postMultiplyPivotMatrix: boolean;
  7601. private _tempMatrix;
  7602. private _tempMatrix2;
  7603. protected _isWorldMatrixFrozen: boolean;
  7604. /** @hidden */
  7605. _indexInSceneTransformNodesArray: number;
  7606. /**
  7607. * An event triggered after the world matrix is updated
  7608. */
  7609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7611. /**
  7612. * Gets a string identifying the name of the class
  7613. * @returns "TransformNode" string
  7614. */
  7615. getClassName(): string;
  7616. /**
  7617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7618. */
  7619. position: Vector3;
  7620. /**
  7621. * 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)).
  7622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7623. */
  7624. rotation: Vector3;
  7625. /**
  7626. * 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)).
  7627. */
  7628. scaling: Vector3;
  7629. /**
  7630. * 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).
  7631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7632. */
  7633. rotationQuaternion: Nullable<Quaternion>;
  7634. /**
  7635. * The forward direction of that transform in world space.
  7636. */
  7637. readonly forward: Vector3;
  7638. /**
  7639. * The up direction of that transform in world space.
  7640. */
  7641. readonly up: Vector3;
  7642. /**
  7643. * The right direction of that transform in world space.
  7644. */
  7645. readonly right: Vector3;
  7646. /**
  7647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7648. * @param matrix the matrix to copy the pose from
  7649. * @returns this TransformNode.
  7650. */
  7651. updatePoseMatrix(matrix: Matrix): TransformNode;
  7652. /**
  7653. * Returns the mesh Pose matrix.
  7654. * @returns the pose matrix
  7655. */
  7656. getPoseMatrix(): Matrix;
  7657. /** @hidden */
  7658. _isSynchronized(): boolean;
  7659. /** @hidden */
  7660. _initCache(): void;
  7661. /**
  7662. * Flag the transform node as dirty (Forcing it to update everything)
  7663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7664. * @returns this transform node
  7665. */
  7666. markAsDirty(property: string): TransformNode;
  7667. /**
  7668. * Returns the current mesh absolute position.
  7669. * Returns a Vector3.
  7670. */
  7671. readonly absolutePosition: Vector3;
  7672. /**
  7673. * Sets a new matrix to apply before all other transformation
  7674. * @param matrix defines the transform matrix
  7675. * @returns the current TransformNode
  7676. */
  7677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7678. /**
  7679. * Sets a new pivot matrix to the current node
  7680. * @param matrix defines the new pivot matrix to use
  7681. * @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
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7685. /**
  7686. * Returns the mesh pivot matrix.
  7687. * Default : Identity.
  7688. * @returns the matrix
  7689. */
  7690. getPivotMatrix(): Matrix;
  7691. /**
  7692. * Prevents the World matrix to be computed any longer.
  7693. * @returns the TransformNode.
  7694. */
  7695. freezeWorldMatrix(): TransformNode;
  7696. /**
  7697. * Allows back the World matrix computation.
  7698. * @returns the TransformNode.
  7699. */
  7700. unfreezeWorldMatrix(): this;
  7701. /**
  7702. * True if the World matrix has been frozen.
  7703. */
  7704. readonly isWorldMatrixFrozen: boolean;
  7705. /**
  7706. * Retuns the mesh absolute position in the World.
  7707. * @returns a Vector3.
  7708. */
  7709. getAbsolutePosition(): Vector3;
  7710. /**
  7711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7712. * @param absolutePosition the absolute position to set
  7713. * @returns the TransformNode.
  7714. */
  7715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7716. /**
  7717. * Sets the mesh position in its local space.
  7718. * @param vector3 the position to set in localspace
  7719. * @returns the TransformNode.
  7720. */
  7721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7722. /**
  7723. * Returns the mesh position in the local space from the current World matrix values.
  7724. * @returns a new Vector3.
  7725. */
  7726. getPositionExpressedInLocalSpace(): Vector3;
  7727. /**
  7728. * Translates the mesh along the passed Vector3 in its local space.
  7729. * @param vector3 the distance to translate in localspace
  7730. * @returns the TransformNode.
  7731. */
  7732. locallyTranslate(vector3: Vector3): TransformNode;
  7733. private static _lookAtVectorCache;
  7734. /**
  7735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7736. * @param targetPoint the position (must be in same space as current mesh) to look at
  7737. * @param yawCor optional yaw (y-axis) correction in radians
  7738. * @param pitchCor optional pitch (x-axis) correction in radians
  7739. * @param rollCor optional roll (z-axis) correction in radians
  7740. * @param space the choosen space of the target
  7741. * @returns the TransformNode.
  7742. */
  7743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7744. /**
  7745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7746. * This Vector3 is expressed in the World space.
  7747. * @param localAxis axis to rotate
  7748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7749. */
  7750. getDirection(localAxis: Vector3): Vector3;
  7751. /**
  7752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7753. * localAxis is expressed in the mesh local space.
  7754. * result is computed in the Wordl space from the mesh World matrix.
  7755. * @param localAxis axis to rotate
  7756. * @param result the resulting transformnode
  7757. * @returns this TransformNode.
  7758. */
  7759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7760. /**
  7761. * Sets this transform node rotation to the given local axis.
  7762. * @param localAxis the axis in local space
  7763. * @param yawCor optional yaw (y-axis) correction in radians
  7764. * @param pitchCor optional pitch (x-axis) correction in radians
  7765. * @param rollCor optional roll (z-axis) correction in radians
  7766. * @returns this TransformNode
  7767. */
  7768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7769. /**
  7770. * Sets a new pivot point to the current node
  7771. * @param point defines the new pivot point to use
  7772. * @param space defines if the point is in world or local space (local by default)
  7773. * @returns the current TransformNode
  7774. */
  7775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7776. /**
  7777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7778. * @returns the pivot point
  7779. */
  7780. getPivotPoint(): Vector3;
  7781. /**
  7782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7783. * @param result the vector3 to store the result
  7784. * @returns this TransformNode.
  7785. */
  7786. getPivotPointToRef(result: Vector3): TransformNode;
  7787. /**
  7788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7790. */
  7791. getAbsolutePivotPoint(): Vector3;
  7792. /**
  7793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7794. * @param result vector3 to store the result
  7795. * @returns this TransformNode.
  7796. */
  7797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7798. /**
  7799. * Defines the passed node as the parent of the current node.
  7800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7801. * @see https://doc.babylonjs.com/how_to/parenting
  7802. * @param node the node ot set as the parent
  7803. * @returns this TransformNode.
  7804. */
  7805. setParent(node: Nullable<Node>): TransformNode;
  7806. private _nonUniformScaling;
  7807. /**
  7808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7809. */
  7810. readonly nonUniformScaling: boolean;
  7811. /** @hidden */
  7812. _updateNonUniformScalingState(value: boolean): boolean;
  7813. /**
  7814. * Attach the current TransformNode to another TransformNode associated with a bone
  7815. * @param bone Bone affecting the TransformNode
  7816. * @param affectedTransformNode TransformNode associated with the bone
  7817. * @returns this object
  7818. */
  7819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7820. /**
  7821. * Detach the transform node if its associated with a bone
  7822. * @returns this object
  7823. */
  7824. detachFromBone(): TransformNode;
  7825. private static _rotationAxisCache;
  7826. /**
  7827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7830. * The passed axis is also normalized.
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @param space Space to rotate in (Default: local)
  7834. * @returns the TransformNode.
  7835. */
  7836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7837. /**
  7838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7840. * The passed axis is also normalized. .
  7841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7842. * @param point the point to rotate around
  7843. * @param axis the axis to rotate around
  7844. * @param amount the amount to rotate in radians
  7845. * @returns the TransformNode
  7846. */
  7847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7848. /**
  7849. * Translates the mesh along the axis vector for the passed distance in the given space.
  7850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7851. * @param axis the axis to translate in
  7852. * @param distance the distance to translate
  7853. * @param space Space to rotate in (Default: local)
  7854. * @returns the TransformNode.
  7855. */
  7856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7857. /**
  7858. * Adds a rotation step to the mesh current rotation.
  7859. * x, y, z are Euler angles expressed in radians.
  7860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7861. * This means this rotation is made in the mesh local space only.
  7862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7864. * ```javascript
  7865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7866. * ```
  7867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7868. * 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.
  7869. * @param x Rotation to add
  7870. * @param y Rotation to add
  7871. * @param z Rotation to add
  7872. * @returns the TransformNode.
  7873. */
  7874. addRotation(x: number, y: number, z: number): TransformNode;
  7875. /**
  7876. * Computes the world matrix of the node
  7877. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7878. * @returns the world matrix
  7879. */
  7880. computeWorldMatrix(force?: boolean): Matrix;
  7881. protected _afterComputeWorldMatrix(): void;
  7882. /**
  7883. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7884. * @param func callback function to add
  7885. *
  7886. * @returns the TransformNode.
  7887. */
  7888. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7889. /**
  7890. * Removes a registered callback function.
  7891. * @param func callback function to remove
  7892. * @returns the TransformNode.
  7893. */
  7894. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7895. /**
  7896. * Gets the position of the current mesh in camera space
  7897. * @param camera defines the camera to use
  7898. * @returns a position
  7899. */
  7900. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7901. /**
  7902. * Returns the distance from the mesh to the active camera
  7903. * @param camera defines the camera to use
  7904. * @returns the distance
  7905. */
  7906. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7907. /**
  7908. * Clone the current transform node
  7909. * @param name Name of the new clone
  7910. * @param newParent New parent for the clone
  7911. * @param doNotCloneChildren Do not clone children hierarchy
  7912. * @returns the new transform node
  7913. */
  7914. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7915. /**
  7916. * Serializes the objects information.
  7917. * @param currentSerializationObject defines the object to serialize in
  7918. * @returns the serialized object
  7919. */
  7920. serialize(currentSerializationObject?: any): any;
  7921. /**
  7922. * Returns a new TransformNode object parsed from the source provided.
  7923. * @param parsedTransformNode is the source.
  7924. * @param scene the scne the object belongs to
  7925. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7926. * @returns a new TransformNode object parsed from the source provided.
  7927. */
  7928. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7929. /**
  7930. * Get all child-transformNodes of this node
  7931. * @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
  7932. * @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
  7933. * @returns an array of TransformNode
  7934. */
  7935. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7936. /**
  7937. * Releases resources associated with this transform node.
  7938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7940. */
  7941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7942. }
  7943. }
  7944. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7945. /**
  7946. * Class used to override all child animations of a given target
  7947. */
  7948. export class AnimationPropertiesOverride {
  7949. /**
  7950. * Gets or sets a value indicating if animation blending must be used
  7951. */
  7952. enableBlending: boolean;
  7953. /**
  7954. * Gets or sets the blending speed to use when enableBlending is true
  7955. */
  7956. blendingSpeed: number;
  7957. /**
  7958. * Gets or sets the default loop mode to use
  7959. */
  7960. loopMode: number;
  7961. }
  7962. }
  7963. declare module "babylonjs/Bones/bone" {
  7964. import { Skeleton } from "babylonjs/Bones/skeleton";
  7965. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7966. import { Nullable } from "babylonjs/types";
  7967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7969. import { Node } from "babylonjs/node";
  7970. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7971. /**
  7972. * Class used to store bone information
  7973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7974. */
  7975. export class Bone extends Node {
  7976. /**
  7977. * defines the bone name
  7978. */
  7979. name: string;
  7980. private static _tmpVecs;
  7981. private static _tmpQuat;
  7982. private static _tmpMats;
  7983. /**
  7984. * Gets the list of child bones
  7985. */
  7986. children: Bone[];
  7987. /** Gets the animations associated with this bone */
  7988. animations: import("babylonjs/Animations/animation").Animation[];
  7989. /**
  7990. * Gets or sets bone length
  7991. */
  7992. length: number;
  7993. /**
  7994. * @hidden Internal only
  7995. * Set this value to map this bone to a different index in the transform matrices
  7996. * Set this value to -1 to exclude the bone from the transform matrices
  7997. */
  7998. _index: Nullable<number>;
  7999. private _skeleton;
  8000. private _localMatrix;
  8001. private _restPose;
  8002. private _baseMatrix;
  8003. private _absoluteTransform;
  8004. private _invertedAbsoluteTransform;
  8005. private _parent;
  8006. private _scalingDeterminant;
  8007. private _worldTransform;
  8008. private _localScaling;
  8009. private _localRotation;
  8010. private _localPosition;
  8011. private _needToDecompose;
  8012. private _needToCompose;
  8013. /** @hidden */
  8014. _linkedTransformNode: Nullable<TransformNode>;
  8015. /** @hidden */
  8016. /** @hidden */
  8017. _matrix: Matrix;
  8018. /**
  8019. * Create a new bone
  8020. * @param name defines the bone name
  8021. * @param skeleton defines the parent skeleton
  8022. * @param parentBone defines the parent (can be null if the bone is the root)
  8023. * @param localMatrix defines the local matrix
  8024. * @param restPose defines the rest pose matrix
  8025. * @param baseMatrix defines the base matrix
  8026. * @param index defines index of the bone in the hiearchy
  8027. */
  8028. constructor(
  8029. /**
  8030. * defines the bone name
  8031. */
  8032. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8033. /**
  8034. * Gets the current object class name.
  8035. * @return the class name
  8036. */
  8037. getClassName(): string;
  8038. /**
  8039. * Gets the parent skeleton
  8040. * @returns a skeleton
  8041. */
  8042. getSkeleton(): Skeleton;
  8043. /**
  8044. * Gets parent bone
  8045. * @returns a bone or null if the bone is the root of the bone hierarchy
  8046. */
  8047. getParent(): Nullable<Bone>;
  8048. /**
  8049. * Returns an array containing the root bones
  8050. * @returns an array containing the root bones
  8051. */
  8052. getChildren(): Array<Bone>;
  8053. /**
  8054. * Sets the parent bone
  8055. * @param parent defines the parent (can be null if the bone is the root)
  8056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8057. */
  8058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8059. /**
  8060. * Gets the local matrix
  8061. * @returns a matrix
  8062. */
  8063. getLocalMatrix(): Matrix;
  8064. /**
  8065. * Gets the base matrix (initial matrix which remains unchanged)
  8066. * @returns a matrix
  8067. */
  8068. getBaseMatrix(): Matrix;
  8069. /**
  8070. * Gets the rest pose matrix
  8071. * @returns a matrix
  8072. */
  8073. getRestPose(): Matrix;
  8074. /**
  8075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8076. */
  8077. getWorldMatrix(): Matrix;
  8078. /**
  8079. * Sets the local matrix to rest pose matrix
  8080. */
  8081. returnToRest(): void;
  8082. /**
  8083. * Gets the inverse of the absolute transform matrix.
  8084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8085. * @returns a matrix
  8086. */
  8087. getInvertedAbsoluteTransform(): Matrix;
  8088. /**
  8089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8090. * @returns a matrix
  8091. */
  8092. getAbsoluteTransform(): Matrix;
  8093. /**
  8094. * Links with the given transform node.
  8095. * The local matrix of this bone is copied from the transform node every frame.
  8096. * @param transformNode defines the transform node to link to
  8097. */
  8098. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8099. /** Gets or sets current position (in local space) */
  8100. position: Vector3;
  8101. /** Gets or sets current rotation (in local space) */
  8102. rotation: Vector3;
  8103. /** Gets or sets current rotation quaternion (in local space) */
  8104. rotationQuaternion: Quaternion;
  8105. /** Gets or sets current scaling (in local space) */
  8106. scaling: Vector3;
  8107. /**
  8108. * Gets the animation properties override
  8109. */
  8110. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8111. private _decompose;
  8112. private _compose;
  8113. /**
  8114. * Update the base and local matrices
  8115. * @param matrix defines the new base or local matrix
  8116. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8117. * @param updateLocalMatrix defines if the local matrix should be updated
  8118. */
  8119. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8120. /** @hidden */
  8121. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8122. /**
  8123. * Flag the bone as dirty (Forcing it to update everything)
  8124. */
  8125. markAsDirty(): void;
  8126. private _markAsDirtyAndCompose;
  8127. private _markAsDirtyAndDecompose;
  8128. /**
  8129. * Translate the bone in local or world space
  8130. * @param vec The amount to translate the bone
  8131. * @param space The space that the translation is in
  8132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8133. */
  8134. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8135. /**
  8136. * Set the postion of the bone in local or world space
  8137. * @param position The position to set the bone
  8138. * @param space The space that the position is in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. */
  8141. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8142. /**
  8143. * Set the absolute position of the bone (world space)
  8144. * @param position The position to set the bone
  8145. * @param mesh The mesh that this bone is attached to
  8146. */
  8147. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8148. /**
  8149. * Scale the bone on the x, y and z axes (in local space)
  8150. * @param x The amount to scale the bone on the x axis
  8151. * @param y The amount to scale the bone on the y axis
  8152. * @param z The amount to scale the bone on the z axis
  8153. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8154. */
  8155. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8156. /**
  8157. * Set the bone scaling in local space
  8158. * @param scale defines the scaling vector
  8159. */
  8160. setScale(scale: Vector3): void;
  8161. /**
  8162. * Gets the current scaling in local space
  8163. * @returns the current scaling vector
  8164. */
  8165. getScale(): Vector3;
  8166. /**
  8167. * Gets the current scaling in local space and stores it in a target vector
  8168. * @param result defines the target vector
  8169. */
  8170. getScaleToRef(result: Vector3): void;
  8171. /**
  8172. * Set the yaw, pitch, and roll of the bone in local or world space
  8173. * @param yaw The rotation of the bone on the y axis
  8174. * @param pitch The rotation of the bone on the x axis
  8175. * @param roll The rotation of the bone on the z axis
  8176. * @param space The space that the axes of rotation are in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Add a rotation to the bone on an axis in local or world space
  8182. * @param axis The axis to rotate the bone on
  8183. * @param amount The amount to rotate the bone
  8184. * @param space The space that the axis is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the rotation of the bone to a particular axis angle in local or world space
  8190. * @param axis The axis to rotate the bone on
  8191. * @param angle The angle that the bone should be rotated to
  8192. * @param space The space that the axis is in
  8193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8194. */
  8195. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8196. /**
  8197. * Set the euler rotation of the bone in local of world space
  8198. * @param rotation The euler rotation that the bone should be set to
  8199. * @param space The space that the rotation is in
  8200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8201. */
  8202. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8203. /**
  8204. * Set the quaternion rotation of the bone in local of world space
  8205. * @param quat The quaternion rotation that the bone should be set to
  8206. * @param space The space that the rotation is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. */
  8209. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8210. /**
  8211. * Set the rotation matrix of the bone in local of world space
  8212. * @param rotMat The rotation matrix that the bone should be set to
  8213. * @param space The space that the rotation is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8217. private _rotateWithMatrix;
  8218. private _getNegativeRotationToRef;
  8219. /**
  8220. * Get the position of the bone in local or world space
  8221. * @param space The space that the returned position is in
  8222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8223. * @returns The position of the bone
  8224. */
  8225. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8226. /**
  8227. * Copy the position of the bone to a vector3 in local or world space
  8228. * @param space The space that the returned position is in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. * @param result The vector3 to copy the position to
  8231. */
  8232. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8233. /**
  8234. * Get the absolute position of the bone (world space)
  8235. * @param mesh The mesh that this bone is attached to
  8236. * @returns The absolute position of the bone
  8237. */
  8238. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8239. /**
  8240. * Copy the absolute position of the bone (world space) to the result param
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @param result The vector3 to copy the absolute position to
  8243. */
  8244. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8245. /**
  8246. * Compute the absolute transforms of this bone and its children
  8247. */
  8248. computeAbsoluteTransforms(): void;
  8249. /**
  8250. * Get the world direction from an axis that is in the local space of the bone
  8251. * @param localAxis The local direction that is used to compute the world direction
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @returns The world direction
  8254. */
  8255. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8256. /**
  8257. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8258. * @param localAxis The local direction that is used to compute the world direction
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @param result The vector3 that the world direction will be copied to
  8261. */
  8262. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8263. /**
  8264. * Get the euler rotation of the bone in local or world space
  8265. * @param space The space that the rotation should be in
  8266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8267. * @returns The euler rotation
  8268. */
  8269. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8270. /**
  8271. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8272. * @param space The space that the rotation should be in
  8273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8274. * @param result The vector3 that the rotation should be copied to
  8275. */
  8276. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8277. /**
  8278. * Get the quaternion rotation of the bone in either local or world space
  8279. * @param space The space that the rotation should be in
  8280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8281. * @returns The quaternion rotation
  8282. */
  8283. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8284. /**
  8285. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8286. * @param space The space that the rotation should be in
  8287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8288. * @param result The quaternion that the rotation should be copied to
  8289. */
  8290. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8291. /**
  8292. * Get the rotation matrix of the bone in local or world space
  8293. * @param space The space that the rotation should be in
  8294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8295. * @returns The rotation matrix
  8296. */
  8297. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8298. /**
  8299. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8300. * @param space The space that the rotation should be in
  8301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8302. * @param result The quaternion that the rotation should be copied to
  8303. */
  8304. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8305. /**
  8306. * Get the world position of a point that is in the local space of the bone
  8307. * @param position The local position
  8308. * @param mesh The mesh that this bone is attached to
  8309. * @returns The world position
  8310. */
  8311. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8312. /**
  8313. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8314. * @param position The local position
  8315. * @param mesh The mesh that this bone is attached to
  8316. * @param result The vector3 that the world position should be copied to
  8317. */
  8318. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8319. /**
  8320. * Get the local position of a point that is in world space
  8321. * @param position The world position
  8322. * @param mesh The mesh that this bone is attached to
  8323. * @returns The local position
  8324. */
  8325. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8326. /**
  8327. * Get the local position of a point that is in world space and copy it to the result param
  8328. * @param position The world position
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @param result The vector3 that the local position should be copied to
  8331. */
  8332. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8333. }
  8334. }
  8335. declare module "babylonjs/Misc/iInspectable" {
  8336. /**
  8337. * Enum that determines the text-wrapping mode to use.
  8338. */
  8339. export enum InspectableType {
  8340. /**
  8341. * Checkbox for booleans
  8342. */
  8343. Checkbox = 0,
  8344. /**
  8345. * Sliders for numbers
  8346. */
  8347. Slider = 1,
  8348. /**
  8349. * Vector3
  8350. */
  8351. Vector3 = 2,
  8352. /**
  8353. * Quaternions
  8354. */
  8355. Quaternion = 3,
  8356. /**
  8357. * Color3
  8358. */
  8359. Color3 = 4
  8360. }
  8361. /**
  8362. * Interface used to define custom inspectable properties.
  8363. * This interface is used by the inspector to display custom property grids
  8364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8365. */
  8366. export interface IInspectable {
  8367. /**
  8368. * Gets the label to display
  8369. */
  8370. label: string;
  8371. /**
  8372. * Gets the name of the property to edit
  8373. */
  8374. propertyName: string;
  8375. /**
  8376. * Gets the type of the editor to use
  8377. */
  8378. type: InspectableType;
  8379. /**
  8380. * Gets the minimum value of the property when using in "slider" mode
  8381. */
  8382. min?: number;
  8383. /**
  8384. * Gets the maximum value of the property when using in "slider" mode
  8385. */
  8386. max?: number;
  8387. /**
  8388. * Gets the setp to use when using in "slider" mode
  8389. */
  8390. step?: number;
  8391. }
  8392. }
  8393. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8394. import { Nullable } from "babylonjs/types";
  8395. import { Scene } from "babylonjs/scene";
  8396. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. /**
  8399. * Class for creating a cube texture
  8400. */
  8401. export class CubeTexture extends BaseTexture {
  8402. private _delayedOnLoad;
  8403. /**
  8404. * The url of the texture
  8405. */
  8406. url: string;
  8407. /**
  8408. * Gets or sets the center of the bounding box associated with the cube texture.
  8409. * It must define where the camera used to render the texture was set
  8410. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8411. */
  8412. boundingBoxPosition: Vector3;
  8413. private _boundingBoxSize;
  8414. /**
  8415. * Gets or sets the size of the bounding box associated with the cube texture
  8416. * When defined, the cubemap will switch to local mode
  8417. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8418. * @example https://www.babylonjs-playground.com/#RNASML
  8419. */
  8420. /**
  8421. * Returns the bounding box size
  8422. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8423. */
  8424. boundingBoxSize: Vector3;
  8425. protected _rotationY: number;
  8426. /**
  8427. * Sets texture matrix rotation angle around Y axis in radians.
  8428. */
  8429. /**
  8430. * Gets texture matrix rotation angle around Y axis radians.
  8431. */
  8432. rotationY: number;
  8433. /**
  8434. * Are mip maps generated for this texture or not.
  8435. */
  8436. readonly noMipmap: boolean;
  8437. private _noMipmap;
  8438. private _files;
  8439. private _extensions;
  8440. private _textureMatrix;
  8441. private _format;
  8442. private _createPolynomials;
  8443. /** @hidden */
  8444. _prefiltered: boolean;
  8445. /**
  8446. * Creates a cube texture from an array of image urls
  8447. * @param files defines an array of image urls
  8448. * @param scene defines the hosting scene
  8449. * @param noMipmap specifies if mip maps are not used
  8450. * @returns a cube texture
  8451. */
  8452. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8453. /**
  8454. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8455. * @param url defines the url of the prefiltered texture
  8456. * @param scene defines the scene the texture is attached to
  8457. * @param forcedExtension defines the extension of the file if different from the url
  8458. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8459. * @return the prefiltered texture
  8460. */
  8461. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8462. /**
  8463. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8464. * as prefiltered data.
  8465. * @param rootUrl defines the url of the texture or the root name of the six images
  8466. * @param scene defines the scene the texture is attached to
  8467. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8468. * @param noMipmap defines if mipmaps should be created or not
  8469. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8470. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8471. * @param onError defines a callback triggered in case of error during load
  8472. * @param format defines the internal format to use for the texture once loaded
  8473. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8474. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8475. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8478. * @return the cube texture
  8479. */
  8480. 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);
  8481. /**
  8482. * Get the current class name of the texture useful for serialization or dynamic coding.
  8483. * @returns "CubeTexture"
  8484. */
  8485. getClassName(): string;
  8486. /**
  8487. * Update the url (and optional buffer) of this texture if url was null during construction.
  8488. * @param url the url of the texture
  8489. * @param forcedExtension defines the extension to use
  8490. * @param onLoad callback called when the texture is loaded (defaults to null)
  8491. */
  8492. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8493. /**
  8494. * Delays loading of the cube texture
  8495. * @param forcedExtension defines the extension to use
  8496. */
  8497. delayLoad(forcedExtension?: string): void;
  8498. /**
  8499. * Returns the reflection texture matrix
  8500. * @returns the reflection texture matrix
  8501. */
  8502. getReflectionTextureMatrix(): Matrix;
  8503. /**
  8504. * Sets the reflection texture matrix
  8505. * @param value Reflection texture matrix
  8506. */
  8507. setReflectionTextureMatrix(value: Matrix): void;
  8508. /**
  8509. * Parses text to create a cube texture
  8510. * @param parsedTexture define the serialized text to read from
  8511. * @param scene defines the hosting scene
  8512. * @param rootUrl defines the root url of the cube texture
  8513. * @returns a cube texture
  8514. */
  8515. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8516. /**
  8517. * Makes a clone, or deep copy, of the cube texture
  8518. * @returns a new cube texture
  8519. */
  8520. clone(): CubeTexture;
  8521. }
  8522. }
  8523. declare module "babylonjs/Shaders/postprocess.vertex" {
  8524. /** @hidden */
  8525. export var postprocessVertexShader: {
  8526. name: string;
  8527. shader: string;
  8528. };
  8529. }
  8530. declare module "babylonjs/Cameras/targetCamera" {
  8531. import { Nullable } from "babylonjs/types";
  8532. import { Camera } from "babylonjs/Cameras/camera";
  8533. import { Scene } from "babylonjs/scene";
  8534. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8535. /**
  8536. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8537. * This is the base of the follow, arc rotate cameras and Free camera
  8538. * @see http://doc.babylonjs.com/features/cameras
  8539. */
  8540. export class TargetCamera extends Camera {
  8541. private static _RigCamTransformMatrix;
  8542. private static _TargetTransformMatrix;
  8543. private static _TargetFocalPoint;
  8544. /**
  8545. * Define the current direction the camera is moving to
  8546. */
  8547. cameraDirection: Vector3;
  8548. /**
  8549. * Define the current rotation the camera is rotating to
  8550. */
  8551. cameraRotation: Vector2;
  8552. /**
  8553. * When set, the up vector of the camera will be updated by the rotation of the camera
  8554. */
  8555. updateUpVectorFromRotation: boolean;
  8556. private _tmpQuaternion;
  8557. /**
  8558. * Define the current rotation of the camera
  8559. */
  8560. rotation: Vector3;
  8561. /**
  8562. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8563. */
  8564. rotationQuaternion: Quaternion;
  8565. /**
  8566. * Define the current speed of the camera
  8567. */
  8568. speed: number;
  8569. /**
  8570. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8571. * around all axis.
  8572. */
  8573. noRotationConstraint: boolean;
  8574. /**
  8575. * Define the current target of the camera as an object or a position.
  8576. */
  8577. lockedTarget: any;
  8578. /** @hidden */
  8579. _currentTarget: Vector3;
  8580. /** @hidden */
  8581. _initialFocalDistance: number;
  8582. /** @hidden */
  8583. _viewMatrix: Matrix;
  8584. /** @hidden */
  8585. _camMatrix: Matrix;
  8586. /** @hidden */
  8587. _cameraTransformMatrix: Matrix;
  8588. /** @hidden */
  8589. _cameraRotationMatrix: Matrix;
  8590. /** @hidden */
  8591. _referencePoint: Vector3;
  8592. /** @hidden */
  8593. _transformedReferencePoint: Vector3;
  8594. protected _globalCurrentTarget: Vector3;
  8595. protected _globalCurrentUpVector: Vector3;
  8596. /** @hidden */
  8597. _reset: () => void;
  8598. private _defaultUp;
  8599. /**
  8600. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8601. * This is the base of the follow, arc rotate cameras and Free camera
  8602. * @see http://doc.babylonjs.com/features/cameras
  8603. * @param name Defines the name of the camera in the scene
  8604. * @param position Defines the start position of the camera in the scene
  8605. * @param scene Defines the scene the camera belongs to
  8606. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8607. */
  8608. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8609. /**
  8610. * Gets the position in front of the camera at a given distance.
  8611. * @param distance The distance from the camera we want the position to be
  8612. * @returns the position
  8613. */
  8614. getFrontPosition(distance: number): Vector3;
  8615. /** @hidden */
  8616. _getLockedTargetPosition(): Nullable<Vector3>;
  8617. private _storedPosition;
  8618. private _storedRotation;
  8619. private _storedRotationQuaternion;
  8620. /**
  8621. * Store current camera state of the camera (fov, position, rotation, etc..)
  8622. * @returns the camera
  8623. */
  8624. storeState(): Camera;
  8625. /**
  8626. * Restored camera state. You must call storeState() first
  8627. * @returns whether it was successful or not
  8628. * @hidden
  8629. */
  8630. _restoreStateValues(): boolean;
  8631. /** @hidden */
  8632. _initCache(): void;
  8633. /** @hidden */
  8634. _updateCache(ignoreParentClass?: boolean): void;
  8635. /** @hidden */
  8636. _isSynchronizedViewMatrix(): boolean;
  8637. /** @hidden */
  8638. _computeLocalCameraSpeed(): number;
  8639. /**
  8640. * Defines the target the camera should look at.
  8641. * This will automatically adapt alpha beta and radius to fit within the new target.
  8642. * @param target Defines the new target as a Vector or a mesh
  8643. */
  8644. setTarget(target: Vector3): void;
  8645. /**
  8646. * Return the current target position of the camera. This value is expressed in local space.
  8647. * @returns the target position
  8648. */
  8649. getTarget(): Vector3;
  8650. /** @hidden */
  8651. _decideIfNeedsToMove(): boolean;
  8652. /** @hidden */
  8653. _updatePosition(): void;
  8654. /** @hidden */
  8655. _checkInputs(): void;
  8656. protected _updateCameraRotationMatrix(): void;
  8657. /**
  8658. * 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)
  8659. * @returns the current camera
  8660. */
  8661. private _rotateUpVectorWithCameraRotationMatrix;
  8662. private _cachedRotationZ;
  8663. private _cachedQuaternionRotationZ;
  8664. /** @hidden */
  8665. _getViewMatrix(): Matrix;
  8666. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8667. /**
  8668. * @hidden
  8669. */
  8670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8671. /**
  8672. * @hidden
  8673. */
  8674. _updateRigCameras(): void;
  8675. private _getRigCamPositionAndTarget;
  8676. /**
  8677. * Gets the current object class name.
  8678. * @return the class name
  8679. */
  8680. getClassName(): string;
  8681. }
  8682. }
  8683. declare module "babylonjs/Cameras/cameraInputsManager" {
  8684. import { Nullable } from "babylonjs/types";
  8685. import { Camera } from "babylonjs/Cameras/camera";
  8686. /**
  8687. * @ignore
  8688. * This is a list of all the different input types that are available in the application.
  8689. * Fo instance: ArcRotateCameraGamepadInput...
  8690. */
  8691. export var CameraInputTypes: {};
  8692. /**
  8693. * This is the contract to implement in order to create a new input class.
  8694. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8695. */
  8696. export interface ICameraInput<TCamera extends Camera> {
  8697. /**
  8698. * Defines the camera the input is attached to.
  8699. */
  8700. camera: Nullable<TCamera>;
  8701. /**
  8702. * Gets the class name of the current intput.
  8703. * @returns the class name
  8704. */
  8705. getClassName(): string;
  8706. /**
  8707. * Get the friendly name associated with the input class.
  8708. * @returns the input friendly name
  8709. */
  8710. getSimpleName(): string;
  8711. /**
  8712. * Attach the input controls to a specific dom element to get the input from.
  8713. * @param element Defines the element the controls should be listened from
  8714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8715. */
  8716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8717. /**
  8718. * Detach the current controls from the specified dom element.
  8719. * @param element Defines the element to stop listening the inputs from
  8720. */
  8721. detachControl(element: Nullable<HTMLElement>): void;
  8722. /**
  8723. * Update the current camera state depending on the inputs that have been used this frame.
  8724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8725. */
  8726. checkInputs?: () => void;
  8727. }
  8728. /**
  8729. * Represents a map of input types to input instance or input index to input instance.
  8730. */
  8731. export interface CameraInputsMap<TCamera extends Camera> {
  8732. /**
  8733. * Accessor to the input by input type.
  8734. */
  8735. [name: string]: ICameraInput<TCamera>;
  8736. /**
  8737. * Accessor to the input by input index.
  8738. */
  8739. [idx: number]: ICameraInput<TCamera>;
  8740. }
  8741. /**
  8742. * This represents the input manager used within a camera.
  8743. * It helps dealing with all the different kind of input attached to a camera.
  8744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8745. */
  8746. export class CameraInputsManager<TCamera extends Camera> {
  8747. /**
  8748. * Defines the list of inputs attahed to the camera.
  8749. */
  8750. attached: CameraInputsMap<TCamera>;
  8751. /**
  8752. * Defines the dom element the camera is collecting inputs from.
  8753. * This is null if the controls have not been attached.
  8754. */
  8755. attachedElement: Nullable<HTMLElement>;
  8756. /**
  8757. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8758. */
  8759. noPreventDefault: boolean;
  8760. /**
  8761. * Defined the camera the input manager belongs to.
  8762. */
  8763. camera: TCamera;
  8764. /**
  8765. * Update the current camera state depending on the inputs that have been used this frame.
  8766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8767. */
  8768. checkInputs: () => void;
  8769. /**
  8770. * Instantiate a new Camera Input Manager.
  8771. * @param camera Defines the camera the input manager blongs to
  8772. */
  8773. constructor(camera: TCamera);
  8774. /**
  8775. * Add an input method to a camera
  8776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8777. * @param input camera input method
  8778. */
  8779. add(input: ICameraInput<TCamera>): void;
  8780. /**
  8781. * Remove a specific input method from a camera
  8782. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8783. * @param inputToRemove camera input method
  8784. */
  8785. remove(inputToRemove: ICameraInput<TCamera>): void;
  8786. /**
  8787. * Remove a specific input type from a camera
  8788. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8789. * @param inputType the type of the input to remove
  8790. */
  8791. removeByType(inputType: string): void;
  8792. private _addCheckInputs;
  8793. /**
  8794. * Attach the input controls to the currently attached dom element to listen the events from.
  8795. * @param input Defines the input to attach
  8796. */
  8797. attachInput(input: ICameraInput<TCamera>): void;
  8798. /**
  8799. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8800. * @param element Defines the dom element to collect the events from
  8801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8802. */
  8803. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8804. /**
  8805. * Detach the current manager inputs controls from a specific dom element.
  8806. * @param element Defines the dom element to collect the events from
  8807. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8808. */
  8809. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8810. /**
  8811. * Rebuild the dynamic inputCheck function from the current list of
  8812. * defined inputs in the manager.
  8813. */
  8814. rebuildInputCheck(): void;
  8815. /**
  8816. * Remove all attached input methods from a camera
  8817. */
  8818. clear(): void;
  8819. /**
  8820. * Serialize the current input manager attached to a camera.
  8821. * This ensures than once parsed,
  8822. * the input associated to the camera will be identical to the current ones
  8823. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8824. */
  8825. serialize(serializedCamera: any): void;
  8826. /**
  8827. * Parses an input manager serialized JSON to restore the previous list of inputs
  8828. * and states associated to a camera.
  8829. * @param parsedCamera Defines the JSON to parse
  8830. */
  8831. parse(parsedCamera: any): void;
  8832. }
  8833. }
  8834. declare module "babylonjs/Events/keyboardEvents" {
  8835. /**
  8836. * Gather the list of keyboard event types as constants.
  8837. */
  8838. export class KeyboardEventTypes {
  8839. /**
  8840. * The keydown event is fired when a key becomes active (pressed).
  8841. */
  8842. static readonly KEYDOWN: number;
  8843. /**
  8844. * The keyup event is fired when a key has been released.
  8845. */
  8846. static readonly KEYUP: number;
  8847. }
  8848. /**
  8849. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8850. */
  8851. export class KeyboardInfo {
  8852. /**
  8853. * Defines the type of event (KeyboardEventTypes)
  8854. */
  8855. type: number;
  8856. /**
  8857. * Defines the related dom event
  8858. */
  8859. event: KeyboardEvent;
  8860. /**
  8861. * Instantiates a new keyboard info.
  8862. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8863. * @param type Defines the type of event (KeyboardEventTypes)
  8864. * @param event Defines the related dom event
  8865. */
  8866. constructor(
  8867. /**
  8868. * Defines the type of event (KeyboardEventTypes)
  8869. */
  8870. type: number,
  8871. /**
  8872. * Defines the related dom event
  8873. */
  8874. event: KeyboardEvent);
  8875. }
  8876. /**
  8877. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8878. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8879. */
  8880. export class KeyboardInfoPre extends KeyboardInfo {
  8881. /**
  8882. * Defines the type of event (KeyboardEventTypes)
  8883. */
  8884. type: number;
  8885. /**
  8886. * Defines the related dom event
  8887. */
  8888. event: KeyboardEvent;
  8889. /**
  8890. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8891. */
  8892. skipOnPointerObservable: boolean;
  8893. /**
  8894. * Instantiates a new keyboard pre info.
  8895. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8896. * @param type Defines the type of event (KeyboardEventTypes)
  8897. * @param event Defines the related dom event
  8898. */
  8899. constructor(
  8900. /**
  8901. * Defines the type of event (KeyboardEventTypes)
  8902. */
  8903. type: number,
  8904. /**
  8905. * Defines the related dom event
  8906. */
  8907. event: KeyboardEvent);
  8908. }
  8909. }
  8910. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8911. import { Nullable } from "babylonjs/types";
  8912. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8913. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8914. /**
  8915. * Manage the keyboard inputs to control the movement of a free camera.
  8916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8917. */
  8918. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8919. /**
  8920. * Defines the camera the input is attached to.
  8921. */
  8922. camera: FreeCamera;
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8925. */
  8926. keysUp: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8929. */
  8930. keysDown: number[];
  8931. /**
  8932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8933. */
  8934. keysLeft: number[];
  8935. /**
  8936. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8937. */
  8938. keysRight: number[];
  8939. private _keys;
  8940. private _onCanvasBlurObserver;
  8941. private _onKeyboardObserver;
  8942. private _engine;
  8943. private _scene;
  8944. /**
  8945. * Attach the input controls to a specific dom element to get the input from.
  8946. * @param element Defines the element the controls should be listened from
  8947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8948. */
  8949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8950. /**
  8951. * Detach the current controls from the specified dom element.
  8952. * @param element Defines the element to stop listening the inputs from
  8953. */
  8954. detachControl(element: Nullable<HTMLElement>): void;
  8955. /**
  8956. * Update the current camera state depending on the inputs that have been used this frame.
  8957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8958. */
  8959. checkInputs(): void;
  8960. /**
  8961. * Gets the class name of the current intput.
  8962. * @returns the class name
  8963. */
  8964. getClassName(): string;
  8965. /** @hidden */
  8966. _onLostFocus(): void;
  8967. /**
  8968. * Get the friendly name associated with the input class.
  8969. * @returns the input friendly name
  8970. */
  8971. getSimpleName(): string;
  8972. }
  8973. }
  8974. declare module "babylonjs/Lights/shadowLight" {
  8975. import { Camera } from "babylonjs/Cameras/camera";
  8976. import { Scene } from "babylonjs/scene";
  8977. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8979. import { Light } from "babylonjs/Lights/light";
  8980. /**
  8981. * Interface describing all the common properties and methods a shadow light needs to implement.
  8982. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8983. * as well as binding the different shadow properties to the effects.
  8984. */
  8985. export interface IShadowLight extends Light {
  8986. /**
  8987. * The light id in the scene (used in scene.findLighById for instance)
  8988. */
  8989. id: string;
  8990. /**
  8991. * The position the shdow will be casted from.
  8992. */
  8993. position: Vector3;
  8994. /**
  8995. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8996. */
  8997. direction: Vector3;
  8998. /**
  8999. * The transformed position. Position of the light in world space taking parenting in account.
  9000. */
  9001. transformedPosition: Vector3;
  9002. /**
  9003. * The transformed direction. Direction of the light in world space taking parenting in account.
  9004. */
  9005. transformedDirection: Vector3;
  9006. /**
  9007. * The friendly name of the light in the scene.
  9008. */
  9009. name: string;
  9010. /**
  9011. * Defines the shadow projection clipping minimum z value.
  9012. */
  9013. shadowMinZ: number;
  9014. /**
  9015. * Defines the shadow projection clipping maximum z value.
  9016. */
  9017. shadowMaxZ: number;
  9018. /**
  9019. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9020. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9021. */
  9022. computeTransformedInformation(): boolean;
  9023. /**
  9024. * Gets the scene the light belongs to.
  9025. * @returns The scene
  9026. */
  9027. getScene(): Scene;
  9028. /**
  9029. * Callback defining a custom Projection Matrix Builder.
  9030. * This can be used to override the default projection matrix computation.
  9031. */
  9032. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9033. /**
  9034. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9035. * @param matrix The materix to updated with the projection information
  9036. * @param viewMatrix The transform matrix of the light
  9037. * @param renderList The list of mesh to render in the map
  9038. * @returns The current light
  9039. */
  9040. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9041. /**
  9042. * Gets the current depth scale used in ESM.
  9043. * @returns The scale
  9044. */
  9045. getDepthScale(): number;
  9046. /**
  9047. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9048. * @returns true if a cube texture needs to be use
  9049. */
  9050. needCube(): boolean;
  9051. /**
  9052. * Detects if the projection matrix requires to be recomputed this frame.
  9053. * @returns true if it requires to be recomputed otherwise, false.
  9054. */
  9055. needProjectionMatrixCompute(): boolean;
  9056. /**
  9057. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9058. */
  9059. forceProjectionMatrixCompute(): void;
  9060. /**
  9061. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9062. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9063. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9064. */
  9065. getShadowDirection(faceIndex?: number): Vector3;
  9066. /**
  9067. * Gets the minZ used for shadow according to both the scene and the light.
  9068. * @param activeCamera The camera we are returning the min for
  9069. * @returns the depth min z
  9070. */
  9071. getDepthMinZ(activeCamera: Camera): number;
  9072. /**
  9073. * Gets the maxZ used for shadow according to both the scene and the light.
  9074. * @param activeCamera The camera we are returning the max for
  9075. * @returns the depth max z
  9076. */
  9077. getDepthMaxZ(activeCamera: Camera): number;
  9078. }
  9079. /**
  9080. * Base implementation IShadowLight
  9081. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9082. */
  9083. export abstract class ShadowLight extends Light implements IShadowLight {
  9084. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9085. protected _position: Vector3;
  9086. protected _setPosition(value: Vector3): void;
  9087. /**
  9088. * Sets the position the shadow will be casted from. Also use as the light position for both
  9089. * point and spot lights.
  9090. */
  9091. /**
  9092. * Sets the position the shadow will be casted from. Also use as the light position for both
  9093. * point and spot lights.
  9094. */
  9095. position: Vector3;
  9096. protected _direction: Vector3;
  9097. protected _setDirection(value: Vector3): void;
  9098. /**
  9099. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9100. * Also use as the light direction on spot and directional lights.
  9101. */
  9102. /**
  9103. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9104. * Also use as the light direction on spot and directional lights.
  9105. */
  9106. direction: Vector3;
  9107. private _shadowMinZ;
  9108. /**
  9109. * Gets the shadow projection clipping minimum z value.
  9110. */
  9111. /**
  9112. * Sets the shadow projection clipping minimum z value.
  9113. */
  9114. shadowMinZ: number;
  9115. private _shadowMaxZ;
  9116. /**
  9117. * Sets the shadow projection clipping maximum z value.
  9118. */
  9119. /**
  9120. * Gets the shadow projection clipping maximum z value.
  9121. */
  9122. shadowMaxZ: number;
  9123. /**
  9124. * Callback defining a custom Projection Matrix Builder.
  9125. * This can be used to override the default projection matrix computation.
  9126. */
  9127. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9128. /**
  9129. * The transformed position. Position of the light in world space taking parenting in account.
  9130. */
  9131. transformedPosition: Vector3;
  9132. /**
  9133. * The transformed direction. Direction of the light in world space taking parenting in account.
  9134. */
  9135. transformedDirection: Vector3;
  9136. private _needProjectionMatrixCompute;
  9137. /**
  9138. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9139. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9140. */
  9141. computeTransformedInformation(): boolean;
  9142. /**
  9143. * Return the depth scale used for the shadow map.
  9144. * @returns the depth scale.
  9145. */
  9146. getDepthScale(): number;
  9147. /**
  9148. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9149. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9150. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9151. */
  9152. getShadowDirection(faceIndex?: number): Vector3;
  9153. /**
  9154. * Returns the ShadowLight absolute position in the World.
  9155. * @returns the position vector in world space
  9156. */
  9157. getAbsolutePosition(): Vector3;
  9158. /**
  9159. * Sets the ShadowLight direction toward the passed target.
  9160. * @param target The point to target in local space
  9161. * @returns the updated ShadowLight direction
  9162. */
  9163. setDirectionToTarget(target: Vector3): Vector3;
  9164. /**
  9165. * Returns the light rotation in euler definition.
  9166. * @returns the x y z rotation in local space.
  9167. */
  9168. getRotation(): Vector3;
  9169. /**
  9170. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9171. * @returns true if a cube texture needs to be use
  9172. */
  9173. needCube(): boolean;
  9174. /**
  9175. * Detects if the projection matrix requires to be recomputed this frame.
  9176. * @returns true if it requires to be recomputed otherwise, false.
  9177. */
  9178. needProjectionMatrixCompute(): boolean;
  9179. /**
  9180. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9181. */
  9182. forceProjectionMatrixCompute(): void;
  9183. /** @hidden */
  9184. _initCache(): void;
  9185. /** @hidden */
  9186. _isSynchronized(): boolean;
  9187. /**
  9188. * Computes the world matrix of the node
  9189. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9190. * @returns the world matrix
  9191. */
  9192. computeWorldMatrix(force?: boolean): Matrix;
  9193. /**
  9194. * Gets the minZ used for shadow according to both the scene and the light.
  9195. * @param activeCamera The camera we are returning the min for
  9196. * @returns the depth min z
  9197. */
  9198. getDepthMinZ(activeCamera: Camera): number;
  9199. /**
  9200. * Gets the maxZ used for shadow according to both the scene and the light.
  9201. * @param activeCamera The camera we are returning the max for
  9202. * @returns the depth max z
  9203. */
  9204. getDepthMaxZ(activeCamera: Camera): number;
  9205. /**
  9206. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9207. * @param matrix The materix to updated with the projection information
  9208. * @param viewMatrix The transform matrix of the light
  9209. * @param renderList The list of mesh to render in the map
  9210. * @returns The current light
  9211. */
  9212. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9213. }
  9214. }
  9215. declare module "babylonjs/Materials/materialHelper" {
  9216. import { Nullable } from "babylonjs/types";
  9217. import { Scene } from "babylonjs/scene";
  9218. import { Engine } from "babylonjs/Engines/engine";
  9219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9220. import { Light } from "babylonjs/Lights/light";
  9221. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9222. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9224. /**
  9225. * "Static Class" containing the most commonly used helper while dealing with material for
  9226. * rendering purpose.
  9227. *
  9228. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9229. *
  9230. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9231. */
  9232. export class MaterialHelper {
  9233. /**
  9234. * Bind the current view position to an effect.
  9235. * @param effect The effect to be bound
  9236. * @param scene The scene the eyes position is used from
  9237. */
  9238. static BindEyePosition(effect: Effect, scene: Scene): void;
  9239. /**
  9240. * Helps preparing the defines values about the UVs in used in the effect.
  9241. * UVs are shared as much as we can accross channels in the shaders.
  9242. * @param texture The texture we are preparing the UVs for
  9243. * @param defines The defines to update
  9244. * @param key The channel key "diffuse", "specular"... used in the shader
  9245. */
  9246. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9247. /**
  9248. * Binds a texture matrix value to its corrsponding uniform
  9249. * @param texture The texture to bind the matrix for
  9250. * @param uniformBuffer The uniform buffer receivin the data
  9251. * @param key The channel key "diffuse", "specular"... used in the shader
  9252. */
  9253. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9254. /**
  9255. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9256. * @param mesh defines the current mesh
  9257. * @param scene defines the current scene
  9258. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9259. * @param pointsCloud defines if point cloud rendering has to be turned on
  9260. * @param fogEnabled defines if fog has to be turned on
  9261. * @param alphaTest defines if alpha testing has to be turned on
  9262. * @param defines defines the current list of defines
  9263. */
  9264. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9265. /**
  9266. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9267. * @param scene defines the current scene
  9268. * @param engine defines the current engine
  9269. * @param defines specifies the list of active defines
  9270. * @param useInstances defines if instances have to be turned on
  9271. * @param useClipPlane defines if clip plane have to be turned on
  9272. */
  9273. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9274. /**
  9275. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9276. * @param mesh The mesh containing the geometry data we will draw
  9277. * @param defines The defines to update
  9278. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9279. * @param useBones Precise whether bones should be used or not (override mesh info)
  9280. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9281. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9282. * @returns false if defines are considered not dirty and have not been checked
  9283. */
  9284. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9285. /**
  9286. * Prepares the defines related to the light information passed in parameter
  9287. * @param scene The scene we are intending to draw
  9288. * @param mesh The mesh the effect is compiling for
  9289. * @param defines The defines to update
  9290. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9291. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9292. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9293. * @returns true if normals will be required for the rest of the effect
  9294. */
  9295. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9296. /**
  9297. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9298. * that won t be acctive due to defines being turned off.
  9299. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9300. * @param samplersList The samplers list
  9301. * @param defines The defines helping in the list generation
  9302. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9303. */
  9304. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9305. /**
  9306. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9307. * @param defines The defines to update while falling back
  9308. * @param fallbacks The authorized effect fallbacks
  9309. * @param maxSimultaneousLights The maximum number of lights allowed
  9310. * @param rank the current rank of the Effect
  9311. * @returns The newly affected rank
  9312. */
  9313. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9314. /**
  9315. * Prepares the list of attributes required for morph targets according to the effect defines.
  9316. * @param attribs The current list of supported attribs
  9317. * @param mesh The mesh to prepare the morph targets attributes for
  9318. * @param defines The current Defines of the effect
  9319. */
  9320. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9321. /**
  9322. * Prepares the list of attributes required for bones according to the effect defines.
  9323. * @param attribs The current list of supported attribs
  9324. * @param mesh The mesh to prepare the bones attributes for
  9325. * @param defines The current Defines of the effect
  9326. * @param fallbacks The current efffect fallback strategy
  9327. */
  9328. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9329. /**
  9330. * Prepares the list of attributes required for instances according to the effect defines.
  9331. * @param attribs The current list of supported attribs
  9332. * @param defines The current Defines of the effect
  9333. */
  9334. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9335. /**
  9336. * Binds the light shadow information to the effect for the given mesh.
  9337. * @param light The light containing the generator
  9338. * @param scene The scene the lights belongs to
  9339. * @param mesh The mesh we are binding the information to render
  9340. * @param lightIndex The light index in the effect used to render the mesh
  9341. * @param effect The effect we are binding the data to
  9342. */
  9343. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9344. /**
  9345. * Binds the light information to the effect.
  9346. * @param light The light containing the generator
  9347. * @param effect The effect we are binding the data to
  9348. * @param lightIndex The light index in the effect used to render
  9349. */
  9350. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9351. /**
  9352. * Binds the lights information from the scene to the effect for the given mesh.
  9353. * @param scene The scene the lights belongs to
  9354. * @param mesh The mesh we are binding the information to render
  9355. * @param effect The effect we are binding the data to
  9356. * @param defines The generated defines for the effect
  9357. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9358. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9359. */
  9360. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9361. private static _tempFogColor;
  9362. /**
  9363. * Binds the fog information from the scene to the effect for the given mesh.
  9364. * @param scene The scene the lights belongs to
  9365. * @param mesh The mesh we are binding the information to render
  9366. * @param effect The effect we are binding the data to
  9367. * @param linearSpace Defines if the fog effect is applied in linear space
  9368. */
  9369. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9370. /**
  9371. * Binds the bones information from the mesh to the effect.
  9372. * @param mesh The mesh we are binding the information to render
  9373. * @param effect The effect we are binding the data to
  9374. */
  9375. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9376. /**
  9377. * Binds the morph targets information from the mesh to the effect.
  9378. * @param abstractMesh The mesh we are binding the information to render
  9379. * @param effect The effect we are binding the data to
  9380. */
  9381. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9382. /**
  9383. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9384. * @param defines The generated defines used in the effect
  9385. * @param effect The effect we are binding the data to
  9386. * @param scene The scene we are willing to render with logarithmic scale for
  9387. */
  9388. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9389. /**
  9390. * Binds the clip plane information from the scene to the effect.
  9391. * @param scene The scene the clip plane information are extracted from
  9392. * @param effect The effect we are binding the data to
  9393. */
  9394. static BindClipPlane(effect: Effect, scene: Scene): void;
  9395. }
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9398. /** @hidden */
  9399. export var kernelBlurVaryingDeclaration: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9405. /** @hidden */
  9406. export var kernelBlurFragment: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9412. /** @hidden */
  9413. export var kernelBlurFragment2: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9419. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9420. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9421. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9422. /** @hidden */
  9423. export var kernelBlurPixelShader: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9429. /** @hidden */
  9430. export var kernelBlurVertex: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9436. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9437. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9438. /** @hidden */
  9439. export var kernelBlurVertexShader: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9445. import { Vector2 } from "babylonjs/Maths/math";
  9446. import { Nullable } from "babylonjs/types";
  9447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9448. import { Camera } from "babylonjs/Cameras/camera";
  9449. import { Effect } from "babylonjs/Materials/effect";
  9450. import { Engine } from "babylonjs/Engines/engine";
  9451. import "babylonjs/Shaders/kernelBlur.fragment";
  9452. import "babylonjs/Shaders/kernelBlur.vertex";
  9453. /**
  9454. * The Blur Post Process which blurs an image based on a kernel and direction.
  9455. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9456. */
  9457. export class BlurPostProcess extends PostProcess {
  9458. /** The direction in which to blur the image. */
  9459. direction: Vector2;
  9460. private blockCompilation;
  9461. protected _kernel: number;
  9462. protected _idealKernel: number;
  9463. protected _packedFloat: boolean;
  9464. private _staticDefines;
  9465. /**
  9466. * Sets the length in pixels of the blur sample region
  9467. */
  9468. /**
  9469. * Gets the length in pixels of the blur sample region
  9470. */
  9471. kernel: number;
  9472. /**
  9473. * Sets wether or not the blur needs to unpack/repack floats
  9474. */
  9475. /**
  9476. * Gets wether or not the blur is unpacking/repacking floats
  9477. */
  9478. packedFloat: boolean;
  9479. /**
  9480. * Creates a new instance BlurPostProcess
  9481. * @param name The name of the effect.
  9482. * @param direction The direction in which to blur the image.
  9483. * @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.
  9484. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9485. * @param camera The camera to apply the render pass to.
  9486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9487. * @param engine The engine which the post process will be applied. (default: current engine)
  9488. * @param reusable If the post process can be reused on the same frame. (default: false)
  9489. * @param textureType Type of textures used when performing the post process. (default: 0)
  9490. * @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)
  9491. */
  9492. constructor(name: string,
  9493. /** The direction in which to blur the image. */
  9494. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9495. /**
  9496. * Updates the effect with the current post process compile time values and recompiles the shader.
  9497. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9498. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9499. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9500. * @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
  9501. * @param onCompiled Called when the shader has been compiled.
  9502. * @param onError Called if there is an error when compiling a shader.
  9503. */
  9504. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9505. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9506. /**
  9507. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9508. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9509. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9510. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9511. * The gaps between physical kernels are compensated for in the weighting of the samples
  9512. * @param idealKernel Ideal blur kernel.
  9513. * @return Nearest best kernel.
  9514. */
  9515. protected _nearestBestKernel(idealKernel: number): number;
  9516. /**
  9517. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9518. * @param x The point on the Gaussian distribution to sample.
  9519. * @return the value of the Gaussian function at x.
  9520. */
  9521. protected _gaussianWeight(x: number): number;
  9522. /**
  9523. * Generates a string that can be used as a floating point number in GLSL.
  9524. * @param x Value to print.
  9525. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9526. * @return GLSL float string.
  9527. */
  9528. protected _glslFloat(x: number, decimalFigures?: number): string;
  9529. }
  9530. }
  9531. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9532. /** @hidden */
  9533. export var shadowMapPixelShader: {
  9534. name: string;
  9535. shader: string;
  9536. };
  9537. }
  9538. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9539. /** @hidden */
  9540. export var bonesDeclaration: {
  9541. name: string;
  9542. shader: string;
  9543. };
  9544. }
  9545. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9546. /** @hidden */
  9547. export var morphTargetsVertexGlobalDeclaration: {
  9548. name: string;
  9549. shader: string;
  9550. };
  9551. }
  9552. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9553. /** @hidden */
  9554. export var morphTargetsVertexDeclaration: {
  9555. name: string;
  9556. shader: string;
  9557. };
  9558. }
  9559. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9560. /** @hidden */
  9561. export var instancesDeclaration: {
  9562. name: string;
  9563. shader: string;
  9564. };
  9565. }
  9566. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9567. /** @hidden */
  9568. export var helperFunctions: {
  9569. name: string;
  9570. shader: string;
  9571. };
  9572. }
  9573. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9574. /** @hidden */
  9575. export var morphTargetsVertex: {
  9576. name: string;
  9577. shader: string;
  9578. };
  9579. }
  9580. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9581. /** @hidden */
  9582. export var instancesVertex: {
  9583. name: string;
  9584. shader: string;
  9585. };
  9586. }
  9587. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9588. /** @hidden */
  9589. export var bonesVertex: {
  9590. name: string;
  9591. shader: string;
  9592. };
  9593. }
  9594. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9595. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9596. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9597. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9598. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9599. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9600. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9601. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9602. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9603. /** @hidden */
  9604. export var shadowMapVertexShader: {
  9605. name: string;
  9606. shader: string;
  9607. };
  9608. }
  9609. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9610. /** @hidden */
  9611. export var depthBoxBlurPixelShader: {
  9612. name: string;
  9613. shader: string;
  9614. };
  9615. }
  9616. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9617. import { Nullable } from "babylonjs/types";
  9618. import { Scene } from "babylonjs/scene";
  9619. import { Matrix } from "babylonjs/Maths/math";
  9620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9622. import { Mesh } from "babylonjs/Meshes/mesh";
  9623. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9624. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9625. import { Effect } from "babylonjs/Materials/effect";
  9626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9627. import "babylonjs/Shaders/shadowMap.fragment";
  9628. import "babylonjs/Shaders/shadowMap.vertex";
  9629. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9630. import { Observable } from "babylonjs/Misc/observable";
  9631. /**
  9632. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9633. */
  9634. export interface ICustomShaderOptions {
  9635. /**
  9636. * Gets or sets the custom shader name to use
  9637. */
  9638. shaderName: string;
  9639. /**
  9640. * The list of attribute names used in the shader
  9641. */
  9642. attributes?: string[];
  9643. /**
  9644. * The list of unifrom names used in the shader
  9645. */
  9646. uniforms?: string[];
  9647. /**
  9648. * The list of sampler names used in the shader
  9649. */
  9650. samplers?: string[];
  9651. /**
  9652. * The list of defines used in the shader
  9653. */
  9654. defines?: string[];
  9655. }
  9656. /**
  9657. * Interface to implement to create a shadow generator compatible with BJS.
  9658. */
  9659. export interface IShadowGenerator {
  9660. /**
  9661. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9662. * @returns The render target texture if present otherwise, null
  9663. */
  9664. getShadowMap(): Nullable<RenderTargetTexture>;
  9665. /**
  9666. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9667. * @returns The render target texture if the shadow map is present otherwise, null
  9668. */
  9669. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9670. /**
  9671. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9672. * @param subMesh The submesh we want to render in the shadow map
  9673. * @param useInstances Defines wether will draw in the map using instances
  9674. * @returns true if ready otherwise, false
  9675. */
  9676. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9677. /**
  9678. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9679. * @param defines Defines of the material we want to update
  9680. * @param lightIndex Index of the light in the enabled light list of the material
  9681. */
  9682. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9683. /**
  9684. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9685. * defined in the generator but impacting the effect).
  9686. * It implies the unifroms available on the materials are the standard BJS ones.
  9687. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9688. * @param effect The effect we are binfing the information for
  9689. */
  9690. bindShadowLight(lightIndex: string, effect: Effect): void;
  9691. /**
  9692. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9693. * (eq to shadow prjection matrix * light transform matrix)
  9694. * @returns The transform matrix used to create the shadow map
  9695. */
  9696. getTransformMatrix(): Matrix;
  9697. /**
  9698. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9699. * Cube and 2D textures for instance.
  9700. */
  9701. recreateShadowMap(): void;
  9702. /**
  9703. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9704. * @param onCompiled Callback triggered at the and of the effects compilation
  9705. * @param options Sets of optional options forcing the compilation with different modes
  9706. */
  9707. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9708. useInstances: boolean;
  9709. }>): void;
  9710. /**
  9711. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9712. * @param options Sets of optional options forcing the compilation with different modes
  9713. * @returns A promise that resolves when the compilation completes
  9714. */
  9715. forceCompilationAsync(options?: Partial<{
  9716. useInstances: boolean;
  9717. }>): Promise<void>;
  9718. /**
  9719. * Serializes the shadow generator setup to a json object.
  9720. * @returns The serialized JSON object
  9721. */
  9722. serialize(): any;
  9723. /**
  9724. * Disposes the Shadow map and related Textures and effects.
  9725. */
  9726. dispose(): void;
  9727. }
  9728. /**
  9729. * Default implementation IShadowGenerator.
  9730. * This is the main object responsible of generating shadows in the framework.
  9731. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9732. */
  9733. export class ShadowGenerator implements IShadowGenerator {
  9734. /**
  9735. * Shadow generator mode None: no filtering applied.
  9736. */
  9737. static readonly FILTER_NONE: number;
  9738. /**
  9739. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9740. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9741. */
  9742. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9743. /**
  9744. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9745. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9746. */
  9747. static readonly FILTER_POISSONSAMPLING: number;
  9748. /**
  9749. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9750. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9751. */
  9752. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9753. /**
  9754. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9755. * edge artifacts on steep falloff.
  9756. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9757. */
  9758. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9759. /**
  9760. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9761. * edge artifacts on steep falloff.
  9762. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9763. */
  9764. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9765. /**
  9766. * Shadow generator mode PCF: Percentage Closer Filtering
  9767. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9768. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9769. */
  9770. static readonly FILTER_PCF: number;
  9771. /**
  9772. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9773. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9774. * Contact Hardening
  9775. */
  9776. static readonly FILTER_PCSS: number;
  9777. /**
  9778. * Reserved for PCF and PCSS
  9779. * Highest Quality.
  9780. *
  9781. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9782. *
  9783. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9784. */
  9785. static readonly QUALITY_HIGH: number;
  9786. /**
  9787. * Reserved for PCF and PCSS
  9788. * Good tradeoff for quality/perf cross devices
  9789. *
  9790. * Execute PCF on a 3*3 kernel.
  9791. *
  9792. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9793. */
  9794. static readonly QUALITY_MEDIUM: number;
  9795. /**
  9796. * Reserved for PCF and PCSS
  9797. * The lowest quality but the fastest.
  9798. *
  9799. * Execute PCF on a 1*1 kernel.
  9800. *
  9801. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9802. */
  9803. static readonly QUALITY_LOW: number;
  9804. /** Gets or sets the custom shader name to use */
  9805. customShaderOptions: ICustomShaderOptions;
  9806. /**
  9807. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9808. */
  9809. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9810. /**
  9811. * Observable triggered before a mesh is rendered in the shadow map.
  9812. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9813. */
  9814. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9815. private _bias;
  9816. /**
  9817. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9818. */
  9819. /**
  9820. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9821. */
  9822. bias: number;
  9823. private _normalBias;
  9824. /**
  9825. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9826. */
  9827. /**
  9828. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9829. */
  9830. normalBias: number;
  9831. private _blurBoxOffset;
  9832. /**
  9833. * Gets the blur box offset: offset applied during the blur pass.
  9834. * Only useful if useKernelBlur = false
  9835. */
  9836. /**
  9837. * Sets the blur box offset: offset applied during the blur pass.
  9838. * Only useful if useKernelBlur = false
  9839. */
  9840. blurBoxOffset: number;
  9841. private _blurScale;
  9842. /**
  9843. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9844. * 2 means half of the size.
  9845. */
  9846. /**
  9847. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9848. * 2 means half of the size.
  9849. */
  9850. blurScale: number;
  9851. private _blurKernel;
  9852. /**
  9853. * Gets the blur kernel: kernel size of the blur pass.
  9854. * Only useful if useKernelBlur = true
  9855. */
  9856. /**
  9857. * Sets the blur kernel: kernel size of the blur pass.
  9858. * Only useful if useKernelBlur = true
  9859. */
  9860. blurKernel: number;
  9861. private _useKernelBlur;
  9862. /**
  9863. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9864. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9865. */
  9866. /**
  9867. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9868. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9869. */
  9870. useKernelBlur: boolean;
  9871. private _depthScale;
  9872. /**
  9873. * Gets the depth scale used in ESM mode.
  9874. */
  9875. /**
  9876. * Sets the depth scale used in ESM mode.
  9877. * This can override the scale stored on the light.
  9878. */
  9879. depthScale: number;
  9880. private _filter;
  9881. /**
  9882. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9883. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9884. */
  9885. /**
  9886. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9887. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9888. */
  9889. filter: number;
  9890. /**
  9891. * Gets if the current filter is set to Poisson Sampling.
  9892. */
  9893. /**
  9894. * Sets the current filter to Poisson Sampling.
  9895. */
  9896. usePoissonSampling: boolean;
  9897. /**
  9898. * Gets if the current filter is set to ESM.
  9899. */
  9900. /**
  9901. * Sets the current filter is to ESM.
  9902. */
  9903. useExponentialShadowMap: boolean;
  9904. /**
  9905. * Gets if the current filter is set to filtered ESM.
  9906. */
  9907. /**
  9908. * Gets if the current filter is set to filtered ESM.
  9909. */
  9910. useBlurExponentialShadowMap: boolean;
  9911. /**
  9912. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9913. * exponential to prevent steep falloff artifacts).
  9914. */
  9915. /**
  9916. * Sets the current filter to "close ESM" (using the inverse of the
  9917. * exponential to prevent steep falloff artifacts).
  9918. */
  9919. useCloseExponentialShadowMap: boolean;
  9920. /**
  9921. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9922. * exponential to prevent steep falloff artifacts).
  9923. */
  9924. /**
  9925. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9926. * exponential to prevent steep falloff artifacts).
  9927. */
  9928. useBlurCloseExponentialShadowMap: boolean;
  9929. /**
  9930. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9931. */
  9932. /**
  9933. * Sets the current filter to "PCF" (percentage closer filtering).
  9934. */
  9935. usePercentageCloserFiltering: boolean;
  9936. private _filteringQuality;
  9937. /**
  9938. * Gets the PCF or PCSS Quality.
  9939. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9940. */
  9941. /**
  9942. * Sets the PCF or PCSS Quality.
  9943. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9944. */
  9945. filteringQuality: number;
  9946. /**
  9947. * Gets if the current filter is set to "PCSS" (contact hardening).
  9948. */
  9949. /**
  9950. * Sets the current filter to "PCSS" (contact hardening).
  9951. */
  9952. useContactHardeningShadow: boolean;
  9953. private _contactHardeningLightSizeUVRatio;
  9954. /**
  9955. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9956. * Using a ratio helps keeping shape stability independently of the map size.
  9957. *
  9958. * It does not account for the light projection as it was having too much
  9959. * instability during the light setup or during light position changes.
  9960. *
  9961. * Only valid if useContactHardeningShadow is true.
  9962. */
  9963. /**
  9964. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9965. * Using a ratio helps keeping shape stability independently of the map size.
  9966. *
  9967. * It does not account for the light projection as it was having too much
  9968. * instability during the light setup or during light position changes.
  9969. *
  9970. * Only valid if useContactHardeningShadow is true.
  9971. */
  9972. contactHardeningLightSizeUVRatio: number;
  9973. private _darkness;
  9974. /**
  9975. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9976. * 0 means strongest and 1 would means no shadow.
  9977. * @returns the darkness.
  9978. */
  9979. getDarkness(): number;
  9980. /**
  9981. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9982. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9983. * @returns the shadow generator allowing fluent coding.
  9984. */
  9985. setDarkness(darkness: number): ShadowGenerator;
  9986. private _transparencyShadow;
  9987. /**
  9988. * Sets the ability to have transparent shadow (boolean).
  9989. * @param transparent True if transparent else False
  9990. * @returns the shadow generator allowing fluent coding
  9991. */
  9992. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9993. private _shadowMap;
  9994. private _shadowMap2;
  9995. /**
  9996. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9997. * @returns The render target texture if present otherwise, null
  9998. */
  9999. getShadowMap(): Nullable<RenderTargetTexture>;
  10000. /**
  10001. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10002. * @returns The render target texture if the shadow map is present otherwise, null
  10003. */
  10004. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10005. /**
  10006. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10007. * @param mesh Mesh to add
  10008. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10009. * @returns the Shadow Generator itself
  10010. */
  10011. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10012. /**
  10013. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10014. * @param mesh Mesh to remove
  10015. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10016. * @returns the Shadow Generator itself
  10017. */
  10018. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10019. /**
  10020. * Controls the extent to which the shadows fade out at the edge of the frustum
  10021. * Used only by directionals and spots
  10022. */
  10023. frustumEdgeFalloff: number;
  10024. private _light;
  10025. /**
  10026. * Returns the associated light object.
  10027. * @returns the light generating the shadow
  10028. */
  10029. getLight(): IShadowLight;
  10030. /**
  10031. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10032. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10033. * It might on the other hand introduce peter panning.
  10034. */
  10035. forceBackFacesOnly: boolean;
  10036. private _scene;
  10037. private _lightDirection;
  10038. private _effect;
  10039. private _viewMatrix;
  10040. private _projectionMatrix;
  10041. private _transformMatrix;
  10042. private _cachedPosition;
  10043. private _cachedDirection;
  10044. private _cachedDefines;
  10045. private _currentRenderID;
  10046. private _boxBlurPostprocess;
  10047. private _kernelBlurXPostprocess;
  10048. private _kernelBlurYPostprocess;
  10049. private _blurPostProcesses;
  10050. private _mapSize;
  10051. private _currentFaceIndex;
  10052. private _currentFaceIndexCache;
  10053. private _textureType;
  10054. private _defaultTextureMatrix;
  10055. /** @hidden */
  10056. static _SceneComponentInitialization: (scene: Scene) => void;
  10057. /**
  10058. * Creates a ShadowGenerator object.
  10059. * A ShadowGenerator is the required tool to use the shadows.
  10060. * Each light casting shadows needs to use its own ShadowGenerator.
  10061. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10062. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10063. * @param light The light object generating the shadows.
  10064. * @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.
  10065. */
  10066. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10067. private _initializeGenerator;
  10068. private _initializeShadowMap;
  10069. private _initializeBlurRTTAndPostProcesses;
  10070. private _renderForShadowMap;
  10071. private _renderSubMeshForShadowMap;
  10072. private _applyFilterValues;
  10073. /**
  10074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10075. * @param onCompiled Callback triggered at the and of the effects compilation
  10076. * @param options Sets of optional options forcing the compilation with different modes
  10077. */
  10078. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10079. useInstances: boolean;
  10080. }>): void;
  10081. /**
  10082. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10083. * @param options Sets of optional options forcing the compilation with different modes
  10084. * @returns A promise that resolves when the compilation completes
  10085. */
  10086. forceCompilationAsync(options?: Partial<{
  10087. useInstances: boolean;
  10088. }>): Promise<void>;
  10089. /**
  10090. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10091. * @param subMesh The submesh we want to render in the shadow map
  10092. * @param useInstances Defines wether will draw in the map using instances
  10093. * @returns true if ready otherwise, false
  10094. */
  10095. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10096. /**
  10097. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10098. * @param defines Defines of the material we want to update
  10099. * @param lightIndex Index of the light in the enabled light list of the material
  10100. */
  10101. prepareDefines(defines: any, lightIndex: number): void;
  10102. /**
  10103. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10104. * defined in the generator but impacting the effect).
  10105. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10106. * @param effect The effect we are binfing the information for
  10107. */
  10108. bindShadowLight(lightIndex: string, effect: Effect): void;
  10109. /**
  10110. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10111. * (eq to shadow prjection matrix * light transform matrix)
  10112. * @returns The transform matrix used to create the shadow map
  10113. */
  10114. getTransformMatrix(): Matrix;
  10115. /**
  10116. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10117. * Cube and 2D textures for instance.
  10118. */
  10119. recreateShadowMap(): void;
  10120. private _disposeBlurPostProcesses;
  10121. private _disposeRTTandPostProcesses;
  10122. /**
  10123. * Disposes the ShadowGenerator.
  10124. * Returns nothing.
  10125. */
  10126. dispose(): void;
  10127. /**
  10128. * Serializes the shadow generator setup to a json object.
  10129. * @returns The serialized JSON object
  10130. */
  10131. serialize(): any;
  10132. /**
  10133. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10134. * @param parsedShadowGenerator The JSON object to parse
  10135. * @param scene The scene to create the shadow map for
  10136. * @returns The parsed shadow generator
  10137. */
  10138. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10139. }
  10140. }
  10141. declare module "babylonjs/Lights/light" {
  10142. import { Nullable } from "babylonjs/types";
  10143. import { Scene } from "babylonjs/scene";
  10144. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10145. import { Node } from "babylonjs/node";
  10146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10147. import { Effect } from "babylonjs/Materials/effect";
  10148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10149. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10150. /**
  10151. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10152. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10153. * 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.
  10154. */
  10155. export abstract class Light extends Node {
  10156. /**
  10157. * Falloff Default: light is falling off following the material specification:
  10158. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10159. */
  10160. static readonly FALLOFF_DEFAULT: number;
  10161. /**
  10162. * Falloff Physical: light is falling off following the inverse squared distance law.
  10163. */
  10164. static readonly FALLOFF_PHYSICAL: number;
  10165. /**
  10166. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10167. * to enhance interoperability with other engines.
  10168. */
  10169. static readonly FALLOFF_GLTF: number;
  10170. /**
  10171. * Falloff Standard: light is falling off like in the standard material
  10172. * to enhance interoperability with other materials.
  10173. */
  10174. static readonly FALLOFF_STANDARD: number;
  10175. /**
  10176. * If every light affecting the material is in this lightmapMode,
  10177. * material.lightmapTexture adds or multiplies
  10178. * (depends on material.useLightmapAsShadowmap)
  10179. * after every other light calculations.
  10180. */
  10181. static readonly LIGHTMAP_DEFAULT: number;
  10182. /**
  10183. * material.lightmapTexture as only diffuse lighting from this light
  10184. * adds only specular lighting from this light
  10185. * adds dynamic shadows
  10186. */
  10187. static readonly LIGHTMAP_SPECULAR: number;
  10188. /**
  10189. * material.lightmapTexture as only lighting
  10190. * no light calculation from this light
  10191. * only adds dynamic shadows from this light
  10192. */
  10193. static readonly LIGHTMAP_SHADOWSONLY: number;
  10194. /**
  10195. * Each light type uses the default quantity according to its type:
  10196. * point/spot lights use luminous intensity
  10197. * directional lights use illuminance
  10198. */
  10199. static readonly INTENSITYMODE_AUTOMATIC: number;
  10200. /**
  10201. * lumen (lm)
  10202. */
  10203. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10204. /**
  10205. * candela (lm/sr)
  10206. */
  10207. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10208. /**
  10209. * lux (lm/m^2)
  10210. */
  10211. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10212. /**
  10213. * nit (cd/m^2)
  10214. */
  10215. static readonly INTENSITYMODE_LUMINANCE: number;
  10216. /**
  10217. * Light type const id of the point light.
  10218. */
  10219. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10220. /**
  10221. * Light type const id of the directional light.
  10222. */
  10223. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10224. /**
  10225. * Light type const id of the spot light.
  10226. */
  10227. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10228. /**
  10229. * Light type const id of the hemispheric light.
  10230. */
  10231. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10232. /**
  10233. * Diffuse gives the basic color to an object.
  10234. */
  10235. diffuse: Color3;
  10236. /**
  10237. * Specular produces a highlight color on an object.
  10238. * Note: This is note affecting PBR materials.
  10239. */
  10240. specular: Color3;
  10241. /**
  10242. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10243. * falling off base on range or angle.
  10244. * This can be set to any values in Light.FALLOFF_x.
  10245. *
  10246. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10247. * other types of materials.
  10248. */
  10249. falloffType: number;
  10250. /**
  10251. * Strength of the light.
  10252. * Note: By default it is define in the framework own unit.
  10253. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10254. */
  10255. intensity: number;
  10256. private _range;
  10257. protected _inverseSquaredRange: number;
  10258. /**
  10259. * Defines how far from the source the light is impacting in scene units.
  10260. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10261. */
  10262. /**
  10263. * Defines how far from the source the light is impacting in scene units.
  10264. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10265. */
  10266. range: number;
  10267. /**
  10268. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10269. * of light.
  10270. */
  10271. private _photometricScale;
  10272. private _intensityMode;
  10273. /**
  10274. * Gets the photometric scale used to interpret the intensity.
  10275. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10276. */
  10277. /**
  10278. * Sets the photometric scale used to interpret the intensity.
  10279. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10280. */
  10281. intensityMode: number;
  10282. private _radius;
  10283. /**
  10284. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10285. */
  10286. /**
  10287. * sets the light radius used by PBR Materials to simulate soft area lights.
  10288. */
  10289. radius: number;
  10290. private _renderPriority;
  10291. /**
  10292. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10293. * exceeding the number allowed of the materials.
  10294. */
  10295. renderPriority: number;
  10296. private _shadowEnabled;
  10297. /**
  10298. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10299. * the current shadow generator.
  10300. */
  10301. /**
  10302. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10303. * the current shadow generator.
  10304. */
  10305. shadowEnabled: boolean;
  10306. private _includedOnlyMeshes;
  10307. /**
  10308. * Gets the only meshes impacted by this light.
  10309. */
  10310. /**
  10311. * Sets the only meshes impacted by this light.
  10312. */
  10313. includedOnlyMeshes: AbstractMesh[];
  10314. private _excludedMeshes;
  10315. /**
  10316. * Gets the meshes not impacted by this light.
  10317. */
  10318. /**
  10319. * Sets the meshes not impacted by this light.
  10320. */
  10321. excludedMeshes: AbstractMesh[];
  10322. private _excludeWithLayerMask;
  10323. /**
  10324. * Gets the layer id use to find what meshes are not impacted by the light.
  10325. * Inactive if 0
  10326. */
  10327. /**
  10328. * Sets the layer id use to find what meshes are not impacted by the light.
  10329. * Inactive if 0
  10330. */
  10331. excludeWithLayerMask: number;
  10332. private _includeOnlyWithLayerMask;
  10333. /**
  10334. * Gets the layer id use to find what meshes are impacted by the light.
  10335. * Inactive if 0
  10336. */
  10337. /**
  10338. * Sets the layer id use to find what meshes are impacted by the light.
  10339. * Inactive if 0
  10340. */
  10341. includeOnlyWithLayerMask: number;
  10342. private _lightmapMode;
  10343. /**
  10344. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10345. */
  10346. /**
  10347. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10348. */
  10349. lightmapMode: number;
  10350. /**
  10351. * Shadow generator associted to the light.
  10352. * @hidden Internal use only.
  10353. */
  10354. _shadowGenerator: Nullable<IShadowGenerator>;
  10355. /**
  10356. * @hidden Internal use only.
  10357. */
  10358. _excludedMeshesIds: string[];
  10359. /**
  10360. * @hidden Internal use only.
  10361. */
  10362. _includedOnlyMeshesIds: string[];
  10363. /**
  10364. * The current light unifom buffer.
  10365. * @hidden Internal use only.
  10366. */
  10367. _uniformBuffer: UniformBuffer;
  10368. /**
  10369. * Creates a Light object in the scene.
  10370. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10371. * @param name The firendly name of the light
  10372. * @param scene The scene the light belongs too
  10373. */
  10374. constructor(name: string, scene: Scene);
  10375. protected abstract _buildUniformLayout(): void;
  10376. /**
  10377. * Sets the passed Effect "effect" with the Light information.
  10378. * @param effect The effect to update
  10379. * @param lightIndex The index of the light in the effect to update
  10380. * @returns The light
  10381. */
  10382. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10383. /**
  10384. * Returns the string "Light".
  10385. * @returns the class name
  10386. */
  10387. getClassName(): string;
  10388. /** @hidden */
  10389. readonly _isLight: boolean;
  10390. /**
  10391. * Converts the light information to a readable string for debug purpose.
  10392. * @param fullDetails Supports for multiple levels of logging within scene loading
  10393. * @returns the human readable light info
  10394. */
  10395. toString(fullDetails?: boolean): string;
  10396. /** @hidden */
  10397. protected _syncParentEnabledState(): void;
  10398. /**
  10399. * Set the enabled state of this node.
  10400. * @param value - the new enabled state
  10401. */
  10402. setEnabled(value: boolean): void;
  10403. /**
  10404. * Returns the Light associated shadow generator if any.
  10405. * @return the associated shadow generator.
  10406. */
  10407. getShadowGenerator(): Nullable<IShadowGenerator>;
  10408. /**
  10409. * Returns a Vector3, the absolute light position in the World.
  10410. * @returns the world space position of the light
  10411. */
  10412. getAbsolutePosition(): Vector3;
  10413. /**
  10414. * Specifies if the light will affect the passed mesh.
  10415. * @param mesh The mesh to test against the light
  10416. * @return true the mesh is affected otherwise, false.
  10417. */
  10418. canAffectMesh(mesh: AbstractMesh): boolean;
  10419. /**
  10420. * Sort function to order lights for rendering.
  10421. * @param a First Light object to compare to second.
  10422. * @param b Second Light object to compare first.
  10423. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10424. */
  10425. static CompareLightsPriority(a: Light, b: Light): number;
  10426. /**
  10427. * Releases resources associated with this node.
  10428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10430. */
  10431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10432. /**
  10433. * Returns the light type ID (integer).
  10434. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10435. */
  10436. getTypeID(): number;
  10437. /**
  10438. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10439. * @returns the scaled intensity in intensity mode unit
  10440. */
  10441. getScaledIntensity(): number;
  10442. /**
  10443. * Returns a new Light object, named "name", from the current one.
  10444. * @param name The name of the cloned light
  10445. * @returns the new created light
  10446. */
  10447. clone(name: string): Nullable<Light>;
  10448. /**
  10449. * Serializes the current light into a Serialization object.
  10450. * @returns the serialized object.
  10451. */
  10452. serialize(): any;
  10453. /**
  10454. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10455. * This new light is named "name" and added to the passed scene.
  10456. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10457. * @param name The friendly name of the light
  10458. * @param scene The scene the new light will belong to
  10459. * @returns the constructor function
  10460. */
  10461. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10462. /**
  10463. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10464. * @param parsedLight The JSON representation of the light
  10465. * @param scene The scene to create the parsed light in
  10466. * @returns the created light after parsing
  10467. */
  10468. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10469. private _hookArrayForExcluded;
  10470. private _hookArrayForIncludedOnly;
  10471. private _resyncMeshes;
  10472. /**
  10473. * Forces the meshes to update their light related information in their rendering used effects
  10474. * @hidden Internal Use Only
  10475. */
  10476. _markMeshesAsLightDirty(): void;
  10477. /**
  10478. * Recomputes the cached photometric scale if needed.
  10479. */
  10480. private _computePhotometricScale;
  10481. /**
  10482. * Returns the Photometric Scale according to the light type and intensity mode.
  10483. */
  10484. private _getPhotometricScale;
  10485. /**
  10486. * Reorder the light in the scene according to their defined priority.
  10487. * @hidden Internal Use Only
  10488. */
  10489. _reorderLightsInScene(): void;
  10490. /**
  10491. * Prepares the list of defines specific to the light type.
  10492. * @param defines the list of defines
  10493. * @param lightIndex defines the index of the light for the effect
  10494. */
  10495. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10496. }
  10497. }
  10498. declare module "babylonjs/Actions/action" {
  10499. import { Observable } from "babylonjs/Misc/observable";
  10500. import { Condition } from "babylonjs/Actions/condition";
  10501. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10502. import { ActionManager } from "babylonjs/Actions/actionManager";
  10503. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10504. /**
  10505. * Interface used to define Action
  10506. */
  10507. export interface IAction {
  10508. /**
  10509. * Trigger for the action
  10510. */
  10511. trigger: number;
  10512. /** Options of the trigger */
  10513. triggerOptions: any;
  10514. /**
  10515. * Gets the trigger parameters
  10516. * @returns the trigger parameters
  10517. */
  10518. getTriggerParameter(): any;
  10519. /**
  10520. * Internal only - executes current action event
  10521. * @hidden
  10522. */
  10523. _executeCurrent(evt?: ActionEvent): void;
  10524. /**
  10525. * Serialize placeholder for child classes
  10526. * @param parent of child
  10527. * @returns the serialized object
  10528. */
  10529. serialize(parent: any): any;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. _prepare(): void;
  10535. /**
  10536. * Internal only - manager for action
  10537. * @hidden
  10538. */
  10539. _actionManager: AbstractActionManager;
  10540. }
  10541. /**
  10542. * The action to be carried out following a trigger
  10543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10544. */
  10545. export class Action implements IAction {
  10546. /** the trigger, with or without parameters, for the action */
  10547. triggerOptions: any;
  10548. /**
  10549. * Trigger for the action
  10550. */
  10551. trigger: number;
  10552. /**
  10553. * Internal only - manager for action
  10554. * @hidden
  10555. */
  10556. _actionManager: ActionManager;
  10557. private _nextActiveAction;
  10558. private _child;
  10559. private _condition?;
  10560. private _triggerParameter;
  10561. /**
  10562. * An event triggered prior to action being executed.
  10563. */
  10564. onBeforeExecuteObservable: Observable<Action>;
  10565. /**
  10566. * Creates a new Action
  10567. * @param triggerOptions the trigger, with or without parameters, for the action
  10568. * @param condition an optional determinant of action
  10569. */
  10570. constructor(
  10571. /** the trigger, with or without parameters, for the action */
  10572. triggerOptions: any, condition?: Condition);
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. _prepare(): void;
  10578. /**
  10579. * Gets the trigger parameters
  10580. * @returns the trigger parameters
  10581. */
  10582. getTriggerParameter(): any;
  10583. /**
  10584. * Internal only - executes current action event
  10585. * @hidden
  10586. */
  10587. _executeCurrent(evt?: ActionEvent): void;
  10588. /**
  10589. * Execute placeholder for child classes
  10590. * @param evt optional action event
  10591. */
  10592. execute(evt?: ActionEvent): void;
  10593. /**
  10594. * Skips to next active action
  10595. */
  10596. skipToNextActiveAction(): void;
  10597. /**
  10598. * Adds action to chain of actions, may be a DoNothingAction
  10599. * @param action defines the next action to execute
  10600. * @returns The action passed in
  10601. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10602. */
  10603. then(action: Action): Action;
  10604. /**
  10605. * Internal only
  10606. * @hidden
  10607. */
  10608. _getProperty(propertyPath: string): string;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. _getEffectiveTarget(target: any, propertyPath: string): any;
  10614. /**
  10615. * Serialize placeholder for child classes
  10616. * @param parent of child
  10617. * @returns the serialized object
  10618. */
  10619. serialize(parent: any): any;
  10620. /**
  10621. * Internal only called by serialize
  10622. * @hidden
  10623. */
  10624. protected _serialize(serializedAction: any, parent?: any): any;
  10625. /**
  10626. * Internal only
  10627. * @hidden
  10628. */
  10629. static _SerializeValueAsString: (value: any) => string;
  10630. /**
  10631. * Internal only
  10632. * @hidden
  10633. */
  10634. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10635. name: string;
  10636. targetType: string;
  10637. value: string;
  10638. };
  10639. }
  10640. }
  10641. declare module "babylonjs/Actions/condition" {
  10642. import { ActionManager } from "babylonjs/Actions/actionManager";
  10643. /**
  10644. * A Condition applied to an Action
  10645. */
  10646. export class Condition {
  10647. /**
  10648. * Internal only - manager for action
  10649. * @hidden
  10650. */
  10651. _actionManager: ActionManager;
  10652. /**
  10653. * Internal only
  10654. * @hidden
  10655. */
  10656. _evaluationId: number;
  10657. /**
  10658. * Internal only
  10659. * @hidden
  10660. */
  10661. _currentResult: boolean;
  10662. /**
  10663. * Creates a new Condition
  10664. * @param actionManager the manager of the action the condition is applied to
  10665. */
  10666. constructor(actionManager: ActionManager);
  10667. /**
  10668. * Check if the current condition is valid
  10669. * @returns a boolean
  10670. */
  10671. isValid(): boolean;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. _getProperty(propertyPath: string): string;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. _getEffectiveTarget(target: any, propertyPath: string): any;
  10682. /**
  10683. * Serialize placeholder for child classes
  10684. * @returns the serialized object
  10685. */
  10686. serialize(): any;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. protected _serialize(serializedCondition: any): any;
  10692. }
  10693. /**
  10694. * Defines specific conditional operators as extensions of Condition
  10695. */
  10696. export class ValueCondition extends Condition {
  10697. /** path to specify the property of the target the conditional operator uses */
  10698. propertyPath: string;
  10699. /** the value compared by the conditional operator against the current value of the property */
  10700. value: any;
  10701. /** the conditional operator, default ValueCondition.IsEqual */
  10702. operator: number;
  10703. /**
  10704. * Internal only
  10705. * @hidden
  10706. */
  10707. private static _IsEqual;
  10708. /**
  10709. * Internal only
  10710. * @hidden
  10711. */
  10712. private static _IsDifferent;
  10713. /**
  10714. * Internal only
  10715. * @hidden
  10716. */
  10717. private static _IsGreater;
  10718. /**
  10719. * Internal only
  10720. * @hidden
  10721. */
  10722. private static _IsLesser;
  10723. /**
  10724. * returns the number for IsEqual
  10725. */
  10726. static readonly IsEqual: number;
  10727. /**
  10728. * Returns the number for IsDifferent
  10729. */
  10730. static readonly IsDifferent: number;
  10731. /**
  10732. * Returns the number for IsGreater
  10733. */
  10734. static readonly IsGreater: number;
  10735. /**
  10736. * Returns the number for IsLesser
  10737. */
  10738. static readonly IsLesser: number;
  10739. /**
  10740. * Internal only The action manager for the condition
  10741. * @hidden
  10742. */
  10743. _actionManager: ActionManager;
  10744. /**
  10745. * Internal only
  10746. * @hidden
  10747. */
  10748. private _target;
  10749. /**
  10750. * Internal only
  10751. * @hidden
  10752. */
  10753. private _effectiveTarget;
  10754. /**
  10755. * Internal only
  10756. * @hidden
  10757. */
  10758. private _property;
  10759. /**
  10760. * Creates a new ValueCondition
  10761. * @param actionManager manager for the action the condition applies to
  10762. * @param target for the action
  10763. * @param propertyPath path to specify the property of the target the conditional operator uses
  10764. * @param value the value compared by the conditional operator against the current value of the property
  10765. * @param operator the conditional operator, default ValueCondition.IsEqual
  10766. */
  10767. constructor(actionManager: ActionManager, target: any,
  10768. /** path to specify the property of the target the conditional operator uses */
  10769. propertyPath: string,
  10770. /** the value compared by the conditional operator against the current value of the property */
  10771. value: any,
  10772. /** the conditional operator, default ValueCondition.IsEqual */
  10773. operator?: number);
  10774. /**
  10775. * Compares the given value with the property value for the specified conditional operator
  10776. * @returns the result of the comparison
  10777. */
  10778. isValid(): boolean;
  10779. /**
  10780. * Serialize the ValueCondition into a JSON compatible object
  10781. * @returns serialization object
  10782. */
  10783. serialize(): any;
  10784. /**
  10785. * Gets the name of the conditional operator for the ValueCondition
  10786. * @param operator the conditional operator
  10787. * @returns the name
  10788. */
  10789. static GetOperatorName(operator: number): string;
  10790. }
  10791. /**
  10792. * Defines a predicate condition as an extension of Condition
  10793. */
  10794. export class PredicateCondition extends Condition {
  10795. /** defines the predicate function used to validate the condition */
  10796. predicate: () => boolean;
  10797. /**
  10798. * Internal only - manager for action
  10799. * @hidden
  10800. */
  10801. _actionManager: ActionManager;
  10802. /**
  10803. * Creates a new PredicateCondition
  10804. * @param actionManager manager for the action the condition applies to
  10805. * @param predicate defines the predicate function used to validate the condition
  10806. */
  10807. constructor(actionManager: ActionManager,
  10808. /** defines the predicate function used to validate the condition */
  10809. predicate: () => boolean);
  10810. /**
  10811. * @returns the validity of the predicate condition
  10812. */
  10813. isValid(): boolean;
  10814. }
  10815. /**
  10816. * Defines a state condition as an extension of Condition
  10817. */
  10818. export class StateCondition extends Condition {
  10819. /** Value to compare with target state */
  10820. value: string;
  10821. /**
  10822. * Internal only - manager for action
  10823. * @hidden
  10824. */
  10825. _actionManager: ActionManager;
  10826. /**
  10827. * Internal only
  10828. * @hidden
  10829. */
  10830. private _target;
  10831. /**
  10832. * Creates a new StateCondition
  10833. * @param actionManager manager for the action the condition applies to
  10834. * @param target of the condition
  10835. * @param value to compare with target state
  10836. */
  10837. constructor(actionManager: ActionManager, target: any,
  10838. /** Value to compare with target state */
  10839. value: string);
  10840. /**
  10841. * Gets a boolean indicating if the current condition is met
  10842. * @returns the validity of the state
  10843. */
  10844. isValid(): boolean;
  10845. /**
  10846. * Serialize the StateCondition into a JSON compatible object
  10847. * @returns serialization object
  10848. */
  10849. serialize(): any;
  10850. }
  10851. }
  10852. declare module "babylonjs/Actions/directActions" {
  10853. import { Action } from "babylonjs/Actions/action";
  10854. import { Condition } from "babylonjs/Actions/condition";
  10855. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10856. /**
  10857. * This defines an action responsible to toggle a boolean once triggered.
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10859. */
  10860. export class SwitchBooleanAction extends Action {
  10861. /**
  10862. * The path to the boolean property in the target object
  10863. */
  10864. propertyPath: string;
  10865. private _target;
  10866. private _effectiveTarget;
  10867. private _property;
  10868. /**
  10869. * Instantiate the action
  10870. * @param triggerOptions defines the trigger options
  10871. * @param target defines the object containing the boolean
  10872. * @param propertyPath defines the path to the boolean property in the target object
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10876. /** @hidden */
  10877. _prepare(): void;
  10878. /**
  10879. * Execute the action toggle the boolean value.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to set a the state field of the target
  10891. * to a desired value once triggered.
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10893. */
  10894. export class SetStateAction extends Action {
  10895. /**
  10896. * The value to store in the state field.
  10897. */
  10898. value: string;
  10899. private _target;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the object containing the state property
  10904. * @param value defines the value to store in the state field
  10905. * @param condition defines the trigger related conditions
  10906. */
  10907. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10908. /**
  10909. * Execute the action and store the value on the target state property.
  10910. */
  10911. execute(): void;
  10912. /**
  10913. * Serializes the actions and its related information.
  10914. * @param parent defines the object to serialize in
  10915. * @returns the serialized object
  10916. */
  10917. serialize(parent: any): any;
  10918. }
  10919. /**
  10920. * This defines an action responsible to set a property of the target
  10921. * to a desired value once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class SetValueAction extends Action {
  10925. /**
  10926. * The path of the property to set in the target.
  10927. */
  10928. propertyPath: string;
  10929. /**
  10930. * The value to set in the property
  10931. */
  10932. value: any;
  10933. private _target;
  10934. private _effectiveTarget;
  10935. private _property;
  10936. /**
  10937. * Instantiate the action
  10938. * @param triggerOptions defines the trigger options
  10939. * @param target defines the object containing the property
  10940. * @param propertyPath defines the path of the property to set in the target
  10941. * @param value defines the value to set in the property
  10942. * @param condition defines the trigger related conditions
  10943. */
  10944. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10945. /** @hidden */
  10946. _prepare(): void;
  10947. /**
  10948. * Execute the action and set the targetted property to the desired value.
  10949. */
  10950. execute(): void;
  10951. /**
  10952. * Serializes the actions and its related information.
  10953. * @param parent defines the object to serialize in
  10954. * @returns the serialized object
  10955. */
  10956. serialize(parent: any): any;
  10957. }
  10958. /**
  10959. * This defines an action responsible to increment the target value
  10960. * to a desired value once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class IncrementValueAction extends Action {
  10964. /**
  10965. * The path of the property to increment in the target.
  10966. */
  10967. propertyPath: string;
  10968. /**
  10969. * The value we should increment the property by.
  10970. */
  10971. value: any;
  10972. private _target;
  10973. private _effectiveTarget;
  10974. private _property;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param target defines the object containing the property
  10979. * @param propertyPath defines the path of the property to increment in the target
  10980. * @param value defines the value value we should increment the property by
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10984. /** @hidden */
  10985. _prepare(): void;
  10986. /**
  10987. * Execute the action and increment the target of the value amount.
  10988. */
  10989. execute(): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to start an animation once triggered.
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11000. */
  11001. export class PlayAnimationAction extends Action {
  11002. /**
  11003. * Where the animation should start (animation frame)
  11004. */
  11005. from: number;
  11006. /**
  11007. * Where the animation should stop (animation frame)
  11008. */
  11009. to: number;
  11010. /**
  11011. * Define if the animation should loop or stop after the first play.
  11012. */
  11013. loop?: boolean;
  11014. private _target;
  11015. /**
  11016. * Instantiate the action
  11017. * @param triggerOptions defines the trigger options
  11018. * @param target defines the target animation or animation name
  11019. * @param from defines from where the animation should start (animation frame)
  11020. * @param end defines where the animation should stop (animation frame)
  11021. * @param loop defines if the animation should loop or stop after the first play
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11025. /** @hidden */
  11026. _prepare(): void;
  11027. /**
  11028. * Execute the action and play the animation.
  11029. */
  11030. execute(): void;
  11031. /**
  11032. * Serializes the actions and its related information.
  11033. * @param parent defines the object to serialize in
  11034. * @returns the serialized object
  11035. */
  11036. serialize(parent: any): any;
  11037. }
  11038. /**
  11039. * This defines an action responsible to stop an animation once triggered.
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11041. */
  11042. export class StopAnimationAction extends Action {
  11043. private _target;
  11044. /**
  11045. * Instantiate the action
  11046. * @param triggerOptions defines the trigger options
  11047. * @param target defines the target animation or animation name
  11048. * @param condition defines the trigger related conditions
  11049. */
  11050. constructor(triggerOptions: any, target: any, condition?: Condition);
  11051. /** @hidden */
  11052. _prepare(): void;
  11053. /**
  11054. * Execute the action and stop the animation.
  11055. */
  11056. execute(): void;
  11057. /**
  11058. * Serializes the actions and its related information.
  11059. * @param parent defines the object to serialize in
  11060. * @returns the serialized object
  11061. */
  11062. serialize(parent: any): any;
  11063. }
  11064. /**
  11065. * This defines an action responsible that does nothing once triggered.
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11067. */
  11068. export class DoNothingAction extends Action {
  11069. /**
  11070. * Instantiate the action
  11071. * @param triggerOptions defines the trigger options
  11072. * @param condition defines the trigger related conditions
  11073. */
  11074. constructor(triggerOptions?: any, condition?: Condition);
  11075. /**
  11076. * Execute the action and do nothing.
  11077. */
  11078. execute(): void;
  11079. /**
  11080. * Serializes the actions and its related information.
  11081. * @param parent defines the object to serialize in
  11082. * @returns the serialized object
  11083. */
  11084. serialize(parent: any): any;
  11085. }
  11086. /**
  11087. * This defines an action responsible to trigger several actions once triggered.
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11089. */
  11090. export class CombineAction extends Action {
  11091. /**
  11092. * The list of aggregated animations to run.
  11093. */
  11094. children: Action[];
  11095. /**
  11096. * Instantiate the action
  11097. * @param triggerOptions defines the trigger options
  11098. * @param children defines the list of aggregated animations to run
  11099. * @param condition defines the trigger related conditions
  11100. */
  11101. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11102. /** @hidden */
  11103. _prepare(): void;
  11104. /**
  11105. * Execute the action and executes all the aggregated actions.
  11106. */
  11107. execute(evt: ActionEvent): void;
  11108. /**
  11109. * Serializes the actions and its related information.
  11110. * @param parent defines the object to serialize in
  11111. * @returns the serialized object
  11112. */
  11113. serialize(parent: any): any;
  11114. }
  11115. /**
  11116. * This defines an action responsible to run code (external event) once triggered.
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11118. */
  11119. export class ExecuteCodeAction extends Action {
  11120. /**
  11121. * The callback function to run.
  11122. */
  11123. func: (evt: ActionEvent) => void;
  11124. /**
  11125. * Instantiate the action
  11126. * @param triggerOptions defines the trigger options
  11127. * @param func defines the callback function to run
  11128. * @param condition defines the trigger related conditions
  11129. */
  11130. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11131. /**
  11132. * Execute the action and run the attached code.
  11133. */
  11134. execute(evt: ActionEvent): void;
  11135. }
  11136. /**
  11137. * This defines an action responsible to set the parent property of the target once triggered.
  11138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11139. */
  11140. export class SetParentAction extends Action {
  11141. private _parent;
  11142. private _target;
  11143. /**
  11144. * Instantiate the action
  11145. * @param triggerOptions defines the trigger options
  11146. * @param target defines the target containing the parent property
  11147. * @param parent defines from where the animation should start (animation frame)
  11148. * @param condition defines the trigger related conditions
  11149. */
  11150. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11151. /** @hidden */
  11152. _prepare(): void;
  11153. /**
  11154. * Execute the action and set the parent property.
  11155. */
  11156. execute(): void;
  11157. /**
  11158. * Serializes the actions and its related information.
  11159. * @param parent defines the object to serialize in
  11160. * @returns the serialized object
  11161. */
  11162. serialize(parent: any): any;
  11163. }
  11164. }
  11165. declare module "babylonjs/Actions/actionManager" {
  11166. import { Nullable } from "babylonjs/types";
  11167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11168. import { Scene } from "babylonjs/scene";
  11169. import { IAction } from "babylonjs/Actions/action";
  11170. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11171. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11172. /**
  11173. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11174. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11176. */
  11177. export class ActionManager extends AbstractActionManager {
  11178. /**
  11179. * Nothing
  11180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11181. */
  11182. static readonly NothingTrigger: number;
  11183. /**
  11184. * On pick
  11185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11186. */
  11187. static readonly OnPickTrigger: number;
  11188. /**
  11189. * On left pick
  11190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11191. */
  11192. static readonly OnLeftPickTrigger: number;
  11193. /**
  11194. * On right pick
  11195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11196. */
  11197. static readonly OnRightPickTrigger: number;
  11198. /**
  11199. * On center pick
  11200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11201. */
  11202. static readonly OnCenterPickTrigger: number;
  11203. /**
  11204. * On pick down
  11205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11206. */
  11207. static readonly OnPickDownTrigger: number;
  11208. /**
  11209. * On double pick
  11210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11211. */
  11212. static readonly OnDoublePickTrigger: number;
  11213. /**
  11214. * On pick up
  11215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11216. */
  11217. static readonly OnPickUpTrigger: number;
  11218. /**
  11219. * On pick out.
  11220. * This trigger will only be raised if you also declared a OnPickDown
  11221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11222. */
  11223. static readonly OnPickOutTrigger: number;
  11224. /**
  11225. * On long press
  11226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11227. */
  11228. static readonly OnLongPressTrigger: number;
  11229. /**
  11230. * On pointer over
  11231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11232. */
  11233. static readonly OnPointerOverTrigger: number;
  11234. /**
  11235. * On pointer out
  11236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11237. */
  11238. static readonly OnPointerOutTrigger: number;
  11239. /**
  11240. * On every frame
  11241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11242. */
  11243. static readonly OnEveryFrameTrigger: number;
  11244. /**
  11245. * On intersection enter
  11246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11247. */
  11248. static readonly OnIntersectionEnterTrigger: number;
  11249. /**
  11250. * On intersection exit
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11252. */
  11253. static readonly OnIntersectionExitTrigger: number;
  11254. /**
  11255. * On key down
  11256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11257. */
  11258. static readonly OnKeyDownTrigger: number;
  11259. /**
  11260. * On key up
  11261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11262. */
  11263. static readonly OnKeyUpTrigger: number;
  11264. private _scene;
  11265. /**
  11266. * Creates a new action manager
  11267. * @param scene defines the hosting scene
  11268. */
  11269. constructor(scene: Scene);
  11270. /**
  11271. * Releases all associated resources
  11272. */
  11273. dispose(): void;
  11274. /**
  11275. * Gets hosting scene
  11276. * @returns the hosting scene
  11277. */
  11278. getScene(): Scene;
  11279. /**
  11280. * Does this action manager handles actions of any of the given triggers
  11281. * @param triggers defines the triggers to be tested
  11282. * @return a boolean indicating whether one (or more) of the triggers is handled
  11283. */
  11284. hasSpecificTriggers(triggers: number[]): boolean;
  11285. /**
  11286. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11287. * speed.
  11288. * @param triggerA defines the trigger to be tested
  11289. * @param triggerB defines the trigger to be tested
  11290. * @return a boolean indicating whether one (or more) of the triggers is handled
  11291. */
  11292. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11293. /**
  11294. * Does this action manager handles actions of a given trigger
  11295. * @param trigger defines the trigger to be tested
  11296. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11297. * @return whether the trigger is handled
  11298. */
  11299. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11300. /**
  11301. * Does this action manager has pointer triggers
  11302. */
  11303. readonly hasPointerTriggers: boolean;
  11304. /**
  11305. * Does this action manager has pick triggers
  11306. */
  11307. readonly hasPickTriggers: boolean;
  11308. /**
  11309. * Registers an action to this action manager
  11310. * @param action defines the action to be registered
  11311. * @return the action amended (prepared) after registration
  11312. */
  11313. registerAction(action: IAction): Nullable<IAction>;
  11314. /**
  11315. * Unregisters an action to this action manager
  11316. * @param action defines the action to be unregistered
  11317. * @return a boolean indicating whether the action has been unregistered
  11318. */
  11319. unregisterAction(action: IAction): Boolean;
  11320. /**
  11321. * Process a specific trigger
  11322. * @param trigger defines the trigger to process
  11323. * @param evt defines the event details to be processed
  11324. */
  11325. processTrigger(trigger: number, evt?: IActionEvent): void;
  11326. /** @hidden */
  11327. _getEffectiveTarget(target: any, propertyPath: string): any;
  11328. /** @hidden */
  11329. _getProperty(propertyPath: string): string;
  11330. /**
  11331. * Serialize this manager to a JSON object
  11332. * @param name defines the property name to store this manager
  11333. * @returns a JSON representation of this manager
  11334. */
  11335. serialize(name: string): any;
  11336. /**
  11337. * Creates a new ActionManager from a JSON data
  11338. * @param parsedActions defines the JSON data to read from
  11339. * @param object defines the hosting mesh
  11340. * @param scene defines the hosting scene
  11341. */
  11342. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11343. /**
  11344. * Get a trigger name by index
  11345. * @param trigger defines the trigger index
  11346. * @returns a trigger name
  11347. */
  11348. static GetTriggerName(trigger: number): string;
  11349. }
  11350. }
  11351. declare module "babylonjs/Culling/ray" {
  11352. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11353. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11355. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11356. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11357. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11358. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11359. /**
  11360. * Class representing a ray with position and direction
  11361. */
  11362. export class Ray {
  11363. /** origin point */
  11364. origin: Vector3;
  11365. /** direction */
  11366. direction: Vector3;
  11367. /** length of the ray */
  11368. length: number;
  11369. private static readonly TmpVector3;
  11370. private _tmpRay;
  11371. /**
  11372. * Creates a new ray
  11373. * @param origin origin point
  11374. * @param direction direction
  11375. * @param length length of the ray
  11376. */
  11377. constructor(
  11378. /** origin point */
  11379. origin: Vector3,
  11380. /** direction */
  11381. direction: Vector3,
  11382. /** length of the ray */
  11383. length?: number);
  11384. /**
  11385. * Checks if the ray intersects a box
  11386. * @param minimum bound of the box
  11387. * @param maximum bound of the box
  11388. * @param intersectionTreshold extra extend to be added to the box in all direction
  11389. * @returns if the box was hit
  11390. */
  11391. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11392. /**
  11393. * Checks if the ray intersects a box
  11394. * @param box the bounding box to check
  11395. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11396. * @returns if the box was hit
  11397. */
  11398. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11399. /**
  11400. * If the ray hits a sphere
  11401. * @param sphere the bounding sphere to check
  11402. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11403. * @returns true if it hits the sphere
  11404. */
  11405. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11406. /**
  11407. * If the ray hits a triange
  11408. * @param vertex0 triangle vertex
  11409. * @param vertex1 triangle vertex
  11410. * @param vertex2 triangle vertex
  11411. * @returns intersection information if hit
  11412. */
  11413. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11414. /**
  11415. * Checks if ray intersects a plane
  11416. * @param plane the plane to check
  11417. * @returns the distance away it was hit
  11418. */
  11419. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11420. /**
  11421. * Checks if ray intersects a mesh
  11422. * @param mesh the mesh to check
  11423. * @param fastCheck if only the bounding box should checked
  11424. * @returns picking info of the intersecton
  11425. */
  11426. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11427. /**
  11428. * Checks if ray intersects a mesh
  11429. * @param meshes the meshes to check
  11430. * @param fastCheck if only the bounding box should checked
  11431. * @param results array to store result in
  11432. * @returns Array of picking infos
  11433. */
  11434. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11435. private _comparePickingInfo;
  11436. private static smallnum;
  11437. private static rayl;
  11438. /**
  11439. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11440. * @param sega the first point of the segment to test the intersection against
  11441. * @param segb the second point of the segment to test the intersection against
  11442. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11443. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11444. */
  11445. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11446. /**
  11447. * Update the ray from viewport position
  11448. * @param x position
  11449. * @param y y position
  11450. * @param viewportWidth viewport width
  11451. * @param viewportHeight viewport height
  11452. * @param world world matrix
  11453. * @param view view matrix
  11454. * @param projection projection matrix
  11455. * @returns this ray updated
  11456. */
  11457. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11458. /**
  11459. * Creates a ray with origin and direction of 0,0,0
  11460. * @returns the new ray
  11461. */
  11462. static Zero(): Ray;
  11463. /**
  11464. * Creates a new ray from screen space and viewport
  11465. * @param x position
  11466. * @param y y position
  11467. * @param viewportWidth viewport width
  11468. * @param viewportHeight viewport height
  11469. * @param world world matrix
  11470. * @param view view matrix
  11471. * @param projection projection matrix
  11472. * @returns new ray
  11473. */
  11474. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11475. /**
  11476. * 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
  11477. * transformed to the given world matrix.
  11478. * @param origin The origin point
  11479. * @param end The end point
  11480. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11481. * @returns the new ray
  11482. */
  11483. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11484. /**
  11485. * Transforms a ray by a matrix
  11486. * @param ray ray to transform
  11487. * @param matrix matrix to apply
  11488. * @returns the resulting new ray
  11489. */
  11490. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11491. /**
  11492. * Transforms a ray by a matrix
  11493. * @param ray ray to transform
  11494. * @param matrix matrix to apply
  11495. * @param result ray to store result in
  11496. */
  11497. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11498. /**
  11499. * Unproject a ray from screen space to object space
  11500. * @param sourceX defines the screen space x coordinate to use
  11501. * @param sourceY defines the screen space y coordinate to use
  11502. * @param viewportWidth defines the current width of the viewport
  11503. * @param viewportHeight defines the current height of the viewport
  11504. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11505. * @param view defines the view matrix to use
  11506. * @param projection defines the projection matrix to use
  11507. */
  11508. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11509. }
  11510. /**
  11511. * Type used to define predicate used to select faces when a mesh intersection is detected
  11512. */
  11513. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11514. module "babylonjs/scene" {
  11515. interface Scene {
  11516. /** @hidden */
  11517. _tempPickingRay: Nullable<Ray>;
  11518. /** @hidden */
  11519. _cachedRayForTransform: Ray;
  11520. /** @hidden */
  11521. _pickWithRayInverseMatrix: Matrix;
  11522. /** @hidden */
  11523. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11524. /** @hidden */
  11525. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11526. }
  11527. }
  11528. }
  11529. declare module "babylonjs/sceneComponent" {
  11530. import { Scene } from "babylonjs/scene";
  11531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11533. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11534. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11535. import { Nullable } from "babylonjs/types";
  11536. import { Camera } from "babylonjs/Cameras/camera";
  11537. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11538. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11539. import { AbstractScene } from "babylonjs/abstractScene";
  11540. /**
  11541. * Groups all the scene component constants in one place to ease maintenance.
  11542. * @hidden
  11543. */
  11544. export class SceneComponentConstants {
  11545. static readonly NAME_EFFECTLAYER: string;
  11546. static readonly NAME_LAYER: string;
  11547. static readonly NAME_LENSFLARESYSTEM: string;
  11548. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11549. static readonly NAME_PARTICLESYSTEM: string;
  11550. static readonly NAME_GAMEPAD: string;
  11551. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11552. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11553. static readonly NAME_DEPTHRENDERER: string;
  11554. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11555. static readonly NAME_SPRITE: string;
  11556. static readonly NAME_OUTLINERENDERER: string;
  11557. static readonly NAME_PROCEDURALTEXTURE: string;
  11558. static readonly NAME_SHADOWGENERATOR: string;
  11559. static readonly NAME_OCTREE: string;
  11560. static readonly NAME_PHYSICSENGINE: string;
  11561. static readonly NAME_AUDIO: string;
  11562. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11563. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11564. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11565. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11566. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11567. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11568. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11569. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11570. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11571. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11572. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11573. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11574. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11575. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11576. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11577. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11578. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11579. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11580. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11581. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11582. static readonly STEP_AFTERRENDER_AUDIO: number;
  11583. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11584. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11585. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11586. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11587. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11588. static readonly STEP_POINTERMOVE_SPRITE: number;
  11589. static readonly STEP_POINTERDOWN_SPRITE: number;
  11590. static readonly STEP_POINTERUP_SPRITE: number;
  11591. }
  11592. /**
  11593. * This represents a scene component.
  11594. *
  11595. * This is used to decouple the dependency the scene is having on the different workloads like
  11596. * layers, post processes...
  11597. */
  11598. export interface ISceneComponent {
  11599. /**
  11600. * The name of the component. Each component must have a unique name.
  11601. */
  11602. name: string;
  11603. /**
  11604. * The scene the component belongs to.
  11605. */
  11606. scene: Scene;
  11607. /**
  11608. * Register the component to one instance of a scene.
  11609. */
  11610. register(): void;
  11611. /**
  11612. * Rebuilds the elements related to this component in case of
  11613. * context lost for instance.
  11614. */
  11615. rebuild(): void;
  11616. /**
  11617. * Disposes the component and the associated ressources.
  11618. */
  11619. dispose(): void;
  11620. }
  11621. /**
  11622. * This represents a SERIALIZABLE scene component.
  11623. *
  11624. * This extends Scene Component to add Serialization methods on top.
  11625. */
  11626. export interface ISceneSerializableComponent extends ISceneComponent {
  11627. /**
  11628. * Adds all the element from the container to the scene
  11629. * @param container the container holding the elements
  11630. */
  11631. addFromContainer(container: AbstractScene): void;
  11632. /**
  11633. * Removes all the elements in the container from the scene
  11634. * @param container contains the elements to remove
  11635. * @param dispose if the removed element should be disposed (default: false)
  11636. */
  11637. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11638. /**
  11639. * Serializes the component data to the specified json object
  11640. * @param serializationObject The object to serialize to
  11641. */
  11642. serialize(serializationObject: any): void;
  11643. }
  11644. /**
  11645. * Strong typing of a Mesh related stage step action
  11646. */
  11647. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11648. /**
  11649. * Strong typing of a Evaluate Sub Mesh related stage step action
  11650. */
  11651. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11652. /**
  11653. * Strong typing of a Active Mesh related stage step action
  11654. */
  11655. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11656. /**
  11657. * Strong typing of a Camera related stage step action
  11658. */
  11659. export type CameraStageAction = (camera: Camera) => void;
  11660. /**
  11661. * Strong typing of a Render Target related stage step action
  11662. */
  11663. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11664. /**
  11665. * Strong typing of a RenderingGroup related stage step action
  11666. */
  11667. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11668. /**
  11669. * Strong typing of a Mesh Render related stage step action
  11670. */
  11671. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11672. /**
  11673. * Strong typing of a simple stage step action
  11674. */
  11675. export type SimpleStageAction = () => void;
  11676. /**
  11677. * Strong typing of a render target action.
  11678. */
  11679. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11680. /**
  11681. * Strong typing of a pointer move action.
  11682. */
  11683. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11684. /**
  11685. * Strong typing of a pointer up/down action.
  11686. */
  11687. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11688. /**
  11689. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11690. * @hidden
  11691. */
  11692. export class Stage<T extends Function> extends Array<{
  11693. index: number;
  11694. component: ISceneComponent;
  11695. action: T;
  11696. }> {
  11697. /**
  11698. * Hide ctor from the rest of the world.
  11699. * @param items The items to add.
  11700. */
  11701. private constructor();
  11702. /**
  11703. * Creates a new Stage.
  11704. * @returns A new instance of a Stage
  11705. */
  11706. static Create<T extends Function>(): Stage<T>;
  11707. /**
  11708. * Registers a step in an ordered way in the targeted stage.
  11709. * @param index Defines the position to register the step in
  11710. * @param component Defines the component attached to the step
  11711. * @param action Defines the action to launch during the step
  11712. */
  11713. registerStep(index: number, component: ISceneComponent, action: T): void;
  11714. /**
  11715. * Clears all the steps from the stage.
  11716. */
  11717. clear(): void;
  11718. }
  11719. }
  11720. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11721. import { Nullable } from "babylonjs/types";
  11722. import { Observable } from "babylonjs/Misc/observable";
  11723. import { Scene } from "babylonjs/scene";
  11724. import { Sprite } from "babylonjs/Sprites/sprite";
  11725. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11726. import { Ray } from "babylonjs/Culling/ray";
  11727. import { Camera } from "babylonjs/Cameras/camera";
  11728. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11729. import { ISceneComponent } from "babylonjs/sceneComponent";
  11730. module "babylonjs/scene" {
  11731. interface Scene {
  11732. /** @hidden */
  11733. _pointerOverSprite: Nullable<Sprite>;
  11734. /** @hidden */
  11735. _pickedDownSprite: Nullable<Sprite>;
  11736. /** @hidden */
  11737. _tempSpritePickingRay: Nullable<Ray>;
  11738. /**
  11739. * All of the sprite managers added to this scene
  11740. * @see http://doc.babylonjs.com/babylon101/sprites
  11741. */
  11742. spriteManagers: Array<ISpriteManager>;
  11743. /**
  11744. * An event triggered when sprites rendering is about to start
  11745. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11746. */
  11747. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11748. /**
  11749. * An event triggered when sprites rendering is done
  11750. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11751. */
  11752. onAfterSpritesRenderingObservable: Observable<Scene>;
  11753. /** @hidden */
  11754. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11755. /** Launch a ray to try to pick a sprite in the scene
  11756. * @param x position on screen
  11757. * @param y position on screen
  11758. * @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
  11759. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11760. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11761. * @returns a PickingInfo
  11762. */
  11763. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11764. /** Use the given ray to pick a sprite in the scene
  11765. * @param ray The ray (in world space) to use to pick meshes
  11766. * @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
  11767. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11768. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11769. * @returns a PickingInfo
  11770. */
  11771. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11772. /**
  11773. * Force the sprite under the pointer
  11774. * @param sprite defines the sprite to use
  11775. */
  11776. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11777. /**
  11778. * Gets the sprite under the pointer
  11779. * @returns a Sprite or null if no sprite is under the pointer
  11780. */
  11781. getPointerOverSprite(): Nullable<Sprite>;
  11782. }
  11783. }
  11784. /**
  11785. * Defines the sprite scene component responsible to manage sprites
  11786. * in a given scene.
  11787. */
  11788. export class SpriteSceneComponent implements ISceneComponent {
  11789. /**
  11790. * The component name helpfull to identify the component in the list of scene components.
  11791. */
  11792. readonly name: string;
  11793. /**
  11794. * The scene the component belongs to.
  11795. */
  11796. scene: Scene;
  11797. /** @hidden */
  11798. private _spritePredicate;
  11799. /**
  11800. * Creates a new instance of the component for the given scene
  11801. * @param scene Defines the scene to register the component in
  11802. */
  11803. constructor(scene: Scene);
  11804. /**
  11805. * Registers the component in a given scene
  11806. */
  11807. register(): void;
  11808. /**
  11809. * Rebuilds the elements related to this component in case of
  11810. * context lost for instance.
  11811. */
  11812. rebuild(): void;
  11813. /**
  11814. * Disposes the component and the associated ressources.
  11815. */
  11816. dispose(): void;
  11817. private _pickSpriteButKeepRay;
  11818. private _pointerMove;
  11819. private _pointerDown;
  11820. private _pointerUp;
  11821. }
  11822. }
  11823. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11824. /** @hidden */
  11825. export var fogFragmentDeclaration: {
  11826. name: string;
  11827. shader: string;
  11828. };
  11829. }
  11830. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11831. /** @hidden */
  11832. export var fogFragment: {
  11833. name: string;
  11834. shader: string;
  11835. };
  11836. }
  11837. declare module "babylonjs/Shaders/sprites.fragment" {
  11838. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11839. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11840. /** @hidden */
  11841. export var spritesPixelShader: {
  11842. name: string;
  11843. shader: string;
  11844. };
  11845. }
  11846. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11847. /** @hidden */
  11848. export var fogVertexDeclaration: {
  11849. name: string;
  11850. shader: string;
  11851. };
  11852. }
  11853. declare module "babylonjs/Shaders/sprites.vertex" {
  11854. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11855. /** @hidden */
  11856. export var spritesVertexShader: {
  11857. name: string;
  11858. shader: string;
  11859. };
  11860. }
  11861. declare module "babylonjs/Sprites/spriteManager" {
  11862. import { IDisposable, Scene } from "babylonjs/scene";
  11863. import { Nullable } from "babylonjs/types";
  11864. import { Observable } from "babylonjs/Misc/observable";
  11865. import { Sprite } from "babylonjs/Sprites/sprite";
  11866. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11867. import { Camera } from "babylonjs/Cameras/camera";
  11868. import { Texture } from "babylonjs/Materials/Textures/texture";
  11869. import "babylonjs/Shaders/sprites.fragment";
  11870. import "babylonjs/Shaders/sprites.vertex";
  11871. import { Ray } from "babylonjs/Culling/ray";
  11872. /**
  11873. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11874. */
  11875. export interface ISpriteManager extends IDisposable {
  11876. /**
  11877. * Restricts the camera to viewing objects with the same layerMask.
  11878. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11879. */
  11880. layerMask: number;
  11881. /**
  11882. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11883. */
  11884. isPickable: boolean;
  11885. /**
  11886. * Specifies the rendering group id for this mesh (0 by default)
  11887. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11888. */
  11889. renderingGroupId: number;
  11890. /**
  11891. * Defines the list of sprites managed by the manager.
  11892. */
  11893. sprites: Array<Sprite>;
  11894. /**
  11895. * Tests the intersection of a sprite with a specific ray.
  11896. * @param ray The ray we are sending to test the collision
  11897. * @param camera The camera space we are sending rays in
  11898. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11899. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11900. * @returns picking info or null.
  11901. */
  11902. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11903. /**
  11904. * Renders the list of sprites on screen.
  11905. */
  11906. render(): void;
  11907. }
  11908. /**
  11909. * Class used to manage multiple sprites on the same spritesheet
  11910. * @see http://doc.babylonjs.com/babylon101/sprites
  11911. */
  11912. export class SpriteManager implements ISpriteManager {
  11913. /** defines the manager's name */
  11914. name: string;
  11915. /** Gets the list of sprites */
  11916. sprites: Sprite[];
  11917. /** Gets or sets the rendering group id (0 by default) */
  11918. renderingGroupId: number;
  11919. /** Gets or sets camera layer mask */
  11920. layerMask: number;
  11921. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11922. fogEnabled: boolean;
  11923. /** Gets or sets a boolean indicating if the sprites are pickable */
  11924. isPickable: boolean;
  11925. /** Defines the default width of a cell in the spritesheet */
  11926. cellWidth: number;
  11927. /** Defines the default height of a cell in the spritesheet */
  11928. cellHeight: number;
  11929. /**
  11930. * An event triggered when the manager is disposed.
  11931. */
  11932. onDisposeObservable: Observable<SpriteManager>;
  11933. private _onDisposeObserver;
  11934. /**
  11935. * Callback called when the manager is disposed
  11936. */
  11937. onDispose: () => void;
  11938. private _capacity;
  11939. private _spriteTexture;
  11940. private _epsilon;
  11941. private _scene;
  11942. private _vertexData;
  11943. private _buffer;
  11944. private _vertexBuffers;
  11945. private _indexBuffer;
  11946. private _effectBase;
  11947. private _effectFog;
  11948. /**
  11949. * Gets or sets the spritesheet texture
  11950. */
  11951. texture: Texture;
  11952. /**
  11953. * Creates a new sprite manager
  11954. * @param name defines the manager's name
  11955. * @param imgUrl defines the sprite sheet url
  11956. * @param capacity defines the maximum allowed number of sprites
  11957. * @param cellSize defines the size of a sprite cell
  11958. * @param scene defines the hosting scene
  11959. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11960. * @param samplingMode defines the smapling mode to use with spritesheet
  11961. */
  11962. constructor(
  11963. /** defines the manager's name */
  11964. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11965. private _appendSpriteVertex;
  11966. /**
  11967. * Intersects the sprites with a ray
  11968. * @param ray defines the ray to intersect with
  11969. * @param camera defines the current active camera
  11970. * @param predicate defines a predicate used to select candidate sprites
  11971. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11972. * @returns null if no hit or a PickingInfo
  11973. */
  11974. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11975. /**
  11976. * Render all child sprites
  11977. */
  11978. render(): void;
  11979. /**
  11980. * Release associated resources
  11981. */
  11982. dispose(): void;
  11983. }
  11984. }
  11985. declare module "babylonjs/Sprites/sprite" {
  11986. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11987. import { Nullable } from "babylonjs/types";
  11988. import { ActionManager } from "babylonjs/Actions/actionManager";
  11989. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11990. /**
  11991. * Class used to represent a sprite
  11992. * @see http://doc.babylonjs.com/babylon101/sprites
  11993. */
  11994. export class Sprite {
  11995. /** defines the name */
  11996. name: string;
  11997. /** Gets or sets the current world position */
  11998. position: Vector3;
  11999. /** Gets or sets the main color */
  12000. color: Color4;
  12001. /** Gets or sets the width */
  12002. width: number;
  12003. /** Gets or sets the height */
  12004. height: number;
  12005. /** Gets or sets rotation angle */
  12006. angle: number;
  12007. /** Gets or sets the cell index in the sprite sheet */
  12008. cellIndex: number;
  12009. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12010. invertU: number;
  12011. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12012. invertV: number;
  12013. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12014. disposeWhenFinishedAnimating: boolean;
  12015. /** Gets the list of attached animations */
  12016. animations: Animation[];
  12017. /** Gets or sets a boolean indicating if the sprite can be picked */
  12018. isPickable: boolean;
  12019. /**
  12020. * Gets or sets the associated action manager
  12021. */
  12022. actionManager: Nullable<ActionManager>;
  12023. private _animationStarted;
  12024. private _loopAnimation;
  12025. private _fromIndex;
  12026. private _toIndex;
  12027. private _delay;
  12028. private _direction;
  12029. private _manager;
  12030. private _time;
  12031. private _onAnimationEnd;
  12032. /**
  12033. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12034. */
  12035. isVisible: boolean;
  12036. /**
  12037. * Gets or sets the sprite size
  12038. */
  12039. size: number;
  12040. /**
  12041. * Creates a new Sprite
  12042. * @param name defines the name
  12043. * @param manager defines the manager
  12044. */
  12045. constructor(
  12046. /** defines the name */
  12047. name: string, manager: ISpriteManager);
  12048. /**
  12049. * Starts an animation
  12050. * @param from defines the initial key
  12051. * @param to defines the end key
  12052. * @param loop defines if the animation must loop
  12053. * @param delay defines the start delay (in ms)
  12054. * @param onAnimationEnd defines a callback to call when animation ends
  12055. */
  12056. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12057. /** Stops current animation (if any) */
  12058. stopAnimation(): void;
  12059. /** @hidden */
  12060. _animate(deltaTime: number): void;
  12061. /** Release associated resources */
  12062. dispose(): void;
  12063. }
  12064. }
  12065. declare module "babylonjs/Collisions/pickingInfo" {
  12066. import { Nullable } from "babylonjs/types";
  12067. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12069. import { Sprite } from "babylonjs/Sprites/sprite";
  12070. import { Ray } from "babylonjs/Culling/ray";
  12071. /**
  12072. * Information about the result of picking within a scene
  12073. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12074. */
  12075. export class PickingInfo {
  12076. /** @hidden */
  12077. _pickingUnavailable: boolean;
  12078. /**
  12079. * If the pick collided with an object
  12080. */
  12081. hit: boolean;
  12082. /**
  12083. * Distance away where the pick collided
  12084. */
  12085. distance: number;
  12086. /**
  12087. * The location of pick collision
  12088. */
  12089. pickedPoint: Nullable<Vector3>;
  12090. /**
  12091. * The mesh corresponding the the pick collision
  12092. */
  12093. pickedMesh: Nullable<AbstractMesh>;
  12094. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12095. bu: number;
  12096. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12097. bv: number;
  12098. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12099. faceId: number;
  12100. /** Id of the the submesh that was picked */
  12101. subMeshId: number;
  12102. /** If a sprite was picked, this will be the sprite the pick collided with */
  12103. pickedSprite: Nullable<Sprite>;
  12104. /**
  12105. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12106. */
  12107. originMesh: Nullable<AbstractMesh>;
  12108. /**
  12109. * The ray that was used to perform the picking.
  12110. */
  12111. ray: Nullable<Ray>;
  12112. /**
  12113. * Gets the normal correspodning to the face the pick collided with
  12114. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12115. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12116. * @returns The normal correspodning to the face the pick collided with
  12117. */
  12118. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12119. /**
  12120. * Gets the texture coordinates of where the pick occured
  12121. * @returns the vector containing the coordnates of the texture
  12122. */
  12123. getTextureCoordinates(): Nullable<Vector2>;
  12124. }
  12125. }
  12126. declare module "babylonjs/Events/pointerEvents" {
  12127. import { Nullable } from "babylonjs/types";
  12128. import { Vector2 } from "babylonjs/Maths/math";
  12129. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12130. import { Ray } from "babylonjs/Culling/ray";
  12131. /**
  12132. * Gather the list of pointer event types as constants.
  12133. */
  12134. export class PointerEventTypes {
  12135. /**
  12136. * 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.
  12137. */
  12138. static readonly POINTERDOWN: number;
  12139. /**
  12140. * The pointerup event is fired when a pointer is no longer active.
  12141. */
  12142. static readonly POINTERUP: number;
  12143. /**
  12144. * The pointermove event is fired when a pointer changes coordinates.
  12145. */
  12146. static readonly POINTERMOVE: number;
  12147. /**
  12148. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12149. */
  12150. static readonly POINTERWHEEL: number;
  12151. /**
  12152. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12153. */
  12154. static readonly POINTERPICK: number;
  12155. /**
  12156. * The pointertap event is fired when a the object has been touched and released without drag.
  12157. */
  12158. static readonly POINTERTAP: number;
  12159. /**
  12160. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12161. */
  12162. static readonly POINTERDOUBLETAP: number;
  12163. }
  12164. /**
  12165. * Base class of pointer info types.
  12166. */
  12167. export class PointerInfoBase {
  12168. /**
  12169. * Defines the type of event (PointerEventTypes)
  12170. */
  12171. type: number;
  12172. /**
  12173. * Defines the related dom event
  12174. */
  12175. event: PointerEvent | MouseWheelEvent;
  12176. /**
  12177. * Instantiates the base class of pointers info.
  12178. * @param type Defines the type of event (PointerEventTypes)
  12179. * @param event Defines the related dom event
  12180. */
  12181. constructor(
  12182. /**
  12183. * Defines the type of event (PointerEventTypes)
  12184. */
  12185. type: number,
  12186. /**
  12187. * Defines the related dom event
  12188. */
  12189. event: PointerEvent | MouseWheelEvent);
  12190. }
  12191. /**
  12192. * This class is used to store pointer related info for the onPrePointerObservable event.
  12193. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12194. */
  12195. export class PointerInfoPre extends PointerInfoBase {
  12196. /**
  12197. * Ray from a pointer if availible (eg. 6dof controller)
  12198. */
  12199. ray: Nullable<Ray>;
  12200. /**
  12201. * Defines the local position of the pointer on the canvas.
  12202. */
  12203. localPosition: Vector2;
  12204. /**
  12205. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12206. */
  12207. skipOnPointerObservable: boolean;
  12208. /**
  12209. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12210. * @param type Defines the type of event (PointerEventTypes)
  12211. * @param event Defines the related dom event
  12212. * @param localX Defines the local x coordinates of the pointer when the event occured
  12213. * @param localY Defines the local y coordinates of the pointer when the event occured
  12214. */
  12215. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12216. }
  12217. /**
  12218. * This type contains all the data related to a pointer event in Babylon.js.
  12219. * 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.
  12220. */
  12221. export class PointerInfo extends PointerInfoBase {
  12222. /**
  12223. * Defines the picking info associated to the info (if any)\
  12224. */
  12225. pickInfo: Nullable<PickingInfo>;
  12226. /**
  12227. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12228. * @param type Defines the type of event (PointerEventTypes)
  12229. * @param event Defines the related dom event
  12230. * @param pickInfo Defines the picking info associated to the info (if any)\
  12231. */
  12232. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12233. /**
  12234. * Defines the picking info associated to the info (if any)\
  12235. */
  12236. pickInfo: Nullable<PickingInfo>);
  12237. }
  12238. /**
  12239. * Data relating to a touch event on the screen.
  12240. */
  12241. export interface PointerTouch {
  12242. /**
  12243. * X coordinate of touch.
  12244. */
  12245. x: number;
  12246. /**
  12247. * Y coordinate of touch.
  12248. */
  12249. y: number;
  12250. /**
  12251. * Id of touch. Unique for each finger.
  12252. */
  12253. pointerId: number;
  12254. /**
  12255. * Event type passed from DOM.
  12256. */
  12257. type: any;
  12258. }
  12259. }
  12260. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12261. import { Nullable } from "babylonjs/types";
  12262. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12263. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12264. /**
  12265. * Manage the mouse inputs to control the movement of a free camera.
  12266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12267. */
  12268. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12269. /**
  12270. * Define if touch is enabled in the mouse input
  12271. */
  12272. touchEnabled: boolean;
  12273. /**
  12274. * Defines the camera the input is attached to.
  12275. */
  12276. camera: FreeCamera;
  12277. /**
  12278. * Defines the buttons associated with the input to handle camera move.
  12279. */
  12280. buttons: number[];
  12281. /**
  12282. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12283. */
  12284. angularSensibility: number;
  12285. private _pointerInput;
  12286. private _onMouseMove;
  12287. private _observer;
  12288. private previousPosition;
  12289. /**
  12290. * Manage the mouse inputs to control the movement of a free camera.
  12291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12292. * @param touchEnabled Defines if touch is enabled or not
  12293. */
  12294. constructor(
  12295. /**
  12296. * Define if touch is enabled in the mouse input
  12297. */
  12298. touchEnabled?: boolean);
  12299. /**
  12300. * Attach the input controls to a specific dom element to get the input from.
  12301. * @param element Defines the element the controls should be listened from
  12302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12303. */
  12304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12305. /**
  12306. * Called on JS contextmenu event.
  12307. * Override this method to provide functionality.
  12308. */
  12309. protected onContextMenu(evt: PointerEvent): void;
  12310. /**
  12311. * Detach the current controls from the specified dom element.
  12312. * @param element Defines the element to stop listening the inputs from
  12313. */
  12314. detachControl(element: Nullable<HTMLElement>): void;
  12315. /**
  12316. * Gets the class name of the current intput.
  12317. * @returns the class name
  12318. */
  12319. getClassName(): string;
  12320. /**
  12321. * Get the friendly name associated with the input class.
  12322. * @returns the input friendly name
  12323. */
  12324. getSimpleName(): string;
  12325. }
  12326. }
  12327. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12328. import { Nullable } from "babylonjs/types";
  12329. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12331. /**
  12332. * Manage the touch inputs to control the movement of a free camera.
  12333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12334. */
  12335. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12336. /**
  12337. * Defines the camera the input is attached to.
  12338. */
  12339. camera: FreeCamera;
  12340. /**
  12341. * Defines the touch sensibility for rotation.
  12342. * The higher the faster.
  12343. */
  12344. touchAngularSensibility: number;
  12345. /**
  12346. * Defines the touch sensibility for move.
  12347. * The higher the faster.
  12348. */
  12349. touchMoveSensibility: number;
  12350. private _offsetX;
  12351. private _offsetY;
  12352. private _pointerPressed;
  12353. private _pointerInput;
  12354. private _observer;
  12355. private _onLostFocus;
  12356. /**
  12357. * Attach the input controls to a specific dom element to get the input from.
  12358. * @param element Defines the element the controls should be listened from
  12359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12360. */
  12361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12362. /**
  12363. * Detach the current controls from the specified dom element.
  12364. * @param element Defines the element to stop listening the inputs from
  12365. */
  12366. detachControl(element: Nullable<HTMLElement>): void;
  12367. /**
  12368. * Update the current camera state depending on the inputs that have been used this frame.
  12369. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12370. */
  12371. checkInputs(): void;
  12372. /**
  12373. * Gets the class name of the current intput.
  12374. * @returns the class name
  12375. */
  12376. getClassName(): string;
  12377. /**
  12378. * Get the friendly name associated with the input class.
  12379. * @returns the input friendly name
  12380. */
  12381. getSimpleName(): string;
  12382. }
  12383. }
  12384. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12385. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12386. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12387. /**
  12388. * Default Inputs manager for the FreeCamera.
  12389. * It groups all the default supported inputs for ease of use.
  12390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12391. */
  12392. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12393. /**
  12394. * Instantiates a new FreeCameraInputsManager.
  12395. * @param camera Defines the camera the inputs belong to
  12396. */
  12397. constructor(camera: FreeCamera);
  12398. /**
  12399. * Add keyboard input support to the input manager.
  12400. * @returns the current input manager
  12401. */
  12402. addKeyboard(): FreeCameraInputsManager;
  12403. /**
  12404. * Add mouse input support to the input manager.
  12405. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12406. * @returns the current input manager
  12407. */
  12408. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12409. /**
  12410. * Add touch input support to the input manager.
  12411. * @returns the current input manager
  12412. */
  12413. addTouch(): FreeCameraInputsManager;
  12414. }
  12415. }
  12416. declare module "babylonjs/Cameras/freeCamera" {
  12417. import { Vector3 } from "babylonjs/Maths/math";
  12418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12419. import { Scene } from "babylonjs/scene";
  12420. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12421. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12422. /**
  12423. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12424. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12425. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12426. */
  12427. export class FreeCamera extends TargetCamera {
  12428. /**
  12429. * Define the collision ellipsoid of the camera.
  12430. * This is helpful to simulate a camera body like the player body around the camera
  12431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12432. */
  12433. ellipsoid: Vector3;
  12434. /**
  12435. * Define an offset for the position of the ellipsoid around the camera.
  12436. * This can be helpful to determine the center of the body near the gravity center of the body
  12437. * instead of its head.
  12438. */
  12439. ellipsoidOffset: Vector3;
  12440. /**
  12441. * Enable or disable collisions of the camera with the rest of the scene objects.
  12442. */
  12443. checkCollisions: boolean;
  12444. /**
  12445. * Enable or disable gravity on the camera.
  12446. */
  12447. applyGravity: boolean;
  12448. /**
  12449. * Define the input manager associated to the camera.
  12450. */
  12451. inputs: FreeCameraInputsManager;
  12452. /**
  12453. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12454. * Higher values reduce sensitivity.
  12455. */
  12456. /**
  12457. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12458. * Higher values reduce sensitivity.
  12459. */
  12460. angularSensibility: number;
  12461. /**
  12462. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12463. */
  12464. keysUp: number[];
  12465. /**
  12466. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12467. */
  12468. keysDown: number[];
  12469. /**
  12470. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12471. */
  12472. keysLeft: number[];
  12473. /**
  12474. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12475. */
  12476. keysRight: number[];
  12477. /**
  12478. * Event raised when the camera collide with a mesh in the scene.
  12479. */
  12480. onCollide: (collidedMesh: AbstractMesh) => void;
  12481. private _collider;
  12482. private _needMoveForGravity;
  12483. private _oldPosition;
  12484. private _diffPosition;
  12485. private _newPosition;
  12486. /** @hidden */
  12487. _localDirection: Vector3;
  12488. /** @hidden */
  12489. _transformedDirection: Vector3;
  12490. /**
  12491. * Instantiates a Free Camera.
  12492. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12493. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12494. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12495. * @param name Define the name of the camera in the scene
  12496. * @param position Define the start position of the camera in the scene
  12497. * @param scene Define the scene the camera belongs to
  12498. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12499. */
  12500. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12501. /**
  12502. * Attached controls to the current camera.
  12503. * @param element Defines the element the controls should be listened from
  12504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12505. */
  12506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12507. /**
  12508. * Detach the current controls from the camera.
  12509. * The camera will stop reacting to inputs.
  12510. * @param element Defines the element to stop listening the inputs from
  12511. */
  12512. detachControl(element: HTMLElement): void;
  12513. private _collisionMask;
  12514. /**
  12515. * Define a collision mask to limit the list of object the camera can collide with
  12516. */
  12517. collisionMask: number;
  12518. /** @hidden */
  12519. _collideWithWorld(displacement: Vector3): void;
  12520. private _onCollisionPositionChange;
  12521. /** @hidden */
  12522. _checkInputs(): void;
  12523. /** @hidden */
  12524. _decideIfNeedsToMove(): boolean;
  12525. /** @hidden */
  12526. _updatePosition(): void;
  12527. /**
  12528. * Destroy the camera and release the current resources hold by it.
  12529. */
  12530. dispose(): void;
  12531. /**
  12532. * Gets the current object class name.
  12533. * @return the class name
  12534. */
  12535. getClassName(): string;
  12536. }
  12537. }
  12538. declare module "babylonjs/Gamepads/gamepad" {
  12539. import { Observable } from "babylonjs/Misc/observable";
  12540. /**
  12541. * Represents a gamepad control stick position
  12542. */
  12543. export class StickValues {
  12544. /**
  12545. * The x component of the control stick
  12546. */
  12547. x: number;
  12548. /**
  12549. * The y component of the control stick
  12550. */
  12551. y: number;
  12552. /**
  12553. * Initializes the gamepad x and y control stick values
  12554. * @param x The x component of the gamepad control stick value
  12555. * @param y The y component of the gamepad control stick value
  12556. */
  12557. constructor(
  12558. /**
  12559. * The x component of the control stick
  12560. */
  12561. x: number,
  12562. /**
  12563. * The y component of the control stick
  12564. */
  12565. y: number);
  12566. }
  12567. /**
  12568. * An interface which manages callbacks for gamepad button changes
  12569. */
  12570. export interface GamepadButtonChanges {
  12571. /**
  12572. * Called when a gamepad has been changed
  12573. */
  12574. changed: boolean;
  12575. /**
  12576. * Called when a gamepad press event has been triggered
  12577. */
  12578. pressChanged: boolean;
  12579. /**
  12580. * Called when a touch event has been triggered
  12581. */
  12582. touchChanged: boolean;
  12583. /**
  12584. * Called when a value has changed
  12585. */
  12586. valueChanged: boolean;
  12587. }
  12588. /**
  12589. * Represents a gamepad
  12590. */
  12591. export class Gamepad {
  12592. /**
  12593. * The id of the gamepad
  12594. */
  12595. id: string;
  12596. /**
  12597. * The index of the gamepad
  12598. */
  12599. index: number;
  12600. /**
  12601. * The browser gamepad
  12602. */
  12603. browserGamepad: any;
  12604. /**
  12605. * Specifies what type of gamepad this represents
  12606. */
  12607. type: number;
  12608. private _leftStick;
  12609. private _rightStick;
  12610. /** @hidden */
  12611. _isConnected: boolean;
  12612. private _leftStickAxisX;
  12613. private _leftStickAxisY;
  12614. private _rightStickAxisX;
  12615. private _rightStickAxisY;
  12616. /**
  12617. * Triggered when the left control stick has been changed
  12618. */
  12619. private _onleftstickchanged;
  12620. /**
  12621. * Triggered when the right control stick has been changed
  12622. */
  12623. private _onrightstickchanged;
  12624. /**
  12625. * Represents a gamepad controller
  12626. */
  12627. static GAMEPAD: number;
  12628. /**
  12629. * Represents a generic controller
  12630. */
  12631. static GENERIC: number;
  12632. /**
  12633. * Represents an XBox controller
  12634. */
  12635. static XBOX: number;
  12636. /**
  12637. * Represents a pose-enabled controller
  12638. */
  12639. static POSE_ENABLED: number;
  12640. /**
  12641. * Specifies whether the left control stick should be Y-inverted
  12642. */
  12643. protected _invertLeftStickY: boolean;
  12644. /**
  12645. * Specifies if the gamepad has been connected
  12646. */
  12647. readonly isConnected: boolean;
  12648. /**
  12649. * Initializes the gamepad
  12650. * @param id The id of the gamepad
  12651. * @param index The index of the gamepad
  12652. * @param browserGamepad The browser gamepad
  12653. * @param leftStickX The x component of the left joystick
  12654. * @param leftStickY The y component of the left joystick
  12655. * @param rightStickX The x component of the right joystick
  12656. * @param rightStickY The y component of the right joystick
  12657. */
  12658. constructor(
  12659. /**
  12660. * The id of the gamepad
  12661. */
  12662. id: string,
  12663. /**
  12664. * The index of the gamepad
  12665. */
  12666. index: number,
  12667. /**
  12668. * The browser gamepad
  12669. */
  12670. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12671. /**
  12672. * Callback triggered when the left joystick has changed
  12673. * @param callback
  12674. */
  12675. onleftstickchanged(callback: (values: StickValues) => void): void;
  12676. /**
  12677. * Callback triggered when the right joystick has changed
  12678. * @param callback
  12679. */
  12680. onrightstickchanged(callback: (values: StickValues) => void): void;
  12681. /**
  12682. * Gets the left joystick
  12683. */
  12684. /**
  12685. * Sets the left joystick values
  12686. */
  12687. leftStick: StickValues;
  12688. /**
  12689. * Gets the right joystick
  12690. */
  12691. /**
  12692. * Sets the right joystick value
  12693. */
  12694. rightStick: StickValues;
  12695. /**
  12696. * Updates the gamepad joystick positions
  12697. */
  12698. update(): void;
  12699. /**
  12700. * Disposes the gamepad
  12701. */
  12702. dispose(): void;
  12703. }
  12704. /**
  12705. * Represents a generic gamepad
  12706. */
  12707. export class GenericPad extends Gamepad {
  12708. private _buttons;
  12709. private _onbuttondown;
  12710. private _onbuttonup;
  12711. /**
  12712. * Observable triggered when a button has been pressed
  12713. */
  12714. onButtonDownObservable: Observable<number>;
  12715. /**
  12716. * Observable triggered when a button has been released
  12717. */
  12718. onButtonUpObservable: Observable<number>;
  12719. /**
  12720. * Callback triggered when a button has been pressed
  12721. * @param callback Called when a button has been pressed
  12722. */
  12723. onbuttondown(callback: (buttonPressed: number) => void): void;
  12724. /**
  12725. * Callback triggered when a button has been released
  12726. * @param callback Called when a button has been released
  12727. */
  12728. onbuttonup(callback: (buttonReleased: number) => void): void;
  12729. /**
  12730. * Initializes the generic gamepad
  12731. * @param id The id of the generic gamepad
  12732. * @param index The index of the generic gamepad
  12733. * @param browserGamepad The browser gamepad
  12734. */
  12735. constructor(id: string, index: number, browserGamepad: any);
  12736. private _setButtonValue;
  12737. /**
  12738. * Updates the generic gamepad
  12739. */
  12740. update(): void;
  12741. /**
  12742. * Disposes the generic gamepad
  12743. */
  12744. dispose(): void;
  12745. }
  12746. }
  12747. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12748. import { Observable } from "babylonjs/Misc/observable";
  12749. import { Nullable } from "babylonjs/types";
  12750. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12751. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12753. import { Ray } from "babylonjs/Culling/ray";
  12754. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12755. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12756. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12757. /**
  12758. * Defines the types of pose enabled controllers that are supported
  12759. */
  12760. export enum PoseEnabledControllerType {
  12761. /**
  12762. * HTC Vive
  12763. */
  12764. VIVE = 0,
  12765. /**
  12766. * Oculus Rift
  12767. */
  12768. OCULUS = 1,
  12769. /**
  12770. * Windows mixed reality
  12771. */
  12772. WINDOWS = 2,
  12773. /**
  12774. * Samsung gear VR
  12775. */
  12776. GEAR_VR = 3,
  12777. /**
  12778. * Google Daydream
  12779. */
  12780. DAYDREAM = 4,
  12781. /**
  12782. * Generic
  12783. */
  12784. GENERIC = 5
  12785. }
  12786. /**
  12787. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12788. */
  12789. export interface MutableGamepadButton {
  12790. /**
  12791. * Value of the button/trigger
  12792. */
  12793. value: number;
  12794. /**
  12795. * If the button/trigger is currently touched
  12796. */
  12797. touched: boolean;
  12798. /**
  12799. * If the button/trigger is currently pressed
  12800. */
  12801. pressed: boolean;
  12802. }
  12803. /**
  12804. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12805. * @hidden
  12806. */
  12807. export interface ExtendedGamepadButton extends GamepadButton {
  12808. /**
  12809. * If the button/trigger is currently pressed
  12810. */
  12811. readonly pressed: boolean;
  12812. /**
  12813. * If the button/trigger is currently touched
  12814. */
  12815. readonly touched: boolean;
  12816. /**
  12817. * Value of the button/trigger
  12818. */
  12819. readonly value: number;
  12820. }
  12821. /** @hidden */
  12822. export interface _GamePadFactory {
  12823. /**
  12824. * Returns wether or not the current gamepad can be created for this type of controller.
  12825. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12826. * @returns true if it can be created, otherwise false
  12827. */
  12828. canCreate(gamepadInfo: any): boolean;
  12829. /**
  12830. * Creates a new instance of the Gamepad.
  12831. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12832. * @returns the new gamepad instance
  12833. */
  12834. create(gamepadInfo: any): Gamepad;
  12835. }
  12836. /**
  12837. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12838. */
  12839. export class PoseEnabledControllerHelper {
  12840. /** @hidden */
  12841. static _ControllerFactories: _GamePadFactory[];
  12842. /** @hidden */
  12843. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12844. /**
  12845. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12846. * @param vrGamepad the gamepad to initialized
  12847. * @returns a vr controller of the type the gamepad identified as
  12848. */
  12849. static InitiateController(vrGamepad: any): Gamepad;
  12850. }
  12851. /**
  12852. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12853. */
  12854. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12855. private _deviceRoomPosition;
  12856. private _deviceRoomRotationQuaternion;
  12857. /**
  12858. * The device position in babylon space
  12859. */
  12860. devicePosition: Vector3;
  12861. /**
  12862. * The device rotation in babylon space
  12863. */
  12864. deviceRotationQuaternion: Quaternion;
  12865. /**
  12866. * The scale factor of the device in babylon space
  12867. */
  12868. deviceScaleFactor: number;
  12869. /**
  12870. * (Likely devicePosition should be used instead) The device position in its room space
  12871. */
  12872. position: Vector3;
  12873. /**
  12874. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12875. */
  12876. rotationQuaternion: Quaternion;
  12877. /**
  12878. * The type of controller (Eg. Windows mixed reality)
  12879. */
  12880. controllerType: PoseEnabledControllerType;
  12881. protected _calculatedPosition: Vector3;
  12882. private _calculatedRotation;
  12883. /**
  12884. * The raw pose from the device
  12885. */
  12886. rawPose: DevicePose;
  12887. private _trackPosition;
  12888. private _maxRotationDistFromHeadset;
  12889. private _draggedRoomRotation;
  12890. /**
  12891. * @hidden
  12892. */
  12893. _disableTrackPosition(fixedPosition: Vector3): void;
  12894. /**
  12895. * Internal, the mesh attached to the controller
  12896. * @hidden
  12897. */
  12898. _mesh: Nullable<AbstractMesh>;
  12899. private _poseControlledCamera;
  12900. private _leftHandSystemQuaternion;
  12901. /**
  12902. * Internal, matrix used to convert room space to babylon space
  12903. * @hidden
  12904. */
  12905. _deviceToWorld: Matrix;
  12906. /**
  12907. * Node to be used when casting a ray from the controller
  12908. * @hidden
  12909. */
  12910. _pointingPoseNode: Nullable<TransformNode>;
  12911. /**
  12912. * Name of the child mesh that can be used to cast a ray from the controller
  12913. */
  12914. static readonly POINTING_POSE: string;
  12915. /**
  12916. * Creates a new PoseEnabledController from a gamepad
  12917. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12918. */
  12919. constructor(browserGamepad: any);
  12920. private _workingMatrix;
  12921. /**
  12922. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12923. */
  12924. update(): void;
  12925. /**
  12926. * Updates only the pose device and mesh without doing any button event checking
  12927. */
  12928. protected _updatePoseAndMesh(): void;
  12929. /**
  12930. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12931. * @param poseData raw pose fromthe device
  12932. */
  12933. updateFromDevice(poseData: DevicePose): void;
  12934. /**
  12935. * @hidden
  12936. */
  12937. _meshAttachedObservable: Observable<AbstractMesh>;
  12938. /**
  12939. * Attaches a mesh to the controller
  12940. * @param mesh the mesh to be attached
  12941. */
  12942. attachToMesh(mesh: AbstractMesh): void;
  12943. /**
  12944. * Attaches the controllers mesh to a camera
  12945. * @param camera the camera the mesh should be attached to
  12946. */
  12947. attachToPoseControlledCamera(camera: TargetCamera): void;
  12948. /**
  12949. * Disposes of the controller
  12950. */
  12951. dispose(): void;
  12952. /**
  12953. * The mesh that is attached to the controller
  12954. */
  12955. readonly mesh: Nullable<AbstractMesh>;
  12956. /**
  12957. * Gets the ray of the controller in the direction the controller is pointing
  12958. * @param length the length the resulting ray should be
  12959. * @returns a ray in the direction the controller is pointing
  12960. */
  12961. getForwardRay(length?: number): Ray;
  12962. }
  12963. }
  12964. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12965. import { Observable } from "babylonjs/Misc/observable";
  12966. import { Scene } from "babylonjs/scene";
  12967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12968. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12969. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12970. /**
  12971. * Defines the WebVRController object that represents controllers tracked in 3D space
  12972. */
  12973. export abstract class WebVRController extends PoseEnabledController {
  12974. /**
  12975. * Internal, the default controller model for the controller
  12976. */
  12977. protected _defaultModel: AbstractMesh;
  12978. /**
  12979. * Fired when the trigger state has changed
  12980. */
  12981. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12982. /**
  12983. * Fired when the main button state has changed
  12984. */
  12985. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12986. /**
  12987. * Fired when the secondary button state has changed
  12988. */
  12989. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12990. /**
  12991. * Fired when the pad state has changed
  12992. */
  12993. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12994. /**
  12995. * Fired when controllers stick values have changed
  12996. */
  12997. onPadValuesChangedObservable: Observable<StickValues>;
  12998. /**
  12999. * Array of button availible on the controller
  13000. */
  13001. protected _buttons: Array<MutableGamepadButton>;
  13002. private _onButtonStateChange;
  13003. /**
  13004. * Fired when a controller button's state has changed
  13005. * @param callback the callback containing the button that was modified
  13006. */
  13007. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13008. /**
  13009. * X and Y axis corrisponding to the controllers joystick
  13010. */
  13011. pad: StickValues;
  13012. /**
  13013. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13014. */
  13015. hand: string;
  13016. /**
  13017. * The default controller model for the controller
  13018. */
  13019. readonly defaultModel: AbstractMesh;
  13020. /**
  13021. * Creates a new WebVRController from a gamepad
  13022. * @param vrGamepad the gamepad that the WebVRController should be created from
  13023. */
  13024. constructor(vrGamepad: any);
  13025. /**
  13026. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13027. */
  13028. update(): void;
  13029. /**
  13030. * Function to be called when a button is modified
  13031. */
  13032. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13033. /**
  13034. * Loads a mesh and attaches it to the controller
  13035. * @param scene the scene the mesh should be added to
  13036. * @param meshLoaded callback for when the mesh has been loaded
  13037. */
  13038. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13039. private _setButtonValue;
  13040. private _changes;
  13041. private _checkChanges;
  13042. /**
  13043. * Disposes of th webVRCOntroller
  13044. */
  13045. dispose(): void;
  13046. }
  13047. }
  13048. declare module "babylonjs/Lights/hemisphericLight" {
  13049. import { Nullable } from "babylonjs/types";
  13050. import { Scene } from "babylonjs/scene";
  13051. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13052. import { Effect } from "babylonjs/Materials/effect";
  13053. import { Light } from "babylonjs/Lights/light";
  13054. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13055. /**
  13056. * The HemisphericLight simulates the ambient environment light,
  13057. * so the passed direction is the light reflection direction, not the incoming direction.
  13058. */
  13059. export class HemisphericLight extends Light {
  13060. /**
  13061. * The groundColor is the light in the opposite direction to the one specified during creation.
  13062. * 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.
  13063. */
  13064. groundColor: Color3;
  13065. /**
  13066. * The light reflection direction, not the incoming direction.
  13067. */
  13068. direction: Vector3;
  13069. /**
  13070. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13071. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13072. * The HemisphericLight can't cast shadows.
  13073. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13074. * @param name The friendly name of the light
  13075. * @param direction The direction of the light reflection
  13076. * @param scene The scene the light belongs to
  13077. */
  13078. constructor(name: string, direction: Vector3, scene: Scene);
  13079. protected _buildUniformLayout(): void;
  13080. /**
  13081. * Returns the string "HemisphericLight".
  13082. * @return The class name
  13083. */
  13084. getClassName(): string;
  13085. /**
  13086. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13087. * Returns the updated direction.
  13088. * @param target The target the direction should point to
  13089. * @return The computed direction
  13090. */
  13091. setDirectionToTarget(target: Vector3): Vector3;
  13092. /**
  13093. * Returns the shadow generator associated to the light.
  13094. * @returns Always null for hemispheric lights because it does not support shadows.
  13095. */
  13096. getShadowGenerator(): Nullable<IShadowGenerator>;
  13097. /**
  13098. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13099. * @param effect The effect to update
  13100. * @param lightIndex The index of the light in the effect to update
  13101. * @returns The hemispheric light
  13102. */
  13103. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13104. /**
  13105. * Computes the world matrix of the node
  13106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13107. * @param useWasUpdatedFlag defines a reserved property
  13108. * @returns the world matrix
  13109. */
  13110. computeWorldMatrix(): Matrix;
  13111. /**
  13112. * Returns the integer 3.
  13113. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13114. */
  13115. getTypeID(): number;
  13116. /**
  13117. * Prepares the list of defines specific to the light type.
  13118. * @param defines the list of defines
  13119. * @param lightIndex defines the index of the light for the effect
  13120. */
  13121. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13122. }
  13123. }
  13124. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  13125. import { Matrix } from "babylonjs/Maths/math";
  13126. /**
  13127. * This represents all the required metrics to create a VR camera.
  13128. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  13129. */
  13130. export class VRCameraMetrics {
  13131. /**
  13132. * Define the horizontal resolution off the screen.
  13133. */
  13134. hResolution: number;
  13135. /**
  13136. * Define the vertical resolution off the screen.
  13137. */
  13138. vResolution: number;
  13139. /**
  13140. * Define the horizontal screen size.
  13141. */
  13142. hScreenSize: number;
  13143. /**
  13144. * Define the vertical screen size.
  13145. */
  13146. vScreenSize: number;
  13147. /**
  13148. * Define the vertical screen center position.
  13149. */
  13150. vScreenCenter: number;
  13151. /**
  13152. * Define the distance of the eyes to the screen.
  13153. */
  13154. eyeToScreenDistance: number;
  13155. /**
  13156. * Define the distance between both lenses
  13157. */
  13158. lensSeparationDistance: number;
  13159. /**
  13160. * Define the distance between both viewer's eyes.
  13161. */
  13162. interpupillaryDistance: number;
  13163. /**
  13164. * Define the distortion factor of the VR postprocess.
  13165. * Please, touch with care.
  13166. */
  13167. distortionK: number[];
  13168. /**
  13169. * Define the chromatic aberration correction factors for the VR post process.
  13170. */
  13171. chromaAbCorrection: number[];
  13172. /**
  13173. * Define the scale factor of the post process.
  13174. * The smaller the better but the slower.
  13175. */
  13176. postProcessScaleFactor: number;
  13177. /**
  13178. * Define an offset for the lens center.
  13179. */
  13180. lensCenterOffset: number;
  13181. /**
  13182. * Define if the current vr camera should compensate the distortion of the lense or not.
  13183. */
  13184. compensateDistortion: boolean;
  13185. /**
  13186. * Defines if multiview should be enabled when rendering (Default: false)
  13187. */
  13188. multiviewEnabled: boolean;
  13189. /**
  13190. * Gets the rendering aspect ratio based on the provided resolutions.
  13191. */
  13192. readonly aspectRatio: number;
  13193. /**
  13194. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  13195. */
  13196. readonly aspectRatioFov: number;
  13197. /**
  13198. * @hidden
  13199. */
  13200. readonly leftHMatrix: Matrix;
  13201. /**
  13202. * @hidden
  13203. */
  13204. readonly rightHMatrix: Matrix;
  13205. /**
  13206. * @hidden
  13207. */
  13208. readonly leftPreViewMatrix: Matrix;
  13209. /**
  13210. * @hidden
  13211. */
  13212. readonly rightPreViewMatrix: Matrix;
  13213. /**
  13214. * Get the default VRMetrics based on the most generic setup.
  13215. * @returns the default vr metrics
  13216. */
  13217. static GetDefault(): VRCameraMetrics;
  13218. }
  13219. }
  13220. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  13221. /** @hidden */
  13222. export var vrDistortionCorrectionPixelShader: {
  13223. name: string;
  13224. shader: string;
  13225. };
  13226. }
  13227. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  13228. import { Camera } from "babylonjs/Cameras/camera";
  13229. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  13230. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13231. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  13232. /**
  13233. * VRDistortionCorrectionPostProcess used for mobile VR
  13234. */
  13235. export class VRDistortionCorrectionPostProcess extends PostProcess {
  13236. private _isRightEye;
  13237. private _distortionFactors;
  13238. private _postProcessScaleFactor;
  13239. private _lensCenterOffset;
  13240. private _scaleIn;
  13241. private _scaleFactor;
  13242. private _lensCenter;
  13243. /**
  13244. * Initializes the VRDistortionCorrectionPostProcess
  13245. * @param name The name of the effect.
  13246. * @param camera The camera to apply the render pass to.
  13247. * @param isRightEye If this is for the right eye distortion
  13248. * @param vrMetrics All the required metrics for the VR camera
  13249. */
  13250. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  13251. }
  13252. /**
  13253. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13254. * This will not be used for webXR as it supports displaying texture arrays directly
  13255. */
  13256. export class VRMultiviewToSingleview extends PostProcess {
  13257. /**
  13258. * Initializes a VRMultiviewToSingleview
  13259. * @param name name of the post process
  13260. * @param camera camera to be applied to
  13261. * @param scaleFactor scaling factor to the size of the output texture
  13262. */
  13263. constructor(name: string, camera: Camera, scaleFactor: number);
  13264. }
  13265. }
  13266. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13267. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13268. import { Nullable } from "babylonjs/types";
  13269. import { Observable } from "babylonjs/Misc/observable";
  13270. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13271. import { Scene } from "babylonjs/scene";
  13272. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13273. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13274. import { Node } from "babylonjs/node";
  13275. import { Ray } from "babylonjs/Culling/ray";
  13276. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13277. /**
  13278. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13279. * IMPORTANT!! The data is right-hand data.
  13280. * @export
  13281. * @interface DevicePose
  13282. */
  13283. export interface DevicePose {
  13284. /**
  13285. * The position of the device, values in array are [x,y,z].
  13286. */
  13287. readonly position: Nullable<Float32Array>;
  13288. /**
  13289. * The linearVelocity of the device, values in array are [x,y,z].
  13290. */
  13291. readonly linearVelocity: Nullable<Float32Array>;
  13292. /**
  13293. * The linearAcceleration of the device, values in array are [x,y,z].
  13294. */
  13295. readonly linearAcceleration: Nullable<Float32Array>;
  13296. /**
  13297. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13298. */
  13299. readonly orientation: Nullable<Float32Array>;
  13300. /**
  13301. * The angularVelocity of the device, values in array are [x,y,z].
  13302. */
  13303. readonly angularVelocity: Nullable<Float32Array>;
  13304. /**
  13305. * The angularAcceleration of the device, values in array are [x,y,z].
  13306. */
  13307. readonly angularAcceleration: Nullable<Float32Array>;
  13308. }
  13309. /**
  13310. * Interface representing a pose controlled object in Babylon.
  13311. * A pose controlled object has both regular pose values as well as pose values
  13312. * from an external device such as a VR head mounted display
  13313. */
  13314. export interface PoseControlled {
  13315. /**
  13316. * The position of the object in babylon space.
  13317. */
  13318. position: Vector3;
  13319. /**
  13320. * The rotation quaternion of the object in babylon space.
  13321. */
  13322. rotationQuaternion: Quaternion;
  13323. /**
  13324. * The position of the device in babylon space.
  13325. */
  13326. devicePosition?: Vector3;
  13327. /**
  13328. * The rotation quaternion of the device in babylon space.
  13329. */
  13330. deviceRotationQuaternion: Quaternion;
  13331. /**
  13332. * The raw pose coming from the device.
  13333. */
  13334. rawPose: Nullable<DevicePose>;
  13335. /**
  13336. * The scale of the device to be used when translating from device space to babylon space.
  13337. */
  13338. deviceScaleFactor: number;
  13339. /**
  13340. * Updates the poseControlled values based on the input device pose.
  13341. * @param poseData the pose data to update the object with
  13342. */
  13343. updateFromDevice(poseData: DevicePose): void;
  13344. }
  13345. /**
  13346. * Set of options to customize the webVRCamera
  13347. */
  13348. export interface WebVROptions {
  13349. /**
  13350. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13351. */
  13352. trackPosition?: boolean;
  13353. /**
  13354. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13355. */
  13356. positionScale?: number;
  13357. /**
  13358. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13359. */
  13360. displayName?: string;
  13361. /**
  13362. * Should the native controller meshes be initialized. (default: true)
  13363. */
  13364. controllerMeshes?: boolean;
  13365. /**
  13366. * Creating a default HemiLight only on controllers. (default: true)
  13367. */
  13368. defaultLightingOnControllers?: boolean;
  13369. /**
  13370. * If you don't want to use the default VR button of the helper. (default: false)
  13371. */
  13372. useCustomVRButton?: boolean;
  13373. /**
  13374. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13375. */
  13376. customVRButton?: HTMLButtonElement;
  13377. /**
  13378. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13379. */
  13380. rayLength?: number;
  13381. /**
  13382. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13383. */
  13384. defaultHeight?: number;
  13385. /**
  13386. * If multiview should be used if availible (default: false)
  13387. */
  13388. useMultiview?: boolean;
  13389. }
  13390. /**
  13391. * This represents a WebVR camera.
  13392. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13393. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13394. */
  13395. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13396. private webVROptions;
  13397. /**
  13398. * @hidden
  13399. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13400. */
  13401. _vrDevice: any;
  13402. /**
  13403. * The rawPose of the vrDevice.
  13404. */
  13405. rawPose: Nullable<DevicePose>;
  13406. private _onVREnabled;
  13407. private _specsVersion;
  13408. private _attached;
  13409. private _frameData;
  13410. protected _descendants: Array<Node>;
  13411. private _deviceRoomPosition;
  13412. /** @hidden */
  13413. _deviceRoomRotationQuaternion: Quaternion;
  13414. private _standingMatrix;
  13415. /**
  13416. * Represents device position in babylon space.
  13417. */
  13418. devicePosition: Vector3;
  13419. /**
  13420. * Represents device rotation in babylon space.
  13421. */
  13422. deviceRotationQuaternion: Quaternion;
  13423. /**
  13424. * The scale of the device to be used when translating from device space to babylon space.
  13425. */
  13426. deviceScaleFactor: number;
  13427. private _deviceToWorld;
  13428. private _worldToDevice;
  13429. /**
  13430. * References to the webVR controllers for the vrDevice.
  13431. */
  13432. controllers: Array<WebVRController>;
  13433. /**
  13434. * Emits an event when a controller is attached.
  13435. */
  13436. onControllersAttachedObservable: Observable<WebVRController[]>;
  13437. /**
  13438. * Emits an event when a controller's mesh has been loaded;
  13439. */
  13440. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13441. /**
  13442. * Emits an event when the HMD's pose has been updated.
  13443. */
  13444. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13445. private _poseSet;
  13446. /**
  13447. * If the rig cameras be used as parent instead of this camera.
  13448. */
  13449. rigParenting: boolean;
  13450. private _lightOnControllers;
  13451. private _defaultHeight?;
  13452. /**
  13453. * Instantiates a WebVRFreeCamera.
  13454. * @param name The name of the WebVRFreeCamera
  13455. * @param position The starting anchor position for the camera
  13456. * @param scene The scene the camera belongs to
  13457. * @param webVROptions a set of customizable options for the webVRCamera
  13458. */
  13459. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13460. /**
  13461. * Gets the device distance from the ground in meters.
  13462. * @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.
  13463. */
  13464. deviceDistanceToRoomGround(): number;
  13465. /**
  13466. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13467. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13468. */
  13469. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13470. /**
  13471. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13472. * @returns A promise with a boolean set to if the standing matrix is supported.
  13473. */
  13474. useStandingMatrixAsync(): Promise<boolean>;
  13475. /**
  13476. * Disposes the camera
  13477. */
  13478. dispose(): void;
  13479. /**
  13480. * Gets a vrController by name.
  13481. * @param name The name of the controller to retreive
  13482. * @returns the controller matching the name specified or null if not found
  13483. */
  13484. getControllerByName(name: string): Nullable<WebVRController>;
  13485. private _leftController;
  13486. /**
  13487. * The controller corrisponding to the users left hand.
  13488. */
  13489. readonly leftController: Nullable<WebVRController>;
  13490. private _rightController;
  13491. /**
  13492. * The controller corrisponding to the users right hand.
  13493. */
  13494. readonly rightController: Nullable<WebVRController>;
  13495. /**
  13496. * Casts a ray forward from the vrCamera's gaze.
  13497. * @param length Length of the ray (default: 100)
  13498. * @returns the ray corrisponding to the gaze
  13499. */
  13500. getForwardRay(length?: number): Ray;
  13501. /**
  13502. * @hidden
  13503. * Updates the camera based on device's frame data
  13504. */
  13505. _checkInputs(): void;
  13506. /**
  13507. * Updates the poseControlled values based on the input device pose.
  13508. * @param poseData Pose coming from the device
  13509. */
  13510. updateFromDevice(poseData: DevicePose): void;
  13511. private _htmlElementAttached;
  13512. private _detachIfAttached;
  13513. /**
  13514. * WebVR's attach control will start broadcasting frames to the device.
  13515. * Note that in certain browsers (chrome for example) this function must be called
  13516. * within a user-interaction callback. Example:
  13517. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13518. *
  13519. * @param element html element to attach the vrDevice to
  13520. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13521. */
  13522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13523. /**
  13524. * Detaches the camera from the html element and disables VR
  13525. *
  13526. * @param element html element to detach from
  13527. */
  13528. detachControl(element: HTMLElement): void;
  13529. /**
  13530. * @returns the name of this class
  13531. */
  13532. getClassName(): string;
  13533. /**
  13534. * Calls resetPose on the vrDisplay
  13535. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13536. */
  13537. resetToCurrentRotation(): void;
  13538. /**
  13539. * @hidden
  13540. * Updates the rig cameras (left and right eye)
  13541. */
  13542. _updateRigCameras(): void;
  13543. private _workingVector;
  13544. private _oneVector;
  13545. private _workingMatrix;
  13546. private updateCacheCalled;
  13547. private _correctPositionIfNotTrackPosition;
  13548. /**
  13549. * @hidden
  13550. * Updates the cached values of the camera
  13551. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13552. */
  13553. _updateCache(ignoreParentClass?: boolean): void;
  13554. /**
  13555. * @hidden
  13556. * Get current device position in babylon world
  13557. */
  13558. _computeDevicePosition(): void;
  13559. /**
  13560. * Updates the current device position and rotation in the babylon world
  13561. */
  13562. update(): void;
  13563. /**
  13564. * @hidden
  13565. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13566. * @returns an identity matrix
  13567. */
  13568. _getViewMatrix(): Matrix;
  13569. private _tmpMatrix;
  13570. /**
  13571. * This function is called by the two RIG cameras.
  13572. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13573. * @hidden
  13574. */
  13575. _getWebVRViewMatrix(): Matrix;
  13576. /** @hidden */
  13577. _getWebVRProjectionMatrix(): Matrix;
  13578. private _onGamepadConnectedObserver;
  13579. private _onGamepadDisconnectedObserver;
  13580. private _updateCacheWhenTrackingDisabledObserver;
  13581. /**
  13582. * Initializes the controllers and their meshes
  13583. */
  13584. initControllers(): void;
  13585. }
  13586. }
  13587. declare module "babylonjs/PostProcesses/postProcess" {
  13588. import { Nullable } from "babylonjs/types";
  13589. import { SmartArray } from "babylonjs/Misc/smartArray";
  13590. import { Observable } from "babylonjs/Misc/observable";
  13591. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13592. import { Camera } from "babylonjs/Cameras/camera";
  13593. import { Effect } from "babylonjs/Materials/effect";
  13594. import "babylonjs/Shaders/postprocess.vertex";
  13595. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13596. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13597. import { Engine } from "babylonjs/Engines/engine";
  13598. /**
  13599. * Size options for a post process
  13600. */
  13601. export type PostProcessOptions = {
  13602. width: number;
  13603. height: number;
  13604. };
  13605. /**
  13606. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13607. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13608. */
  13609. export class PostProcess {
  13610. /** Name of the PostProcess. */
  13611. name: string;
  13612. /**
  13613. * Gets or sets the unique id of the post process
  13614. */
  13615. uniqueId: number;
  13616. /**
  13617. * Width of the texture to apply the post process on
  13618. */
  13619. width: number;
  13620. /**
  13621. * Height of the texture to apply the post process on
  13622. */
  13623. height: number;
  13624. /**
  13625. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13626. * @hidden
  13627. */
  13628. _outputTexture: Nullable<InternalTexture>;
  13629. /**
  13630. * Sampling mode used by the shader
  13631. * See https://doc.babylonjs.com/classes/3.1/texture
  13632. */
  13633. renderTargetSamplingMode: number;
  13634. /**
  13635. * Clear color to use when screen clearing
  13636. */
  13637. clearColor: Color4;
  13638. /**
  13639. * If the buffer needs to be cleared before applying the post process. (default: true)
  13640. * Should be set to false if shader will overwrite all previous pixels.
  13641. */
  13642. autoClear: boolean;
  13643. /**
  13644. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13645. */
  13646. alphaMode: number;
  13647. /**
  13648. * Sets the setAlphaBlendConstants of the babylon engine
  13649. */
  13650. alphaConstants: Color4;
  13651. /**
  13652. * Animations to be used for the post processing
  13653. */
  13654. animations: import("babylonjs/Animations/animation").Animation[];
  13655. /**
  13656. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13657. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13658. */
  13659. enablePixelPerfectMode: boolean;
  13660. /**
  13661. * Force the postprocess to be applied without taking in account viewport
  13662. */
  13663. forceFullscreenViewport: boolean;
  13664. /**
  13665. * List of inspectable custom properties (used by the Inspector)
  13666. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13667. */
  13668. inspectableCustomProperties: IInspectable[];
  13669. /**
  13670. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13671. *
  13672. * | Value | Type | Description |
  13673. * | ----- | ----------------------------------- | ----------- |
  13674. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13675. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13676. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13677. *
  13678. */
  13679. scaleMode: number;
  13680. /**
  13681. * Force textures to be a power of two (default: false)
  13682. */
  13683. alwaysForcePOT: boolean;
  13684. private _samples;
  13685. /**
  13686. * Number of sample textures (default: 1)
  13687. */
  13688. samples: number;
  13689. /**
  13690. * Modify the scale of the post process to be the same as the viewport (default: false)
  13691. */
  13692. adaptScaleToCurrentViewport: boolean;
  13693. private _camera;
  13694. private _scene;
  13695. private _engine;
  13696. private _options;
  13697. private _reusable;
  13698. private _textureType;
  13699. /**
  13700. * Smart array of input and output textures for the post process.
  13701. * @hidden
  13702. */
  13703. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13704. /**
  13705. * The index in _textures that corresponds to the output texture.
  13706. * @hidden
  13707. */
  13708. _currentRenderTextureInd: number;
  13709. private _effect;
  13710. private _samplers;
  13711. private _fragmentUrl;
  13712. private _vertexUrl;
  13713. private _parameters;
  13714. private _scaleRatio;
  13715. protected _indexParameters: any;
  13716. private _shareOutputWithPostProcess;
  13717. private _texelSize;
  13718. private _forcedOutputTexture;
  13719. /**
  13720. * Returns the fragment url or shader name used in the post process.
  13721. * @returns the fragment url or name in the shader store.
  13722. */
  13723. getEffectName(): string;
  13724. /**
  13725. * An event triggered when the postprocess is activated.
  13726. */
  13727. onActivateObservable: Observable<Camera>;
  13728. private _onActivateObserver;
  13729. /**
  13730. * A function that is added to the onActivateObservable
  13731. */
  13732. onActivate: Nullable<(camera: Camera) => void>;
  13733. /**
  13734. * An event triggered when the postprocess changes its size.
  13735. */
  13736. onSizeChangedObservable: Observable<PostProcess>;
  13737. private _onSizeChangedObserver;
  13738. /**
  13739. * A function that is added to the onSizeChangedObservable
  13740. */
  13741. onSizeChanged: (postProcess: PostProcess) => void;
  13742. /**
  13743. * An event triggered when the postprocess applies its effect.
  13744. */
  13745. onApplyObservable: Observable<Effect>;
  13746. private _onApplyObserver;
  13747. /**
  13748. * A function that is added to the onApplyObservable
  13749. */
  13750. onApply: (effect: Effect) => void;
  13751. /**
  13752. * An event triggered before rendering the postprocess
  13753. */
  13754. onBeforeRenderObservable: Observable<Effect>;
  13755. private _onBeforeRenderObserver;
  13756. /**
  13757. * A function that is added to the onBeforeRenderObservable
  13758. */
  13759. onBeforeRender: (effect: Effect) => void;
  13760. /**
  13761. * An event triggered after rendering the postprocess
  13762. */
  13763. onAfterRenderObservable: Observable<Effect>;
  13764. private _onAfterRenderObserver;
  13765. /**
  13766. * A function that is added to the onAfterRenderObservable
  13767. */
  13768. onAfterRender: (efect: Effect) => void;
  13769. /**
  13770. * 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
  13771. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13772. */
  13773. inputTexture: InternalTexture;
  13774. /**
  13775. * Gets the camera which post process is applied to.
  13776. * @returns The camera the post process is applied to.
  13777. */
  13778. getCamera(): Camera;
  13779. /**
  13780. * Gets the texel size of the postprocess.
  13781. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13782. */
  13783. readonly texelSize: Vector2;
  13784. /**
  13785. * Creates a new instance PostProcess
  13786. * @param name The name of the PostProcess.
  13787. * @param fragmentUrl The url of the fragment shader to be used.
  13788. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13789. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13790. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13791. * @param camera The camera to apply the render pass to.
  13792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13793. * @param engine The engine which the post process will be applied. (default: current engine)
  13794. * @param reusable If the post process can be reused on the same frame. (default: false)
  13795. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13796. * @param textureType Type of textures used when performing the post process. (default: 0)
  13797. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13798. * @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
  13799. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13800. */
  13801. constructor(
  13802. /** Name of the PostProcess. */
  13803. 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);
  13804. /**
  13805. * Gets a string idenfifying the name of the class
  13806. * @returns "PostProcess" string
  13807. */
  13808. getClassName(): string;
  13809. /**
  13810. * Gets the engine which this post process belongs to.
  13811. * @returns The engine the post process was enabled with.
  13812. */
  13813. getEngine(): Engine;
  13814. /**
  13815. * The effect that is created when initializing the post process.
  13816. * @returns The created effect corrisponding the the postprocess.
  13817. */
  13818. getEffect(): Effect;
  13819. /**
  13820. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13821. * @param postProcess The post process to share the output with.
  13822. * @returns This post process.
  13823. */
  13824. shareOutputWith(postProcess: PostProcess): PostProcess;
  13825. /**
  13826. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13827. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13828. */
  13829. useOwnOutput(): void;
  13830. /**
  13831. * Updates the effect with the current post process compile time values and recompiles the shader.
  13832. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13833. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13834. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13835. * @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
  13836. * @param onCompiled Called when the shader has been compiled.
  13837. * @param onError Called if there is an error when compiling a shader.
  13838. */
  13839. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13840. /**
  13841. * The post process is reusable if it can be used multiple times within one frame.
  13842. * @returns If the post process is reusable
  13843. */
  13844. isReusable(): boolean;
  13845. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13846. markTextureDirty(): void;
  13847. /**
  13848. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13849. * 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.
  13850. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13851. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13852. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13853. * @returns The target texture that was bound to be written to.
  13854. */
  13855. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13856. /**
  13857. * If the post process is supported.
  13858. */
  13859. readonly isSupported: boolean;
  13860. /**
  13861. * The aspect ratio of the output texture.
  13862. */
  13863. readonly aspectRatio: number;
  13864. /**
  13865. * Get a value indicating if the post-process is ready to be used
  13866. * @returns true if the post-process is ready (shader is compiled)
  13867. */
  13868. isReady(): boolean;
  13869. /**
  13870. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13871. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13872. */
  13873. apply(): Nullable<Effect>;
  13874. private _disposeTextures;
  13875. /**
  13876. * Disposes the post process.
  13877. * @param camera The camera to dispose the post process on.
  13878. */
  13879. dispose(camera?: Camera): void;
  13880. }
  13881. }
  13882. declare module "babylonjs/PostProcesses/postProcessManager" {
  13883. import { Nullable } from "babylonjs/types";
  13884. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13885. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13886. import { Scene } from "babylonjs/scene";
  13887. /**
  13888. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13889. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13890. */
  13891. export class PostProcessManager {
  13892. private _scene;
  13893. private _indexBuffer;
  13894. private _vertexBuffers;
  13895. /**
  13896. * Creates a new instance PostProcess
  13897. * @param scene The scene that the post process is associated with.
  13898. */
  13899. constructor(scene: Scene);
  13900. private _prepareBuffers;
  13901. private _buildIndexBuffer;
  13902. /**
  13903. * Rebuilds the vertex buffers of the manager.
  13904. * @hidden
  13905. */
  13906. _rebuild(): void;
  13907. /**
  13908. * Prepares a frame to be run through a post process.
  13909. * @param sourceTexture The input texture to the post procesess. (default: null)
  13910. * @param postProcesses An array of post processes to be run. (default: null)
  13911. * @returns True if the post processes were able to be run.
  13912. * @hidden
  13913. */
  13914. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13915. /**
  13916. * Manually render a set of post processes to a texture.
  13917. * @param postProcesses An array of post processes to be run.
  13918. * @param targetTexture The target texture to render to.
  13919. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13920. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13921. * @param lodLevel defines which lod of the texture to render to
  13922. */
  13923. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13924. /**
  13925. * Finalize the result of the output of the postprocesses.
  13926. * @param doNotPresent If true the result will not be displayed to the screen.
  13927. * @param targetTexture The target texture to render to.
  13928. * @param faceIndex The index of the face to bind the target texture to.
  13929. * @param postProcesses The array of post processes to render.
  13930. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13931. * @hidden
  13932. */
  13933. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13934. /**
  13935. * Disposes of the post process manager.
  13936. */
  13937. dispose(): void;
  13938. }
  13939. }
  13940. declare module "babylonjs/Layers/layerSceneComponent" {
  13941. import { Scene } from "babylonjs/scene";
  13942. import { ISceneComponent } from "babylonjs/sceneComponent";
  13943. import { Layer } from "babylonjs/Layers/layer";
  13944. module "babylonjs/abstractScene" {
  13945. interface AbstractScene {
  13946. /**
  13947. * The list of layers (background and foreground) of the scene
  13948. */
  13949. layers: Array<Layer>;
  13950. }
  13951. }
  13952. /**
  13953. * Defines the layer scene component responsible to manage any layers
  13954. * in a given scene.
  13955. */
  13956. export class LayerSceneComponent implements ISceneComponent {
  13957. /**
  13958. * The component name helpfull to identify the component in the list of scene components.
  13959. */
  13960. readonly name: string;
  13961. /**
  13962. * The scene the component belongs to.
  13963. */
  13964. scene: Scene;
  13965. private _engine;
  13966. /**
  13967. * Creates a new instance of the component for the given scene
  13968. * @param scene Defines the scene to register the component in
  13969. */
  13970. constructor(scene: Scene);
  13971. /**
  13972. * Registers the component in a given scene
  13973. */
  13974. register(): void;
  13975. /**
  13976. * Rebuilds the elements related to this component in case of
  13977. * context lost for instance.
  13978. */
  13979. rebuild(): void;
  13980. /**
  13981. * Disposes the component and the associated ressources.
  13982. */
  13983. dispose(): void;
  13984. private _draw;
  13985. private _drawCameraPredicate;
  13986. private _drawCameraBackground;
  13987. private _drawCameraForeground;
  13988. private _drawRenderTargetPredicate;
  13989. private _drawRenderTargetBackground;
  13990. private _drawRenderTargetForeground;
  13991. }
  13992. }
  13993. declare module "babylonjs/Shaders/layer.fragment" {
  13994. /** @hidden */
  13995. export var layerPixelShader: {
  13996. name: string;
  13997. shader: string;
  13998. };
  13999. }
  14000. declare module "babylonjs/Shaders/layer.vertex" {
  14001. /** @hidden */
  14002. export var layerVertexShader: {
  14003. name: string;
  14004. shader: string;
  14005. };
  14006. }
  14007. declare module "babylonjs/Layers/layer" {
  14008. import { Observable } from "babylonjs/Misc/observable";
  14009. import { Nullable } from "babylonjs/types";
  14010. import { Scene } from "babylonjs/scene";
  14011. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14012. import { Texture } from "babylonjs/Materials/Textures/texture";
  14013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14014. import "babylonjs/Shaders/layer.fragment";
  14015. import "babylonjs/Shaders/layer.vertex";
  14016. /**
  14017. * This represents a full screen 2d layer.
  14018. * This can be useful to display a picture in the background of your scene for instance.
  14019. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14020. */
  14021. export class Layer {
  14022. /**
  14023. * Define the name of the layer.
  14024. */
  14025. name: string;
  14026. /**
  14027. * Define the texture the layer should display.
  14028. */
  14029. texture: Nullable<Texture>;
  14030. /**
  14031. * Is the layer in background or foreground.
  14032. */
  14033. isBackground: boolean;
  14034. /**
  14035. * Define the color of the layer (instead of texture).
  14036. */
  14037. color: Color4;
  14038. /**
  14039. * Define the scale of the layer in order to zoom in out of the texture.
  14040. */
  14041. scale: Vector2;
  14042. /**
  14043. * Define an offset for the layer in order to shift the texture.
  14044. */
  14045. offset: Vector2;
  14046. /**
  14047. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14048. */
  14049. alphaBlendingMode: number;
  14050. /**
  14051. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14052. * Alpha test will not mix with the background color in case of transparency.
  14053. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14054. */
  14055. alphaTest: boolean;
  14056. /**
  14057. * Define a mask to restrict the layer to only some of the scene cameras.
  14058. */
  14059. layerMask: number;
  14060. /**
  14061. * Define the list of render target the layer is visible into.
  14062. */
  14063. renderTargetTextures: RenderTargetTexture[];
  14064. /**
  14065. * Define if the layer is only used in renderTarget or if it also
  14066. * renders in the main frame buffer of the canvas.
  14067. */
  14068. renderOnlyInRenderTargetTextures: boolean;
  14069. private _scene;
  14070. private _vertexBuffers;
  14071. private _indexBuffer;
  14072. private _effect;
  14073. private _alphaTestEffect;
  14074. /**
  14075. * An event triggered when the layer is disposed.
  14076. */
  14077. onDisposeObservable: Observable<Layer>;
  14078. private _onDisposeObserver;
  14079. /**
  14080. * Back compatibility with callback before the onDisposeObservable existed.
  14081. * The set callback will be triggered when the layer has been disposed.
  14082. */
  14083. onDispose: () => void;
  14084. /**
  14085. * An event triggered before rendering the scene
  14086. */
  14087. onBeforeRenderObservable: Observable<Layer>;
  14088. private _onBeforeRenderObserver;
  14089. /**
  14090. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14091. * The set callback will be triggered just before rendering the layer.
  14092. */
  14093. onBeforeRender: () => void;
  14094. /**
  14095. * An event triggered after rendering the scene
  14096. */
  14097. onAfterRenderObservable: Observable<Layer>;
  14098. private _onAfterRenderObserver;
  14099. /**
  14100. * Back compatibility with callback before the onAfterRenderObservable existed.
  14101. * The set callback will be triggered just after rendering the layer.
  14102. */
  14103. onAfterRender: () => void;
  14104. /**
  14105. * Instantiates a new layer.
  14106. * This represents a full screen 2d layer.
  14107. * This can be useful to display a picture in the background of your scene for instance.
  14108. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14109. * @param name Define the name of the layer in the scene
  14110. * @param imgUrl Define the url of the texture to display in the layer
  14111. * @param scene Define the scene the layer belongs to
  14112. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14113. * @param color Defines a color for the layer
  14114. */
  14115. constructor(
  14116. /**
  14117. * Define the name of the layer.
  14118. */
  14119. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14120. private _createIndexBuffer;
  14121. /** @hidden */
  14122. _rebuild(): void;
  14123. /**
  14124. * Renders the layer in the scene.
  14125. */
  14126. render(): void;
  14127. /**
  14128. * Disposes and releases the associated ressources.
  14129. */
  14130. dispose(): void;
  14131. }
  14132. }
  14133. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14134. import { Scene } from "babylonjs/scene";
  14135. import { ISceneComponent } from "babylonjs/sceneComponent";
  14136. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14137. module "babylonjs/abstractScene" {
  14138. interface AbstractScene {
  14139. /**
  14140. * The list of procedural textures added to the scene
  14141. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14142. */
  14143. proceduralTextures: Array<ProceduralTexture>;
  14144. }
  14145. }
  14146. /**
  14147. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14148. * in a given scene.
  14149. */
  14150. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14151. /**
  14152. * The component name helpfull to identify the component in the list of scene components.
  14153. */
  14154. readonly name: string;
  14155. /**
  14156. * The scene the component belongs to.
  14157. */
  14158. scene: Scene;
  14159. /**
  14160. * Creates a new instance of the component for the given scene
  14161. * @param scene Defines the scene to register the component in
  14162. */
  14163. constructor(scene: Scene);
  14164. /**
  14165. * Registers the component in a given scene
  14166. */
  14167. register(): void;
  14168. /**
  14169. * Rebuilds the elements related to this component in case of
  14170. * context lost for instance.
  14171. */
  14172. rebuild(): void;
  14173. /**
  14174. * Disposes the component and the associated ressources.
  14175. */
  14176. dispose(): void;
  14177. private _beforeClear;
  14178. }
  14179. }
  14180. declare module "babylonjs/Shaders/procedural.vertex" {
  14181. /** @hidden */
  14182. export var proceduralVertexShader: {
  14183. name: string;
  14184. shader: string;
  14185. };
  14186. }
  14187. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14188. import { Observable } from "babylonjs/Misc/observable";
  14189. import { Nullable } from "babylonjs/types";
  14190. import { Scene } from "babylonjs/scene";
  14191. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14192. import { Effect } from "babylonjs/Materials/effect";
  14193. import { Texture } from "babylonjs/Materials/Textures/texture";
  14194. import "babylonjs/Shaders/procedural.vertex";
  14195. /**
  14196. * 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.
  14197. * This is the base class of any Procedural texture and contains most of the shareable code.
  14198. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14199. */
  14200. export class ProceduralTexture extends Texture {
  14201. isCube: boolean;
  14202. /**
  14203. * Define if the texture is enabled or not (disabled texture will not render)
  14204. */
  14205. isEnabled: boolean;
  14206. /**
  14207. * Define if the texture must be cleared before rendering (default is true)
  14208. */
  14209. autoClear: boolean;
  14210. /**
  14211. * Callback called when the texture is generated
  14212. */
  14213. onGenerated: () => void;
  14214. /**
  14215. * Event raised when the texture is generated
  14216. */
  14217. onGeneratedObservable: Observable<ProceduralTexture>;
  14218. /** @hidden */
  14219. _generateMipMaps: boolean;
  14220. /** @hidden **/
  14221. _effect: Effect;
  14222. /** @hidden */
  14223. _textures: {
  14224. [key: string]: Texture;
  14225. };
  14226. private _size;
  14227. private _currentRefreshId;
  14228. private _refreshRate;
  14229. private _vertexBuffers;
  14230. private _indexBuffer;
  14231. private _uniforms;
  14232. private _samplers;
  14233. private _fragment;
  14234. private _floats;
  14235. private _ints;
  14236. private _floatsArrays;
  14237. private _colors3;
  14238. private _colors4;
  14239. private _vectors2;
  14240. private _vectors3;
  14241. private _matrices;
  14242. private _fallbackTexture;
  14243. private _fallbackTextureUsed;
  14244. private _engine;
  14245. private _cachedDefines;
  14246. private _contentUpdateId;
  14247. private _contentData;
  14248. /**
  14249. * Instantiates a new procedural texture.
  14250. * 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.
  14251. * This is the base class of any Procedural texture and contains most of the shareable code.
  14252. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14253. * @param name Define the name of the texture
  14254. * @param size Define the size of the texture to create
  14255. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14256. * @param scene Define the scene the texture belongs to
  14257. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14258. * @param generateMipMaps Define if the texture should creates mip maps or not
  14259. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14260. */
  14261. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14262. /**
  14263. * The effect that is created when initializing the post process.
  14264. * @returns The created effect corrisponding the the postprocess.
  14265. */
  14266. getEffect(): Effect;
  14267. /**
  14268. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14269. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14270. */
  14271. getContent(): Nullable<ArrayBufferView>;
  14272. private _createIndexBuffer;
  14273. /** @hidden */
  14274. _rebuild(): void;
  14275. /**
  14276. * Resets the texture in order to recreate its associated resources.
  14277. * This can be called in case of context loss
  14278. */
  14279. reset(): void;
  14280. protected _getDefines(): string;
  14281. /**
  14282. * Is the texture ready to be used ? (rendered at least once)
  14283. * @returns true if ready, otherwise, false.
  14284. */
  14285. isReady(): boolean;
  14286. /**
  14287. * Resets the refresh counter of the texture and start bak from scratch.
  14288. * Could be useful to regenerate the texture if it is setup to render only once.
  14289. */
  14290. resetRefreshCounter(): void;
  14291. /**
  14292. * Set the fragment shader to use in order to render the texture.
  14293. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14294. */
  14295. setFragment(fragment: any): void;
  14296. /**
  14297. * Define the refresh rate of the texture or the rendering frequency.
  14298. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14299. */
  14300. refreshRate: number;
  14301. /** @hidden */
  14302. _shouldRender(): boolean;
  14303. /**
  14304. * Get the size the texture is rendering at.
  14305. * @returns the size (texture is always squared)
  14306. */
  14307. getRenderSize(): number;
  14308. /**
  14309. * Resize the texture to new value.
  14310. * @param size Define the new size the texture should have
  14311. * @param generateMipMaps Define whether the new texture should create mip maps
  14312. */
  14313. resize(size: number, generateMipMaps: boolean): void;
  14314. private _checkUniform;
  14315. /**
  14316. * Set a texture in the shader program used to render.
  14317. * @param name Define the name of the uniform samplers as defined in the shader
  14318. * @param texture Define the texture to bind to this sampler
  14319. * @return the texture itself allowing "fluent" like uniform updates
  14320. */
  14321. setTexture(name: string, texture: Texture): ProceduralTexture;
  14322. /**
  14323. * Set a float in the shader.
  14324. * @param name Define the name of the uniform as defined in the shader
  14325. * @param value Define the value to give to the uniform
  14326. * @return the texture itself allowing "fluent" like uniform updates
  14327. */
  14328. setFloat(name: string, value: number): ProceduralTexture;
  14329. /**
  14330. * Set a int in the shader.
  14331. * @param name Define the name of the uniform as defined in the shader
  14332. * @param value Define the value to give to the uniform
  14333. * @return the texture itself allowing "fluent" like uniform updates
  14334. */
  14335. setInt(name: string, value: number): ProceduralTexture;
  14336. /**
  14337. * Set an array of floats in the shader.
  14338. * @param name Define the name of the uniform as defined in the shader
  14339. * @param value Define the value to give to the uniform
  14340. * @return the texture itself allowing "fluent" like uniform updates
  14341. */
  14342. setFloats(name: string, value: number[]): ProceduralTexture;
  14343. /**
  14344. * Set a vec3 in the shader from a Color3.
  14345. * @param name Define the name of the uniform as defined in the shader
  14346. * @param value Define the value to give to the uniform
  14347. * @return the texture itself allowing "fluent" like uniform updates
  14348. */
  14349. setColor3(name: string, value: Color3): ProceduralTexture;
  14350. /**
  14351. * Set a vec4 in the shader from a Color4.
  14352. * @param name Define the name of the uniform as defined in the shader
  14353. * @param value Define the value to give to the uniform
  14354. * @return the texture itself allowing "fluent" like uniform updates
  14355. */
  14356. setColor4(name: string, value: Color4): ProceduralTexture;
  14357. /**
  14358. * Set a vec2 in the shader from a Vector2.
  14359. * @param name Define the name of the uniform as defined in the shader
  14360. * @param value Define the value to give to the uniform
  14361. * @return the texture itself allowing "fluent" like uniform updates
  14362. */
  14363. setVector2(name: string, value: Vector2): ProceduralTexture;
  14364. /**
  14365. * Set a vec3 in the shader from a Vector3.
  14366. * @param name Define the name of the uniform as defined in the shader
  14367. * @param value Define the value to give to the uniform
  14368. * @return the texture itself allowing "fluent" like uniform updates
  14369. */
  14370. setVector3(name: string, value: Vector3): ProceduralTexture;
  14371. /**
  14372. * Set a mat4 in the shader from a MAtrix.
  14373. * @param name Define the name of the uniform as defined in the shader
  14374. * @param value Define the value to give to the uniform
  14375. * @return the texture itself allowing "fluent" like uniform updates
  14376. */
  14377. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14378. /**
  14379. * Render the texture to its associated render target.
  14380. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14381. */
  14382. render(useCameraPostProcess?: boolean): void;
  14383. /**
  14384. * Clone the texture.
  14385. * @returns the cloned texture
  14386. */
  14387. clone(): ProceduralTexture;
  14388. /**
  14389. * Dispose the texture and release its asoociated resources.
  14390. */
  14391. dispose(): void;
  14392. }
  14393. }
  14394. declare module "babylonjs/Particles/baseParticleSystem" {
  14395. import { Nullable } from "babylonjs/types";
  14396. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14398. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14399. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14400. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14401. import { Scene } from "babylonjs/scene";
  14402. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14403. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14404. import { Texture } from "babylonjs/Materials/Textures/texture";
  14405. import { Animation } from "babylonjs/Animations/animation";
  14406. /**
  14407. * This represents the base class for particle system in Babylon.
  14408. * 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.
  14409. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14410. * @example https://doc.babylonjs.com/babylon101/particles
  14411. */
  14412. export class BaseParticleSystem {
  14413. /**
  14414. * Source color is added to the destination color without alpha affecting the result
  14415. */
  14416. static BLENDMODE_ONEONE: number;
  14417. /**
  14418. * Blend current color and particle color using particle’s alpha
  14419. */
  14420. static BLENDMODE_STANDARD: number;
  14421. /**
  14422. * Add current color and particle color multiplied by particle’s alpha
  14423. */
  14424. static BLENDMODE_ADD: number;
  14425. /**
  14426. * Multiply current color with particle color
  14427. */
  14428. static BLENDMODE_MULTIPLY: number;
  14429. /**
  14430. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14431. */
  14432. static BLENDMODE_MULTIPLYADD: number;
  14433. /**
  14434. * List of animations used by the particle system.
  14435. */
  14436. animations: Animation[];
  14437. /**
  14438. * The id of the Particle system.
  14439. */
  14440. id: string;
  14441. /**
  14442. * The friendly name of the Particle system.
  14443. */
  14444. name: string;
  14445. /**
  14446. * The rendering group used by the Particle system to chose when to render.
  14447. */
  14448. renderingGroupId: number;
  14449. /**
  14450. * The emitter represents the Mesh or position we are attaching the particle system to.
  14451. */
  14452. emitter: Nullable<AbstractMesh | Vector3>;
  14453. /**
  14454. * The maximum number of particles to emit per frame
  14455. */
  14456. emitRate: number;
  14457. /**
  14458. * If you want to launch only a few particles at once, that can be done, as well.
  14459. */
  14460. manualEmitCount: number;
  14461. /**
  14462. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14463. */
  14464. updateSpeed: number;
  14465. /**
  14466. * The amount of time the particle system is running (depends of the overall update speed).
  14467. */
  14468. targetStopDuration: number;
  14469. /**
  14470. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14471. */
  14472. disposeOnStop: boolean;
  14473. /**
  14474. * Minimum power of emitting particles.
  14475. */
  14476. minEmitPower: number;
  14477. /**
  14478. * Maximum power of emitting particles.
  14479. */
  14480. maxEmitPower: number;
  14481. /**
  14482. * Minimum life time of emitting particles.
  14483. */
  14484. minLifeTime: number;
  14485. /**
  14486. * Maximum life time of emitting particles.
  14487. */
  14488. maxLifeTime: number;
  14489. /**
  14490. * Minimum Size of emitting particles.
  14491. */
  14492. minSize: number;
  14493. /**
  14494. * Maximum Size of emitting particles.
  14495. */
  14496. maxSize: number;
  14497. /**
  14498. * Minimum scale of emitting particles on X axis.
  14499. */
  14500. minScaleX: number;
  14501. /**
  14502. * Maximum scale of emitting particles on X axis.
  14503. */
  14504. maxScaleX: number;
  14505. /**
  14506. * Minimum scale of emitting particles on Y axis.
  14507. */
  14508. minScaleY: number;
  14509. /**
  14510. * Maximum scale of emitting particles on Y axis.
  14511. */
  14512. maxScaleY: number;
  14513. /**
  14514. * Gets or sets the minimal initial rotation in radians.
  14515. */
  14516. minInitialRotation: number;
  14517. /**
  14518. * Gets or sets the maximal initial rotation in radians.
  14519. */
  14520. maxInitialRotation: number;
  14521. /**
  14522. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14523. */
  14524. minAngularSpeed: number;
  14525. /**
  14526. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14527. */
  14528. maxAngularSpeed: number;
  14529. /**
  14530. * The texture used to render each particle. (this can be a spritesheet)
  14531. */
  14532. particleTexture: Nullable<Texture>;
  14533. /**
  14534. * The layer mask we are rendering the particles through.
  14535. */
  14536. layerMask: number;
  14537. /**
  14538. * This can help using your own shader to render the particle system.
  14539. * The according effect will be created
  14540. */
  14541. customShader: any;
  14542. /**
  14543. * By default particle system starts as soon as they are created. This prevents the
  14544. * automatic start to happen and let you decide when to start emitting particles.
  14545. */
  14546. preventAutoStart: boolean;
  14547. private _noiseTexture;
  14548. /**
  14549. * Gets or sets a texture used to add random noise to particle positions
  14550. */
  14551. noiseTexture: Nullable<ProceduralTexture>;
  14552. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14553. noiseStrength: Vector3;
  14554. /**
  14555. * Callback triggered when the particle animation is ending.
  14556. */
  14557. onAnimationEnd: Nullable<() => void>;
  14558. /**
  14559. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14560. */
  14561. blendMode: number;
  14562. /**
  14563. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14564. * to override the particles.
  14565. */
  14566. forceDepthWrite: boolean;
  14567. /** 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 */
  14568. preWarmCycles: number;
  14569. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14570. preWarmStepOffset: number;
  14571. /**
  14572. * 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)
  14573. */
  14574. spriteCellChangeSpeed: number;
  14575. /**
  14576. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14577. */
  14578. startSpriteCellID: number;
  14579. /**
  14580. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14581. */
  14582. endSpriteCellID: number;
  14583. /**
  14584. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14585. */
  14586. spriteCellWidth: number;
  14587. /**
  14588. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14589. */
  14590. spriteCellHeight: number;
  14591. /**
  14592. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14593. */
  14594. spriteRandomStartCell: boolean;
  14595. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14596. translationPivot: Vector2;
  14597. /** @hidden */
  14598. protected _isAnimationSheetEnabled: boolean;
  14599. /**
  14600. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14601. */
  14602. beginAnimationOnStart: boolean;
  14603. /**
  14604. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14605. */
  14606. beginAnimationFrom: number;
  14607. /**
  14608. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14609. */
  14610. beginAnimationTo: number;
  14611. /**
  14612. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14613. */
  14614. beginAnimationLoop: boolean;
  14615. /**
  14616. * Gets or sets a world offset applied to all particles
  14617. */
  14618. worldOffset: Vector3;
  14619. /**
  14620. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14621. */
  14622. isAnimationSheetEnabled: boolean;
  14623. /**
  14624. * Get hosting scene
  14625. * @returns the scene
  14626. */
  14627. getScene(): Scene;
  14628. /**
  14629. * You can use gravity if you want to give an orientation to your particles.
  14630. */
  14631. gravity: Vector3;
  14632. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14633. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14634. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14635. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14636. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14637. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14638. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14639. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14640. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14641. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14642. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14643. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14644. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14645. /**
  14646. * Defines the delay in milliseconds before starting the system (0 by default)
  14647. */
  14648. startDelay: number;
  14649. /**
  14650. * Gets the current list of drag gradients.
  14651. * You must use addDragGradient and removeDragGradient to udpate this list
  14652. * @returns the list of drag gradients
  14653. */
  14654. getDragGradients(): Nullable<Array<FactorGradient>>;
  14655. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14656. limitVelocityDamping: number;
  14657. /**
  14658. * Gets the current list of limit velocity gradients.
  14659. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14660. * @returns the list of limit velocity gradients
  14661. */
  14662. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14663. /**
  14664. * Gets the current list of color gradients.
  14665. * You must use addColorGradient and removeColorGradient to udpate this list
  14666. * @returns the list of color gradients
  14667. */
  14668. getColorGradients(): Nullable<Array<ColorGradient>>;
  14669. /**
  14670. * Gets the current list of size gradients.
  14671. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14672. * @returns the list of size gradients
  14673. */
  14674. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14675. /**
  14676. * Gets the current list of color remap gradients.
  14677. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14678. * @returns the list of color remap gradients
  14679. */
  14680. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14681. /**
  14682. * Gets the current list of alpha remap gradients.
  14683. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14684. * @returns the list of alpha remap gradients
  14685. */
  14686. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14687. /**
  14688. * Gets the current list of life time gradients.
  14689. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14690. * @returns the list of life time gradients
  14691. */
  14692. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14693. /**
  14694. * Gets the current list of angular speed gradients.
  14695. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14696. * @returns the list of angular speed gradients
  14697. */
  14698. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14699. /**
  14700. * Gets the current list of velocity gradients.
  14701. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14702. * @returns the list of velocity gradients
  14703. */
  14704. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14705. /**
  14706. * Gets the current list of start size gradients.
  14707. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14708. * @returns the list of start size gradients
  14709. */
  14710. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14711. /**
  14712. * Gets the current list of emit rate gradients.
  14713. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14714. * @returns the list of emit rate gradients
  14715. */
  14716. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14717. /**
  14718. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14719. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14720. */
  14721. direction1: Vector3;
  14722. /**
  14723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14724. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14725. */
  14726. direction2: Vector3;
  14727. /**
  14728. * 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.
  14729. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14730. */
  14731. minEmitBox: Vector3;
  14732. /**
  14733. * 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.
  14734. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14735. */
  14736. maxEmitBox: Vector3;
  14737. /**
  14738. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14739. */
  14740. color1: Color4;
  14741. /**
  14742. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14743. */
  14744. color2: Color4;
  14745. /**
  14746. * Color the particle will have at the end of its lifetime
  14747. */
  14748. colorDead: Color4;
  14749. /**
  14750. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14751. */
  14752. textureMask: Color4;
  14753. /**
  14754. * The particle emitter type defines the emitter used by the particle system.
  14755. * It can be for example box, sphere, or cone...
  14756. */
  14757. particleEmitterType: IParticleEmitterType;
  14758. /** @hidden */
  14759. _isSubEmitter: boolean;
  14760. /**
  14761. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14762. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14763. */
  14764. billboardMode: number;
  14765. protected _isBillboardBased: boolean;
  14766. /**
  14767. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14768. */
  14769. isBillboardBased: boolean;
  14770. /**
  14771. * The scene the particle system belongs to.
  14772. */
  14773. protected _scene: Scene;
  14774. /**
  14775. * Local cache of defines for image processing.
  14776. */
  14777. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14778. /**
  14779. * Default configuration related to image processing available in the standard Material.
  14780. */
  14781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14782. /**
  14783. * Gets the image processing configuration used either in this material.
  14784. */
  14785. /**
  14786. * Sets the Default image processing configuration used either in the this material.
  14787. *
  14788. * If sets to null, the scene one is in use.
  14789. */
  14790. imageProcessingConfiguration: ImageProcessingConfiguration;
  14791. /**
  14792. * Attaches a new image processing configuration to the Standard Material.
  14793. * @param configuration
  14794. */
  14795. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14796. /** @hidden */
  14797. protected _reset(): void;
  14798. /** @hidden */
  14799. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14800. /**
  14801. * Instantiates a particle system.
  14802. * 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.
  14803. * @param name The name of the particle system
  14804. */
  14805. constructor(name: string);
  14806. /**
  14807. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14810. * @returns the emitter
  14811. */
  14812. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14813. /**
  14814. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14815. * @param radius The radius of the hemisphere to emit from
  14816. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14817. * @returns the emitter
  14818. */
  14819. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14820. /**
  14821. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14822. * @param radius The radius of the sphere to emit from
  14823. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14824. * @returns the emitter
  14825. */
  14826. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14827. /**
  14828. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14829. * @param radius The radius of the sphere to emit from
  14830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14832. * @returns the emitter
  14833. */
  14834. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14835. /**
  14836. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14837. * @param radius The radius of the emission cylinder
  14838. * @param height The height of the emission cylinder
  14839. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14840. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14841. * @returns the emitter
  14842. */
  14843. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14844. /**
  14845. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14846. * @param radius The radius of the cylinder to emit from
  14847. * @param height The height of the emission cylinder
  14848. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14851. * @returns the emitter
  14852. */
  14853. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14854. /**
  14855. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14856. * @param radius The radius of the cone to emit from
  14857. * @param angle The base angle of the cone
  14858. * @returns the emitter
  14859. */
  14860. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14861. /**
  14862. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14865. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14866. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14867. * @returns the emitter
  14868. */
  14869. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14870. }
  14871. }
  14872. declare module "babylonjs/Particles/subEmitter" {
  14873. import { Scene } from "babylonjs/scene";
  14874. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14875. /**
  14876. * Type of sub emitter
  14877. */
  14878. export enum SubEmitterType {
  14879. /**
  14880. * Attached to the particle over it's lifetime
  14881. */
  14882. ATTACHED = 0,
  14883. /**
  14884. * Created when the particle dies
  14885. */
  14886. END = 1
  14887. }
  14888. /**
  14889. * Sub emitter class used to emit particles from an existing particle
  14890. */
  14891. export class SubEmitter {
  14892. /**
  14893. * the particle system to be used by the sub emitter
  14894. */
  14895. particleSystem: ParticleSystem;
  14896. /**
  14897. * Type of the submitter (Default: END)
  14898. */
  14899. type: SubEmitterType;
  14900. /**
  14901. * 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)
  14902. * Note: This only is supported when using an emitter of type Mesh
  14903. */
  14904. inheritDirection: boolean;
  14905. /**
  14906. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14907. */
  14908. inheritedVelocityAmount: number;
  14909. /**
  14910. * Creates a sub emitter
  14911. * @param particleSystem the particle system to be used by the sub emitter
  14912. */
  14913. constructor(
  14914. /**
  14915. * the particle system to be used by the sub emitter
  14916. */
  14917. particleSystem: ParticleSystem);
  14918. /**
  14919. * Clones the sub emitter
  14920. * @returns the cloned sub emitter
  14921. */
  14922. clone(): SubEmitter;
  14923. /**
  14924. * Serialize current object to a JSON object
  14925. * @returns the serialized object
  14926. */
  14927. serialize(): any;
  14928. /** @hidden */
  14929. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14930. /**
  14931. * Creates a new SubEmitter from a serialized JSON version
  14932. * @param serializationObject defines the JSON object to read from
  14933. * @param scene defines the hosting scene
  14934. * @param rootUrl defines the rootUrl for data loading
  14935. * @returns a new SubEmitter
  14936. */
  14937. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14938. /** Release associated resources */
  14939. dispose(): void;
  14940. }
  14941. }
  14942. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14943. /** @hidden */
  14944. export var clipPlaneFragmentDeclaration: {
  14945. name: string;
  14946. shader: string;
  14947. };
  14948. }
  14949. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14950. /** @hidden */
  14951. export var imageProcessingDeclaration: {
  14952. name: string;
  14953. shader: string;
  14954. };
  14955. }
  14956. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14957. /** @hidden */
  14958. export var imageProcessingFunctions: {
  14959. name: string;
  14960. shader: string;
  14961. };
  14962. }
  14963. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14964. /** @hidden */
  14965. export var clipPlaneFragment: {
  14966. name: string;
  14967. shader: string;
  14968. };
  14969. }
  14970. declare module "babylonjs/Shaders/particles.fragment" {
  14971. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14972. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14973. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14974. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14975. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14976. /** @hidden */
  14977. export var particlesPixelShader: {
  14978. name: string;
  14979. shader: string;
  14980. };
  14981. }
  14982. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14983. /** @hidden */
  14984. export var clipPlaneVertexDeclaration: {
  14985. name: string;
  14986. shader: string;
  14987. };
  14988. }
  14989. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14990. /** @hidden */
  14991. export var clipPlaneVertex: {
  14992. name: string;
  14993. shader: string;
  14994. };
  14995. }
  14996. declare module "babylonjs/Shaders/particles.vertex" {
  14997. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14998. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14999. /** @hidden */
  15000. export var particlesVertexShader: {
  15001. name: string;
  15002. shader: string;
  15003. };
  15004. }
  15005. declare module "babylonjs/Particles/particleSystem" {
  15006. import { Nullable } from "babylonjs/types";
  15007. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15008. import { Observable } from "babylonjs/Misc/observable";
  15009. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15010. import { Effect } from "babylonjs/Materials/effect";
  15011. import { Scene, IDisposable } from "babylonjs/scene";
  15012. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15013. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15014. import { Particle } from "babylonjs/Particles/particle";
  15015. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15016. import "babylonjs/Shaders/particles.fragment";
  15017. import "babylonjs/Shaders/particles.vertex";
  15018. /**
  15019. * This represents a particle system in Babylon.
  15020. * 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.
  15021. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15022. * @example https://doc.babylonjs.com/babylon101/particles
  15023. */
  15024. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15025. /**
  15026. * Billboard mode will only apply to Y axis
  15027. */
  15028. static readonly BILLBOARDMODE_Y: number;
  15029. /**
  15030. * Billboard mode will apply to all axes
  15031. */
  15032. static readonly BILLBOARDMODE_ALL: number;
  15033. /**
  15034. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15035. */
  15036. static readonly BILLBOARDMODE_STRETCHED: number;
  15037. /**
  15038. * This function can be defined to provide custom update for active particles.
  15039. * This function will be called instead of regular update (age, position, color, etc.).
  15040. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15041. */
  15042. updateFunction: (particles: Particle[]) => void;
  15043. private _emitterWorldMatrix;
  15044. /**
  15045. * This function can be defined to specify initial direction for every new particle.
  15046. * It by default use the emitterType defined function
  15047. */
  15048. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15049. /**
  15050. * This function can be defined to specify initial position for every new particle.
  15051. * It by default use the emitterType defined function
  15052. */
  15053. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15054. /**
  15055. * @hidden
  15056. */
  15057. _inheritedVelocityOffset: Vector3;
  15058. /**
  15059. * An event triggered when the system is disposed
  15060. */
  15061. onDisposeObservable: Observable<ParticleSystem>;
  15062. private _onDisposeObserver;
  15063. /**
  15064. * Sets a callback that will be triggered when the system is disposed
  15065. */
  15066. onDispose: () => void;
  15067. private _particles;
  15068. private _epsilon;
  15069. private _capacity;
  15070. private _stockParticles;
  15071. private _newPartsExcess;
  15072. private _vertexData;
  15073. private _vertexBuffer;
  15074. private _vertexBuffers;
  15075. private _spriteBuffer;
  15076. private _indexBuffer;
  15077. private _effect;
  15078. private _customEffect;
  15079. private _cachedDefines;
  15080. private _scaledColorStep;
  15081. private _colorDiff;
  15082. private _scaledDirection;
  15083. private _scaledGravity;
  15084. private _currentRenderId;
  15085. private _alive;
  15086. private _useInstancing;
  15087. private _started;
  15088. private _stopped;
  15089. private _actualFrame;
  15090. private _scaledUpdateSpeed;
  15091. private _vertexBufferSize;
  15092. /** @hidden */
  15093. _currentEmitRateGradient: Nullable<FactorGradient>;
  15094. /** @hidden */
  15095. _currentEmitRate1: number;
  15096. /** @hidden */
  15097. _currentEmitRate2: number;
  15098. /** @hidden */
  15099. _currentStartSizeGradient: Nullable<FactorGradient>;
  15100. /** @hidden */
  15101. _currentStartSize1: number;
  15102. /** @hidden */
  15103. _currentStartSize2: number;
  15104. private readonly _rawTextureWidth;
  15105. private _rampGradientsTexture;
  15106. private _useRampGradients;
  15107. /** Gets or sets a boolean indicating that ramp gradients must be used
  15108. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15109. */
  15110. useRampGradients: boolean;
  15111. /**
  15112. * 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.
  15113. * 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: [])
  15114. */
  15115. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15116. private _subEmitters;
  15117. /**
  15118. * @hidden
  15119. * If the particle systems emitter should be disposed when the particle system is disposed
  15120. */
  15121. _disposeEmitterOnDispose: boolean;
  15122. /**
  15123. * The current active Sub-systems, this property is used by the root particle system only.
  15124. */
  15125. activeSubSystems: Array<ParticleSystem>;
  15126. private _rootParticleSystem;
  15127. /**
  15128. * Gets the current list of active particles
  15129. */
  15130. readonly particles: Particle[];
  15131. /**
  15132. * Returns the string "ParticleSystem"
  15133. * @returns a string containing the class name
  15134. */
  15135. getClassName(): string;
  15136. /**
  15137. * Instantiates a particle system.
  15138. * 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.
  15139. * @param name The name of the particle system
  15140. * @param capacity The max number of particles alive at the same time
  15141. * @param scene The scene the particle system belongs to
  15142. * @param customEffect a custom effect used to change the way particles are rendered by default
  15143. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15144. * @param epsilon Offset used to render the particles
  15145. */
  15146. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15147. private _addFactorGradient;
  15148. private _removeFactorGradient;
  15149. /**
  15150. * Adds a new life time gradient
  15151. * @param gradient defines the gradient to use (between 0 and 1)
  15152. * @param factor defines the life time factor to affect to the specified gradient
  15153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15154. * @returns the current particle system
  15155. */
  15156. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15157. /**
  15158. * Remove a specific life time gradient
  15159. * @param gradient defines the gradient to remove
  15160. * @returns the current particle system
  15161. */
  15162. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15163. /**
  15164. * Adds a new size gradient
  15165. * @param gradient defines the gradient to use (between 0 and 1)
  15166. * @param factor defines the size factor to affect to the specified gradient
  15167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15168. * @returns the current particle system
  15169. */
  15170. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15171. /**
  15172. * Remove a specific size gradient
  15173. * @param gradient defines the gradient to remove
  15174. * @returns the current particle system
  15175. */
  15176. removeSizeGradient(gradient: number): IParticleSystem;
  15177. /**
  15178. * Adds a new color remap gradient
  15179. * @param gradient defines the gradient to use (between 0 and 1)
  15180. * @param min defines the color remap minimal range
  15181. * @param max defines the color remap maximal range
  15182. * @returns the current particle system
  15183. */
  15184. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15185. /**
  15186. * Remove a specific color remap gradient
  15187. * @param gradient defines the gradient to remove
  15188. * @returns the current particle system
  15189. */
  15190. removeColorRemapGradient(gradient: number): IParticleSystem;
  15191. /**
  15192. * Adds a new alpha remap gradient
  15193. * @param gradient defines the gradient to use (between 0 and 1)
  15194. * @param min defines the alpha remap minimal range
  15195. * @param max defines the alpha remap maximal range
  15196. * @returns the current particle system
  15197. */
  15198. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15199. /**
  15200. * Remove a specific alpha remap gradient
  15201. * @param gradient defines the gradient to remove
  15202. * @returns the current particle system
  15203. */
  15204. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15205. /**
  15206. * Adds a new angular speed gradient
  15207. * @param gradient defines the gradient to use (between 0 and 1)
  15208. * @param factor defines the angular speed to affect to the specified gradient
  15209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15210. * @returns the current particle system
  15211. */
  15212. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15213. /**
  15214. * Remove a specific angular speed gradient
  15215. * @param gradient defines the gradient to remove
  15216. * @returns the current particle system
  15217. */
  15218. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15219. /**
  15220. * Adds a new velocity gradient
  15221. * @param gradient defines the gradient to use (between 0 and 1)
  15222. * @param factor defines the velocity to affect to the specified gradient
  15223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15224. * @returns the current particle system
  15225. */
  15226. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15227. /**
  15228. * Remove a specific velocity gradient
  15229. * @param gradient defines the gradient to remove
  15230. * @returns the current particle system
  15231. */
  15232. removeVelocityGradient(gradient: number): IParticleSystem;
  15233. /**
  15234. * Adds a new limit velocity gradient
  15235. * @param gradient defines the gradient to use (between 0 and 1)
  15236. * @param factor defines the limit velocity value to affect to the specified gradient
  15237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15238. * @returns the current particle system
  15239. */
  15240. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15241. /**
  15242. * Remove a specific limit velocity gradient
  15243. * @param gradient defines the gradient to remove
  15244. * @returns the current particle system
  15245. */
  15246. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15247. /**
  15248. * Adds a new drag gradient
  15249. * @param gradient defines the gradient to use (between 0 and 1)
  15250. * @param factor defines the drag value to affect to the specified gradient
  15251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15252. * @returns the current particle system
  15253. */
  15254. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15255. /**
  15256. * Remove a specific drag gradient
  15257. * @param gradient defines the gradient to remove
  15258. * @returns the current particle system
  15259. */
  15260. removeDragGradient(gradient: number): IParticleSystem;
  15261. /**
  15262. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15263. * @param gradient defines the gradient to use (between 0 and 1)
  15264. * @param factor defines the emit rate value to affect to the specified gradient
  15265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15266. * @returns the current particle system
  15267. */
  15268. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15269. /**
  15270. * Remove a specific emit rate gradient
  15271. * @param gradient defines the gradient to remove
  15272. * @returns the current particle system
  15273. */
  15274. removeEmitRateGradient(gradient: number): IParticleSystem;
  15275. /**
  15276. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15277. * @param gradient defines the gradient to use (between 0 and 1)
  15278. * @param factor defines the start size value to affect to the specified gradient
  15279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15280. * @returns the current particle system
  15281. */
  15282. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15283. /**
  15284. * Remove a specific start size gradient
  15285. * @param gradient defines the gradient to remove
  15286. * @returns the current particle system
  15287. */
  15288. removeStartSizeGradient(gradient: number): IParticleSystem;
  15289. private _createRampGradientTexture;
  15290. /**
  15291. * Gets the current list of ramp gradients.
  15292. * You must use addRampGradient and removeRampGradient to udpate this list
  15293. * @returns the list of ramp gradients
  15294. */
  15295. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15296. /**
  15297. * Adds a new ramp gradient used to remap particle colors
  15298. * @param gradient defines the gradient to use (between 0 and 1)
  15299. * @param color defines the color to affect to the specified gradient
  15300. * @returns the current particle system
  15301. */
  15302. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15303. /**
  15304. * Remove a specific ramp gradient
  15305. * @param gradient defines the gradient to remove
  15306. * @returns the current particle system
  15307. */
  15308. removeRampGradient(gradient: number): ParticleSystem;
  15309. /**
  15310. * Adds a new color gradient
  15311. * @param gradient defines the gradient to use (between 0 and 1)
  15312. * @param color1 defines the color to affect to the specified gradient
  15313. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15314. * @returns this particle system
  15315. */
  15316. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15317. /**
  15318. * Remove a specific color gradient
  15319. * @param gradient defines the gradient to remove
  15320. * @returns this particle system
  15321. */
  15322. removeColorGradient(gradient: number): IParticleSystem;
  15323. private _fetchR;
  15324. protected _reset(): void;
  15325. private _resetEffect;
  15326. private _createVertexBuffers;
  15327. private _createIndexBuffer;
  15328. /**
  15329. * Gets the maximum number of particles active at the same time.
  15330. * @returns The max number of active particles.
  15331. */
  15332. getCapacity(): number;
  15333. /**
  15334. * Gets whether there are still active particles in the system.
  15335. * @returns True if it is alive, otherwise false.
  15336. */
  15337. isAlive(): boolean;
  15338. /**
  15339. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15340. * @returns True if it has been started, otherwise false.
  15341. */
  15342. isStarted(): boolean;
  15343. private _prepareSubEmitterInternalArray;
  15344. /**
  15345. * Starts the particle system and begins to emit
  15346. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15347. */
  15348. start(delay?: number): void;
  15349. /**
  15350. * Stops the particle system.
  15351. * @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.
  15352. */
  15353. stop(stopSubEmitters?: boolean): void;
  15354. /**
  15355. * Remove all active particles
  15356. */
  15357. reset(): void;
  15358. /**
  15359. * @hidden (for internal use only)
  15360. */
  15361. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15362. /**
  15363. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15364. * Its lifetime will start back at 0.
  15365. */
  15366. recycleParticle: (particle: Particle) => void;
  15367. private _stopSubEmitters;
  15368. private _createParticle;
  15369. private _removeFromRoot;
  15370. private _emitFromParticle;
  15371. private _update;
  15372. /** @hidden */
  15373. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15374. /** @hidden */
  15375. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15376. /** @hidden */
  15377. private _getEffect;
  15378. /**
  15379. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15380. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15381. */
  15382. animate(preWarmOnly?: boolean): void;
  15383. private _appendParticleVertices;
  15384. /**
  15385. * Rebuilds the particle system.
  15386. */
  15387. rebuild(): void;
  15388. /**
  15389. * Is this system ready to be used/rendered
  15390. * @return true if the system is ready
  15391. */
  15392. isReady(): boolean;
  15393. private _render;
  15394. /**
  15395. * Renders the particle system in its current state.
  15396. * @returns the current number of particles
  15397. */
  15398. render(): number;
  15399. /**
  15400. * Disposes the particle system and free the associated resources
  15401. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15402. */
  15403. dispose(disposeTexture?: boolean): void;
  15404. /**
  15405. * Clones the particle system.
  15406. * @param name The name of the cloned object
  15407. * @param newEmitter The new emitter to use
  15408. * @returns the cloned particle system
  15409. */
  15410. clone(name: string, newEmitter: any): ParticleSystem;
  15411. /**
  15412. * Serializes the particle system to a JSON object.
  15413. * @returns the JSON object
  15414. */
  15415. serialize(): any;
  15416. /** @hidden */
  15417. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15418. /** @hidden */
  15419. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15420. /**
  15421. * Parses a JSON object to create a particle system.
  15422. * @param parsedParticleSystem The JSON object to parse
  15423. * @param scene The scene to create the particle system in
  15424. * @param rootUrl The root url to use to load external dependencies like texture
  15425. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15426. * @returns the Parsed particle system
  15427. */
  15428. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15429. }
  15430. }
  15431. declare module "babylonjs/Particles/particle" {
  15432. import { Nullable } from "babylonjs/types";
  15433. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15434. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15435. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15436. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15437. /**
  15438. * A particle represents one of the element emitted by a particle system.
  15439. * This is mainly define by its coordinates, direction, velocity and age.
  15440. */
  15441. export class Particle {
  15442. /**
  15443. * The particle system the particle belongs to.
  15444. */
  15445. particleSystem: ParticleSystem;
  15446. private static _Count;
  15447. /**
  15448. * Unique ID of the particle
  15449. */
  15450. id: number;
  15451. /**
  15452. * The world position of the particle in the scene.
  15453. */
  15454. position: Vector3;
  15455. /**
  15456. * The world direction of the particle in the scene.
  15457. */
  15458. direction: Vector3;
  15459. /**
  15460. * The color of the particle.
  15461. */
  15462. color: Color4;
  15463. /**
  15464. * The color change of the particle per step.
  15465. */
  15466. colorStep: Color4;
  15467. /**
  15468. * Defines how long will the life of the particle be.
  15469. */
  15470. lifeTime: number;
  15471. /**
  15472. * The current age of the particle.
  15473. */
  15474. age: number;
  15475. /**
  15476. * The current size of the particle.
  15477. */
  15478. size: number;
  15479. /**
  15480. * The current scale of the particle.
  15481. */
  15482. scale: Vector2;
  15483. /**
  15484. * The current angle of the particle.
  15485. */
  15486. angle: number;
  15487. /**
  15488. * Defines how fast is the angle changing.
  15489. */
  15490. angularSpeed: number;
  15491. /**
  15492. * Defines the cell index used by the particle to be rendered from a sprite.
  15493. */
  15494. cellIndex: number;
  15495. /**
  15496. * The information required to support color remapping
  15497. */
  15498. remapData: Vector4;
  15499. /** @hidden */
  15500. _randomCellOffset?: number;
  15501. /** @hidden */
  15502. _initialDirection: Nullable<Vector3>;
  15503. /** @hidden */
  15504. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15505. /** @hidden */
  15506. _initialStartSpriteCellID: number;
  15507. /** @hidden */
  15508. _initialEndSpriteCellID: number;
  15509. /** @hidden */
  15510. _currentColorGradient: Nullable<ColorGradient>;
  15511. /** @hidden */
  15512. _currentColor1: Color4;
  15513. /** @hidden */
  15514. _currentColor2: Color4;
  15515. /** @hidden */
  15516. _currentSizeGradient: Nullable<FactorGradient>;
  15517. /** @hidden */
  15518. _currentSize1: number;
  15519. /** @hidden */
  15520. _currentSize2: number;
  15521. /** @hidden */
  15522. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15523. /** @hidden */
  15524. _currentAngularSpeed1: number;
  15525. /** @hidden */
  15526. _currentAngularSpeed2: number;
  15527. /** @hidden */
  15528. _currentVelocityGradient: Nullable<FactorGradient>;
  15529. /** @hidden */
  15530. _currentVelocity1: number;
  15531. /** @hidden */
  15532. _currentVelocity2: number;
  15533. /** @hidden */
  15534. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15535. /** @hidden */
  15536. _currentLimitVelocity1: number;
  15537. /** @hidden */
  15538. _currentLimitVelocity2: number;
  15539. /** @hidden */
  15540. _currentDragGradient: Nullable<FactorGradient>;
  15541. /** @hidden */
  15542. _currentDrag1: number;
  15543. /** @hidden */
  15544. _currentDrag2: number;
  15545. /** @hidden */
  15546. _randomNoiseCoordinates1: Vector3;
  15547. /** @hidden */
  15548. _randomNoiseCoordinates2: Vector3;
  15549. /**
  15550. * Creates a new instance Particle
  15551. * @param particleSystem the particle system the particle belongs to
  15552. */
  15553. constructor(
  15554. /**
  15555. * The particle system the particle belongs to.
  15556. */
  15557. particleSystem: ParticleSystem);
  15558. private updateCellInfoFromSystem;
  15559. /**
  15560. * Defines how the sprite cell index is updated for the particle
  15561. */
  15562. updateCellIndex(): void;
  15563. /** @hidden */
  15564. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15565. /** @hidden */
  15566. _inheritParticleInfoToSubEmitters(): void;
  15567. /** @hidden */
  15568. _reset(): void;
  15569. /**
  15570. * Copy the properties of particle to another one.
  15571. * @param other the particle to copy the information to.
  15572. */
  15573. copyTo(other: Particle): void;
  15574. }
  15575. }
  15576. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15577. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15578. import { Effect } from "babylonjs/Materials/effect";
  15579. import { Particle } from "babylonjs/Particles/particle";
  15580. /**
  15581. * Particle emitter represents a volume emitting particles.
  15582. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15583. */
  15584. export interface IParticleEmitterType {
  15585. /**
  15586. * Called by the particle System when the direction is computed for the created particle.
  15587. * @param worldMatrix is the world matrix of the particle system
  15588. * @param directionToUpdate is the direction vector to update with the result
  15589. * @param particle is the particle we are computed the direction for
  15590. */
  15591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15592. /**
  15593. * Called by the particle System when the position is computed for the created particle.
  15594. * @param worldMatrix is the world matrix of the particle system
  15595. * @param positionToUpdate is the position vector to update with the result
  15596. * @param particle is the particle we are computed the position for
  15597. */
  15598. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15599. /**
  15600. * Clones the current emitter and returns a copy of it
  15601. * @returns the new emitter
  15602. */
  15603. clone(): IParticleEmitterType;
  15604. /**
  15605. * Called by the GPUParticleSystem to setup the update shader
  15606. * @param effect defines the update shader
  15607. */
  15608. applyToShader(effect: Effect): void;
  15609. /**
  15610. * Returns a string to use to update the GPU particles update shader
  15611. * @returns the effect defines string
  15612. */
  15613. getEffectDefines(): string;
  15614. /**
  15615. * Returns a string representing the class name
  15616. * @returns a string containing the class name
  15617. */
  15618. getClassName(): string;
  15619. /**
  15620. * Serializes the particle system to a JSON object.
  15621. * @returns the JSON object
  15622. */
  15623. serialize(): any;
  15624. /**
  15625. * Parse properties from a JSON object
  15626. * @param serializationObject defines the JSON object
  15627. */
  15628. parse(serializationObject: any): void;
  15629. }
  15630. }
  15631. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15632. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15633. import { Effect } from "babylonjs/Materials/effect";
  15634. import { Particle } from "babylonjs/Particles/particle";
  15635. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15636. /**
  15637. * Particle emitter emitting particles from the inside of a box.
  15638. * It emits the particles randomly between 2 given directions.
  15639. */
  15640. export class BoxParticleEmitter implements IParticleEmitterType {
  15641. /**
  15642. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15643. */
  15644. direction1: Vector3;
  15645. /**
  15646. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15647. */
  15648. direction2: Vector3;
  15649. /**
  15650. * 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.
  15651. */
  15652. minEmitBox: Vector3;
  15653. /**
  15654. * 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.
  15655. */
  15656. maxEmitBox: Vector3;
  15657. /**
  15658. * Creates a new instance BoxParticleEmitter
  15659. */
  15660. constructor();
  15661. /**
  15662. * Called by the particle System when the direction is computed for the created particle.
  15663. * @param worldMatrix is the world matrix of the particle system
  15664. * @param directionToUpdate is the direction vector to update with the result
  15665. * @param particle is the particle we are computed the direction for
  15666. */
  15667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15668. /**
  15669. * Called by the particle System when the position is computed for the created particle.
  15670. * @param worldMatrix is the world matrix of the particle system
  15671. * @param positionToUpdate is the position vector to update with the result
  15672. * @param particle is the particle we are computed the position for
  15673. */
  15674. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15675. /**
  15676. * Clones the current emitter and returns a copy of it
  15677. * @returns the new emitter
  15678. */
  15679. clone(): BoxParticleEmitter;
  15680. /**
  15681. * Called by the GPUParticleSystem to setup the update shader
  15682. * @param effect defines the update shader
  15683. */
  15684. applyToShader(effect: Effect): void;
  15685. /**
  15686. * Returns a string to use to update the GPU particles update shader
  15687. * @returns a string containng the defines string
  15688. */
  15689. getEffectDefines(): string;
  15690. /**
  15691. * Returns the string "BoxParticleEmitter"
  15692. * @returns a string containing the class name
  15693. */
  15694. getClassName(): string;
  15695. /**
  15696. * Serializes the particle system to a JSON object.
  15697. * @returns the JSON object
  15698. */
  15699. serialize(): any;
  15700. /**
  15701. * Parse properties from a JSON object
  15702. * @param serializationObject defines the JSON object
  15703. */
  15704. parse(serializationObject: any): void;
  15705. }
  15706. }
  15707. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15708. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15709. import { Effect } from "babylonjs/Materials/effect";
  15710. import { Particle } from "babylonjs/Particles/particle";
  15711. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15712. /**
  15713. * Particle emitter emitting particles from the inside of a cone.
  15714. * It emits the particles alongside the cone volume from the base to the particle.
  15715. * The emission direction might be randomized.
  15716. */
  15717. export class ConeParticleEmitter implements IParticleEmitterType {
  15718. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15719. directionRandomizer: number;
  15720. private _radius;
  15721. private _angle;
  15722. private _height;
  15723. /**
  15724. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15725. */
  15726. radiusRange: number;
  15727. /**
  15728. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15729. */
  15730. heightRange: number;
  15731. /**
  15732. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15733. */
  15734. emitFromSpawnPointOnly: boolean;
  15735. /**
  15736. * Gets or sets the radius of the emission cone
  15737. */
  15738. radius: number;
  15739. /**
  15740. * Gets or sets the angle of the emission cone
  15741. */
  15742. angle: number;
  15743. private _buildHeight;
  15744. /**
  15745. * Creates a new instance ConeParticleEmitter
  15746. * @param radius the radius of the emission cone (1 by default)
  15747. * @param angle the cone base angle (PI by default)
  15748. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15749. */
  15750. constructor(radius?: number, angle?: number,
  15751. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15752. directionRandomizer?: number);
  15753. /**
  15754. * Called by the particle System when the direction is computed for the created particle.
  15755. * @param worldMatrix is the world matrix of the particle system
  15756. * @param directionToUpdate is the direction vector to update with the result
  15757. * @param particle is the particle we are computed the direction for
  15758. */
  15759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15760. /**
  15761. * Called by the particle System when the position is computed for the created particle.
  15762. * @param worldMatrix is the world matrix of the particle system
  15763. * @param positionToUpdate is the position vector to update with the result
  15764. * @param particle is the particle we are computed the position for
  15765. */
  15766. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15767. /**
  15768. * Clones the current emitter and returns a copy of it
  15769. * @returns the new emitter
  15770. */
  15771. clone(): ConeParticleEmitter;
  15772. /**
  15773. * Called by the GPUParticleSystem to setup the update shader
  15774. * @param effect defines the update shader
  15775. */
  15776. applyToShader(effect: Effect): void;
  15777. /**
  15778. * Returns a string to use to update the GPU particles update shader
  15779. * @returns a string containng the defines string
  15780. */
  15781. getEffectDefines(): string;
  15782. /**
  15783. * Returns the string "ConeParticleEmitter"
  15784. * @returns a string containing the class name
  15785. */
  15786. getClassName(): string;
  15787. /**
  15788. * Serializes the particle system to a JSON object.
  15789. * @returns the JSON object
  15790. */
  15791. serialize(): any;
  15792. /**
  15793. * Parse properties from a JSON object
  15794. * @param serializationObject defines the JSON object
  15795. */
  15796. parse(serializationObject: any): void;
  15797. }
  15798. }
  15799. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15800. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15801. import { Effect } from "babylonjs/Materials/effect";
  15802. import { Particle } from "babylonjs/Particles/particle";
  15803. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15804. /**
  15805. * Particle emitter emitting particles from the inside of a cylinder.
  15806. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15807. */
  15808. export class CylinderParticleEmitter implements IParticleEmitterType {
  15809. /**
  15810. * The radius of the emission cylinder.
  15811. */
  15812. radius: number;
  15813. /**
  15814. * The height of the emission cylinder.
  15815. */
  15816. height: number;
  15817. /**
  15818. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15819. */
  15820. radiusRange: number;
  15821. /**
  15822. * How much to randomize the particle direction [0-1].
  15823. */
  15824. directionRandomizer: number;
  15825. /**
  15826. * Creates a new instance CylinderParticleEmitter
  15827. * @param radius the radius of the emission cylinder (1 by default)
  15828. * @param height the height of the emission cylinder (1 by default)
  15829. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15830. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15831. */
  15832. constructor(
  15833. /**
  15834. * The radius of the emission cylinder.
  15835. */
  15836. radius?: number,
  15837. /**
  15838. * The height of the emission cylinder.
  15839. */
  15840. height?: number,
  15841. /**
  15842. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15843. */
  15844. radiusRange?: number,
  15845. /**
  15846. * How much to randomize the particle direction [0-1].
  15847. */
  15848. directionRandomizer?: number);
  15849. /**
  15850. * Called by the particle System when the direction is computed for the created particle.
  15851. * @param worldMatrix is the world matrix of the particle system
  15852. * @param directionToUpdate is the direction vector to update with the result
  15853. * @param particle is the particle we are computed the direction for
  15854. */
  15855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15856. /**
  15857. * Called by the particle System when the position is computed for the created particle.
  15858. * @param worldMatrix is the world matrix of the particle system
  15859. * @param positionToUpdate is the position vector to update with the result
  15860. * @param particle is the particle we are computed the position for
  15861. */
  15862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15863. /**
  15864. * Clones the current emitter and returns a copy of it
  15865. * @returns the new emitter
  15866. */
  15867. clone(): CylinderParticleEmitter;
  15868. /**
  15869. * Called by the GPUParticleSystem to setup the update shader
  15870. * @param effect defines the update shader
  15871. */
  15872. applyToShader(effect: Effect): void;
  15873. /**
  15874. * Returns a string to use to update the GPU particles update shader
  15875. * @returns a string containng the defines string
  15876. */
  15877. getEffectDefines(): string;
  15878. /**
  15879. * Returns the string "CylinderParticleEmitter"
  15880. * @returns a string containing the class name
  15881. */
  15882. getClassName(): string;
  15883. /**
  15884. * Serializes the particle system to a JSON object.
  15885. * @returns the JSON object
  15886. */
  15887. serialize(): any;
  15888. /**
  15889. * Parse properties from a JSON object
  15890. * @param serializationObject defines the JSON object
  15891. */
  15892. parse(serializationObject: any): void;
  15893. }
  15894. /**
  15895. * Particle emitter emitting particles from the inside of a cylinder.
  15896. * It emits the particles randomly between two vectors.
  15897. */
  15898. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15899. /**
  15900. * The min limit of the emission direction.
  15901. */
  15902. direction1: Vector3;
  15903. /**
  15904. * The max limit of the emission direction.
  15905. */
  15906. direction2: Vector3;
  15907. /**
  15908. * Creates a new instance CylinderDirectedParticleEmitter
  15909. * @param radius the radius of the emission cylinder (1 by default)
  15910. * @param height the height of the emission cylinder (1 by default)
  15911. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15912. * @param direction1 the min limit of the emission direction (up vector by default)
  15913. * @param direction2 the max limit of the emission direction (up vector by default)
  15914. */
  15915. constructor(radius?: number, height?: number, radiusRange?: number,
  15916. /**
  15917. * The min limit of the emission direction.
  15918. */
  15919. direction1?: Vector3,
  15920. /**
  15921. * The max limit of the emission direction.
  15922. */
  15923. direction2?: Vector3);
  15924. /**
  15925. * Called by the particle System when the direction is computed for the created particle.
  15926. * @param worldMatrix is the world matrix of the particle system
  15927. * @param directionToUpdate is the direction vector to update with the result
  15928. * @param particle is the particle we are computed the direction for
  15929. */
  15930. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15931. /**
  15932. * Clones the current emitter and returns a copy of it
  15933. * @returns the new emitter
  15934. */
  15935. clone(): CylinderDirectedParticleEmitter;
  15936. /**
  15937. * Called by the GPUParticleSystem to setup the update shader
  15938. * @param effect defines the update shader
  15939. */
  15940. applyToShader(effect: Effect): void;
  15941. /**
  15942. * Returns a string to use to update the GPU particles update shader
  15943. * @returns a string containng the defines string
  15944. */
  15945. getEffectDefines(): string;
  15946. /**
  15947. * Returns the string "CylinderDirectedParticleEmitter"
  15948. * @returns a string containing the class name
  15949. */
  15950. getClassName(): string;
  15951. /**
  15952. * Serializes the particle system to a JSON object.
  15953. * @returns the JSON object
  15954. */
  15955. serialize(): any;
  15956. /**
  15957. * Parse properties from a JSON object
  15958. * @param serializationObject defines the JSON object
  15959. */
  15960. parse(serializationObject: any): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15964. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15965. import { Effect } from "babylonjs/Materials/effect";
  15966. import { Particle } from "babylonjs/Particles/particle";
  15967. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15968. /**
  15969. * Particle emitter emitting particles from the inside of a hemisphere.
  15970. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15971. */
  15972. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15973. /**
  15974. * The radius of the emission hemisphere.
  15975. */
  15976. radius: number;
  15977. /**
  15978. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15979. */
  15980. radiusRange: number;
  15981. /**
  15982. * How much to randomize the particle direction [0-1].
  15983. */
  15984. directionRandomizer: number;
  15985. /**
  15986. * Creates a new instance HemisphericParticleEmitter
  15987. * @param radius the radius of the emission hemisphere (1 by default)
  15988. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15989. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15990. */
  15991. constructor(
  15992. /**
  15993. * The radius of the emission hemisphere.
  15994. */
  15995. radius?: number,
  15996. /**
  15997. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15998. */
  15999. radiusRange?: number,
  16000. /**
  16001. * How much to randomize the particle direction [0-1].
  16002. */
  16003. directionRandomizer?: number);
  16004. /**
  16005. * Called by the particle System when the direction is computed for the created particle.
  16006. * @param worldMatrix is the world matrix of the particle system
  16007. * @param directionToUpdate is the direction vector to update with the result
  16008. * @param particle is the particle we are computed the direction for
  16009. */
  16010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16011. /**
  16012. * Called by the particle System when the position is computed for the created particle.
  16013. * @param worldMatrix is the world matrix of the particle system
  16014. * @param positionToUpdate is the position vector to update with the result
  16015. * @param particle is the particle we are computed the position for
  16016. */
  16017. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16018. /**
  16019. * Clones the current emitter and returns a copy of it
  16020. * @returns the new emitter
  16021. */
  16022. clone(): HemisphericParticleEmitter;
  16023. /**
  16024. * Called by the GPUParticleSystem to setup the update shader
  16025. * @param effect defines the update shader
  16026. */
  16027. applyToShader(effect: Effect): void;
  16028. /**
  16029. * Returns a string to use to update the GPU particles update shader
  16030. * @returns a string containng the defines string
  16031. */
  16032. getEffectDefines(): string;
  16033. /**
  16034. * Returns the string "HemisphericParticleEmitter"
  16035. * @returns a string containing the class name
  16036. */
  16037. getClassName(): string;
  16038. /**
  16039. * Serializes the particle system to a JSON object.
  16040. * @returns the JSON object
  16041. */
  16042. serialize(): any;
  16043. /**
  16044. * Parse properties from a JSON object
  16045. * @param serializationObject defines the JSON object
  16046. */
  16047. parse(serializationObject: any): void;
  16048. }
  16049. }
  16050. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16051. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16052. import { Effect } from "babylonjs/Materials/effect";
  16053. import { Particle } from "babylonjs/Particles/particle";
  16054. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16055. /**
  16056. * Particle emitter emitting particles from a point.
  16057. * It emits the particles randomly between 2 given directions.
  16058. */
  16059. export class PointParticleEmitter implements IParticleEmitterType {
  16060. /**
  16061. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16062. */
  16063. direction1: Vector3;
  16064. /**
  16065. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16066. */
  16067. direction2: Vector3;
  16068. /**
  16069. * Creates a new instance PointParticleEmitter
  16070. */
  16071. constructor();
  16072. /**
  16073. * Called by the particle System when the direction is computed for the created particle.
  16074. * @param worldMatrix is the world matrix of the particle system
  16075. * @param directionToUpdate is the direction vector to update with the result
  16076. * @param particle is the particle we are computed the direction for
  16077. */
  16078. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16079. /**
  16080. * Called by the particle System when the position is computed for the created particle.
  16081. * @param worldMatrix is the world matrix of the particle system
  16082. * @param positionToUpdate is the position vector to update with the result
  16083. * @param particle is the particle we are computed the position for
  16084. */
  16085. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16086. /**
  16087. * Clones the current emitter and returns a copy of it
  16088. * @returns the new emitter
  16089. */
  16090. clone(): PointParticleEmitter;
  16091. /**
  16092. * Called by the GPUParticleSystem to setup the update shader
  16093. * @param effect defines the update shader
  16094. */
  16095. applyToShader(effect: Effect): void;
  16096. /**
  16097. * Returns a string to use to update the GPU particles update shader
  16098. * @returns a string containng the defines string
  16099. */
  16100. getEffectDefines(): string;
  16101. /**
  16102. * Returns the string "PointParticleEmitter"
  16103. * @returns a string containing the class name
  16104. */
  16105. getClassName(): string;
  16106. /**
  16107. * Serializes the particle system to a JSON object.
  16108. * @returns the JSON object
  16109. */
  16110. serialize(): any;
  16111. /**
  16112. * Parse properties from a JSON object
  16113. * @param serializationObject defines the JSON object
  16114. */
  16115. parse(serializationObject: any): void;
  16116. }
  16117. }
  16118. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16119. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16120. import { Effect } from "babylonjs/Materials/effect";
  16121. import { Particle } from "babylonjs/Particles/particle";
  16122. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16123. /**
  16124. * Particle emitter emitting particles from the inside of a sphere.
  16125. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16126. */
  16127. export class SphereParticleEmitter implements IParticleEmitterType {
  16128. /**
  16129. * The radius of the emission sphere.
  16130. */
  16131. radius: number;
  16132. /**
  16133. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16134. */
  16135. radiusRange: number;
  16136. /**
  16137. * How much to randomize the particle direction [0-1].
  16138. */
  16139. directionRandomizer: number;
  16140. /**
  16141. * Creates a new instance SphereParticleEmitter
  16142. * @param radius the radius of the emission sphere (1 by default)
  16143. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16144. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16145. */
  16146. constructor(
  16147. /**
  16148. * The radius of the emission sphere.
  16149. */
  16150. radius?: number,
  16151. /**
  16152. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16153. */
  16154. radiusRange?: number,
  16155. /**
  16156. * How much to randomize the particle direction [0-1].
  16157. */
  16158. directionRandomizer?: number);
  16159. /**
  16160. * Called by the particle System when the direction is computed for the created particle.
  16161. * @param worldMatrix is the world matrix of the particle system
  16162. * @param directionToUpdate is the direction vector to update with the result
  16163. * @param particle is the particle we are computed the direction for
  16164. */
  16165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16166. /**
  16167. * Called by the particle System when the position is computed for the created particle.
  16168. * @param worldMatrix is the world matrix of the particle system
  16169. * @param positionToUpdate is the position vector to update with the result
  16170. * @param particle is the particle we are computed the position for
  16171. */
  16172. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16173. /**
  16174. * Clones the current emitter and returns a copy of it
  16175. * @returns the new emitter
  16176. */
  16177. clone(): SphereParticleEmitter;
  16178. /**
  16179. * Called by the GPUParticleSystem to setup the update shader
  16180. * @param effect defines the update shader
  16181. */
  16182. applyToShader(effect: Effect): void;
  16183. /**
  16184. * Returns a string to use to update the GPU particles update shader
  16185. * @returns a string containng the defines string
  16186. */
  16187. getEffectDefines(): string;
  16188. /**
  16189. * Returns the string "SphereParticleEmitter"
  16190. * @returns a string containing the class name
  16191. */
  16192. getClassName(): string;
  16193. /**
  16194. * Serializes the particle system to a JSON object.
  16195. * @returns the JSON object
  16196. */
  16197. serialize(): any;
  16198. /**
  16199. * Parse properties from a JSON object
  16200. * @param serializationObject defines the JSON object
  16201. */
  16202. parse(serializationObject: any): void;
  16203. }
  16204. /**
  16205. * Particle emitter emitting particles from the inside of a sphere.
  16206. * It emits the particles randomly between two vectors.
  16207. */
  16208. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16209. /**
  16210. * The min limit of the emission direction.
  16211. */
  16212. direction1: Vector3;
  16213. /**
  16214. * The max limit of the emission direction.
  16215. */
  16216. direction2: Vector3;
  16217. /**
  16218. * Creates a new instance SphereDirectedParticleEmitter
  16219. * @param radius the radius of the emission sphere (1 by default)
  16220. * @param direction1 the min limit of the emission direction (up vector by default)
  16221. * @param direction2 the max limit of the emission direction (up vector by default)
  16222. */
  16223. constructor(radius?: number,
  16224. /**
  16225. * The min limit of the emission direction.
  16226. */
  16227. direction1?: Vector3,
  16228. /**
  16229. * The max limit of the emission direction.
  16230. */
  16231. direction2?: Vector3);
  16232. /**
  16233. * Called by the particle System when the direction is computed for the created particle.
  16234. * @param worldMatrix is the world matrix of the particle system
  16235. * @param directionToUpdate is the direction vector to update with the result
  16236. * @param particle is the particle we are computed the direction for
  16237. */
  16238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16239. /**
  16240. * Clones the current emitter and returns a copy of it
  16241. * @returns the new emitter
  16242. */
  16243. clone(): SphereDirectedParticleEmitter;
  16244. /**
  16245. * Called by the GPUParticleSystem to setup the update shader
  16246. * @param effect defines the update shader
  16247. */
  16248. applyToShader(effect: Effect): void;
  16249. /**
  16250. * Returns a string to use to update the GPU particles update shader
  16251. * @returns a string containng the defines string
  16252. */
  16253. getEffectDefines(): string;
  16254. /**
  16255. * Returns the string "SphereDirectedParticleEmitter"
  16256. * @returns a string containing the class name
  16257. */
  16258. getClassName(): string;
  16259. /**
  16260. * Serializes the particle system to a JSON object.
  16261. * @returns the JSON object
  16262. */
  16263. serialize(): any;
  16264. /**
  16265. * Parse properties from a JSON object
  16266. * @param serializationObject defines the JSON object
  16267. */
  16268. parse(serializationObject: any): void;
  16269. }
  16270. }
  16271. declare module "babylonjs/Particles/EmitterTypes/index" {
  16272. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16273. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16274. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16275. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16276. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16277. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16278. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16279. }
  16280. declare module "babylonjs/Particles/IParticleSystem" {
  16281. import { Nullable } from "babylonjs/types";
  16282. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16284. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16285. import { Texture } from "babylonjs/Materials/Textures/texture";
  16286. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16287. import { Scene } from "babylonjs/scene";
  16288. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16289. import { Animation } from "babylonjs/Animations/animation";
  16290. /**
  16291. * Interface representing a particle system in Babylon.js.
  16292. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16293. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16294. */
  16295. export interface IParticleSystem {
  16296. /**
  16297. * List of animations used by the particle system.
  16298. */
  16299. animations: Animation[];
  16300. /**
  16301. * The id of the Particle system.
  16302. */
  16303. id: string;
  16304. /**
  16305. * The name of the Particle system.
  16306. */
  16307. name: string;
  16308. /**
  16309. * The emitter represents the Mesh or position we are attaching the particle system to.
  16310. */
  16311. emitter: Nullable<AbstractMesh | Vector3>;
  16312. /**
  16313. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16314. */
  16315. isBillboardBased: boolean;
  16316. /**
  16317. * The rendering group used by the Particle system to chose when to render.
  16318. */
  16319. renderingGroupId: number;
  16320. /**
  16321. * The layer mask we are rendering the particles through.
  16322. */
  16323. layerMask: number;
  16324. /**
  16325. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16326. */
  16327. updateSpeed: number;
  16328. /**
  16329. * The amount of time the particle system is running (depends of the overall update speed).
  16330. */
  16331. targetStopDuration: number;
  16332. /**
  16333. * The texture used to render each particle. (this can be a spritesheet)
  16334. */
  16335. particleTexture: Nullable<Texture>;
  16336. /**
  16337. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16338. */
  16339. blendMode: number;
  16340. /**
  16341. * Minimum life time of emitting particles.
  16342. */
  16343. minLifeTime: number;
  16344. /**
  16345. * Maximum life time of emitting particles.
  16346. */
  16347. maxLifeTime: number;
  16348. /**
  16349. * Minimum Size of emitting particles.
  16350. */
  16351. minSize: number;
  16352. /**
  16353. * Maximum Size of emitting particles.
  16354. */
  16355. maxSize: number;
  16356. /**
  16357. * Minimum scale of emitting particles on X axis.
  16358. */
  16359. minScaleX: number;
  16360. /**
  16361. * Maximum scale of emitting particles on X axis.
  16362. */
  16363. maxScaleX: number;
  16364. /**
  16365. * Minimum scale of emitting particles on Y axis.
  16366. */
  16367. minScaleY: number;
  16368. /**
  16369. * Maximum scale of emitting particles on Y axis.
  16370. */
  16371. maxScaleY: number;
  16372. /**
  16373. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16374. */
  16375. color1: Color4;
  16376. /**
  16377. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16378. */
  16379. color2: Color4;
  16380. /**
  16381. * Color the particle will have at the end of its lifetime.
  16382. */
  16383. colorDead: Color4;
  16384. /**
  16385. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16386. */
  16387. emitRate: number;
  16388. /**
  16389. * You can use gravity if you want to give an orientation to your particles.
  16390. */
  16391. gravity: Vector3;
  16392. /**
  16393. * Minimum power of emitting particles.
  16394. */
  16395. minEmitPower: number;
  16396. /**
  16397. * Maximum power of emitting particles.
  16398. */
  16399. maxEmitPower: number;
  16400. /**
  16401. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16402. */
  16403. minAngularSpeed: number;
  16404. /**
  16405. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16406. */
  16407. maxAngularSpeed: number;
  16408. /**
  16409. * Gets or sets the minimal initial rotation in radians.
  16410. */
  16411. minInitialRotation: number;
  16412. /**
  16413. * Gets or sets the maximal initial rotation in radians.
  16414. */
  16415. maxInitialRotation: number;
  16416. /**
  16417. * The particle emitter type defines the emitter used by the particle system.
  16418. * It can be for example box, sphere, or cone...
  16419. */
  16420. particleEmitterType: Nullable<IParticleEmitterType>;
  16421. /**
  16422. * Defines the delay in milliseconds before starting the system (0 by default)
  16423. */
  16424. startDelay: number;
  16425. /**
  16426. * 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
  16427. */
  16428. preWarmCycles: number;
  16429. /**
  16430. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16431. */
  16432. preWarmStepOffset: number;
  16433. /**
  16434. * 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)
  16435. */
  16436. spriteCellChangeSpeed: number;
  16437. /**
  16438. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16439. */
  16440. startSpriteCellID: number;
  16441. /**
  16442. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16443. */
  16444. endSpriteCellID: number;
  16445. /**
  16446. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16447. */
  16448. spriteCellWidth: number;
  16449. /**
  16450. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16451. */
  16452. spriteCellHeight: number;
  16453. /**
  16454. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16455. */
  16456. spriteRandomStartCell: boolean;
  16457. /**
  16458. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16459. */
  16460. isAnimationSheetEnabled: boolean;
  16461. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16462. translationPivot: Vector2;
  16463. /**
  16464. * Gets or sets a texture used to add random noise to particle positions
  16465. */
  16466. noiseTexture: Nullable<BaseTexture>;
  16467. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16468. noiseStrength: Vector3;
  16469. /**
  16470. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16471. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16472. */
  16473. billboardMode: number;
  16474. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16475. limitVelocityDamping: number;
  16476. /**
  16477. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16478. */
  16479. beginAnimationOnStart: boolean;
  16480. /**
  16481. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16482. */
  16483. beginAnimationFrom: number;
  16484. /**
  16485. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16486. */
  16487. beginAnimationTo: number;
  16488. /**
  16489. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16490. */
  16491. beginAnimationLoop: boolean;
  16492. /**
  16493. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16494. */
  16495. disposeOnStop: boolean;
  16496. /**
  16497. * Gets the maximum number of particles active at the same time.
  16498. * @returns The max number of active particles.
  16499. */
  16500. getCapacity(): number;
  16501. /**
  16502. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16503. * @returns True if it has been started, otherwise false.
  16504. */
  16505. isStarted(): boolean;
  16506. /**
  16507. * Animates the particle system for this frame.
  16508. */
  16509. animate(): void;
  16510. /**
  16511. * Renders the particle system in its current state.
  16512. * @returns the current number of particles
  16513. */
  16514. render(): number;
  16515. /**
  16516. * Dispose the particle system and frees its associated resources.
  16517. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16518. */
  16519. dispose(disposeTexture?: boolean): void;
  16520. /**
  16521. * Clones the particle system.
  16522. * @param name The name of the cloned object
  16523. * @param newEmitter The new emitter to use
  16524. * @returns the cloned particle system
  16525. */
  16526. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16527. /**
  16528. * Serializes the particle system to a JSON object.
  16529. * @returns the JSON object
  16530. */
  16531. serialize(): any;
  16532. /**
  16533. * Rebuild the particle system
  16534. */
  16535. rebuild(): void;
  16536. /**
  16537. * Starts the particle system and begins to emit
  16538. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16539. */
  16540. start(delay?: number): void;
  16541. /**
  16542. * Stops the particle system.
  16543. */
  16544. stop(): void;
  16545. /**
  16546. * Remove all active particles
  16547. */
  16548. reset(): void;
  16549. /**
  16550. * Is this system ready to be used/rendered
  16551. * @return true if the system is ready
  16552. */
  16553. isReady(): boolean;
  16554. /**
  16555. * Adds a new color gradient
  16556. * @param gradient defines the gradient to use (between 0 and 1)
  16557. * @param color1 defines the color to affect to the specified gradient
  16558. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16559. * @returns the current particle system
  16560. */
  16561. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16562. /**
  16563. * Remove a specific color gradient
  16564. * @param gradient defines the gradient to remove
  16565. * @returns the current particle system
  16566. */
  16567. removeColorGradient(gradient: number): IParticleSystem;
  16568. /**
  16569. * Adds a new size gradient
  16570. * @param gradient defines the gradient to use (between 0 and 1)
  16571. * @param factor defines the size factor to affect to the specified gradient
  16572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16573. * @returns the current particle system
  16574. */
  16575. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16576. /**
  16577. * Remove a specific size gradient
  16578. * @param gradient defines the gradient to remove
  16579. * @returns the current particle system
  16580. */
  16581. removeSizeGradient(gradient: number): IParticleSystem;
  16582. /**
  16583. * Gets the current list of color gradients.
  16584. * You must use addColorGradient and removeColorGradient to udpate this list
  16585. * @returns the list of color gradients
  16586. */
  16587. getColorGradients(): Nullable<Array<ColorGradient>>;
  16588. /**
  16589. * Gets the current list of size gradients.
  16590. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16591. * @returns the list of size gradients
  16592. */
  16593. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16594. /**
  16595. * Gets the current list of angular speed gradients.
  16596. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16597. * @returns the list of angular speed gradients
  16598. */
  16599. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16600. /**
  16601. * Adds a new angular speed gradient
  16602. * @param gradient defines the gradient to use (between 0 and 1)
  16603. * @param factor defines the angular speed to affect to the specified gradient
  16604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16605. * @returns the current particle system
  16606. */
  16607. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16608. /**
  16609. * Remove a specific angular speed gradient
  16610. * @param gradient defines the gradient to remove
  16611. * @returns the current particle system
  16612. */
  16613. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16614. /**
  16615. * Gets the current list of velocity gradients.
  16616. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16617. * @returns the list of velocity gradients
  16618. */
  16619. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16620. /**
  16621. * Adds a new velocity gradient
  16622. * @param gradient defines the gradient to use (between 0 and 1)
  16623. * @param factor defines the velocity to affect to the specified gradient
  16624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16625. * @returns the current particle system
  16626. */
  16627. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16628. /**
  16629. * Remove a specific velocity gradient
  16630. * @param gradient defines the gradient to remove
  16631. * @returns the current particle system
  16632. */
  16633. removeVelocityGradient(gradient: number): IParticleSystem;
  16634. /**
  16635. * Gets the current list of limit velocity gradients.
  16636. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16637. * @returns the list of limit velocity gradients
  16638. */
  16639. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16640. /**
  16641. * Adds a new limit velocity gradient
  16642. * @param gradient defines the gradient to use (between 0 and 1)
  16643. * @param factor defines the limit velocity to affect to the specified gradient
  16644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16645. * @returns the current particle system
  16646. */
  16647. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16648. /**
  16649. * Remove a specific limit velocity gradient
  16650. * @param gradient defines the gradient to remove
  16651. * @returns the current particle system
  16652. */
  16653. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16654. /**
  16655. * Adds a new drag gradient
  16656. * @param gradient defines the gradient to use (between 0 and 1)
  16657. * @param factor defines the drag to affect to the specified gradient
  16658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16659. * @returns the current particle system
  16660. */
  16661. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16662. /**
  16663. * Remove a specific drag gradient
  16664. * @param gradient defines the gradient to remove
  16665. * @returns the current particle system
  16666. */
  16667. removeDragGradient(gradient: number): IParticleSystem;
  16668. /**
  16669. * Gets the current list of drag gradients.
  16670. * You must use addDragGradient and removeDragGradient to udpate this list
  16671. * @returns the list of drag gradients
  16672. */
  16673. getDragGradients(): Nullable<Array<FactorGradient>>;
  16674. /**
  16675. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16676. * @param gradient defines the gradient to use (between 0 and 1)
  16677. * @param factor defines the emit rate to affect to the specified gradient
  16678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16679. * @returns the current particle system
  16680. */
  16681. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16682. /**
  16683. * Remove a specific emit rate gradient
  16684. * @param gradient defines the gradient to remove
  16685. * @returns the current particle system
  16686. */
  16687. removeEmitRateGradient(gradient: number): IParticleSystem;
  16688. /**
  16689. * Gets the current list of emit rate gradients.
  16690. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16691. * @returns the list of emit rate gradients
  16692. */
  16693. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16694. /**
  16695. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16696. * @param gradient defines the gradient to use (between 0 and 1)
  16697. * @param factor defines the start size to affect to the specified gradient
  16698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16699. * @returns the current particle system
  16700. */
  16701. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16702. /**
  16703. * Remove a specific start size gradient
  16704. * @param gradient defines the gradient to remove
  16705. * @returns the current particle system
  16706. */
  16707. removeStartSizeGradient(gradient: number): IParticleSystem;
  16708. /**
  16709. * Gets the current list of start size gradients.
  16710. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16711. * @returns the list of start size gradients
  16712. */
  16713. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16714. /**
  16715. * Adds a new life time gradient
  16716. * @param gradient defines the gradient to use (between 0 and 1)
  16717. * @param factor defines the life time factor to affect to the specified gradient
  16718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16719. * @returns the current particle system
  16720. */
  16721. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16722. /**
  16723. * Remove a specific life time gradient
  16724. * @param gradient defines the gradient to remove
  16725. * @returns the current particle system
  16726. */
  16727. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16728. /**
  16729. * Gets the current list of life time gradients.
  16730. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16731. * @returns the list of life time gradients
  16732. */
  16733. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16734. /**
  16735. * Gets the current list of color gradients.
  16736. * You must use addColorGradient and removeColorGradient to udpate this list
  16737. * @returns the list of color gradients
  16738. */
  16739. getColorGradients(): Nullable<Array<ColorGradient>>;
  16740. /**
  16741. * Adds a new ramp gradient used to remap particle colors
  16742. * @param gradient defines the gradient to use (between 0 and 1)
  16743. * @param color defines the color to affect to the specified gradient
  16744. * @returns the current particle system
  16745. */
  16746. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16747. /**
  16748. * Gets the current list of ramp gradients.
  16749. * You must use addRampGradient and removeRampGradient to udpate this list
  16750. * @returns the list of ramp gradients
  16751. */
  16752. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16753. /** Gets or sets a boolean indicating that ramp gradients must be used
  16754. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16755. */
  16756. useRampGradients: boolean;
  16757. /**
  16758. * Adds a new color remap gradient
  16759. * @param gradient defines the gradient to use (between 0 and 1)
  16760. * @param min defines the color remap minimal range
  16761. * @param max defines the color remap maximal range
  16762. * @returns the current particle system
  16763. */
  16764. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16765. /**
  16766. * Gets the current list of color remap gradients.
  16767. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16768. * @returns the list of color remap gradients
  16769. */
  16770. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16771. /**
  16772. * Adds a new alpha remap gradient
  16773. * @param gradient defines the gradient to use (between 0 and 1)
  16774. * @param min defines the alpha remap minimal range
  16775. * @param max defines the alpha remap maximal range
  16776. * @returns the current particle system
  16777. */
  16778. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16779. /**
  16780. * Gets the current list of alpha remap gradients.
  16781. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16782. * @returns the list of alpha remap gradients
  16783. */
  16784. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16785. /**
  16786. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16789. * @returns the emitter
  16790. */
  16791. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16792. /**
  16793. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16794. * @param radius The radius of the hemisphere to emit from
  16795. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16796. * @returns the emitter
  16797. */
  16798. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16799. /**
  16800. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16801. * @param radius The radius of the sphere to emit from
  16802. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16803. * @returns the emitter
  16804. */
  16805. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16806. /**
  16807. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16808. * @param radius The radius of the sphere to emit from
  16809. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16810. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16811. * @returns the emitter
  16812. */
  16813. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16814. /**
  16815. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16816. * @param radius The radius of the emission cylinder
  16817. * @param height The height of the emission cylinder
  16818. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16819. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16820. * @returns the emitter
  16821. */
  16822. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16823. /**
  16824. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16825. * @param radius The radius of the cylinder to emit from
  16826. * @param height The height of the emission cylinder
  16827. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16828. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16829. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16830. * @returns the emitter
  16831. */
  16832. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16833. /**
  16834. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16835. * @param radius The radius of the cone to emit from
  16836. * @param angle The base angle of the cone
  16837. * @returns the emitter
  16838. */
  16839. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16840. /**
  16841. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16844. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16845. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16846. * @returns the emitter
  16847. */
  16848. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16849. /**
  16850. * Get hosting scene
  16851. * @returns the scene
  16852. */
  16853. getScene(): Scene;
  16854. }
  16855. }
  16856. declare module "babylonjs/Meshes/instancedMesh" {
  16857. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16858. import { Vector3 } from "babylonjs/Maths/math";
  16859. import { Camera } from "babylonjs/Cameras/camera";
  16860. import { Node } from "babylonjs/node";
  16861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16862. import { Mesh } from "babylonjs/Meshes/mesh";
  16863. import { Material } from "babylonjs/Materials/material";
  16864. import { Skeleton } from "babylonjs/Bones/skeleton";
  16865. /**
  16866. * Creates an instance based on a source mesh.
  16867. */
  16868. export class InstancedMesh extends AbstractMesh {
  16869. private _sourceMesh;
  16870. private _currentLOD;
  16871. /** @hidden */
  16872. _indexInSourceMeshInstanceArray: number;
  16873. constructor(name: string, source: Mesh);
  16874. /**
  16875. * Returns the string "InstancedMesh".
  16876. */
  16877. getClassName(): string;
  16878. /**
  16879. * If the source mesh receives shadows
  16880. */
  16881. readonly receiveShadows: boolean;
  16882. /**
  16883. * The material of the source mesh
  16884. */
  16885. readonly material: Nullable<Material>;
  16886. /**
  16887. * Visibility of the source mesh
  16888. */
  16889. readonly visibility: number;
  16890. /**
  16891. * Skeleton of the source mesh
  16892. */
  16893. readonly skeleton: Nullable<Skeleton>;
  16894. /**
  16895. * Rendering ground id of the source mesh
  16896. */
  16897. renderingGroupId: number;
  16898. /**
  16899. * Returns the total number of vertices (integer).
  16900. */
  16901. getTotalVertices(): number;
  16902. /**
  16903. * Returns a positive integer : the total number of indices in this mesh geometry.
  16904. * @returns the numner of indices or zero if the mesh has no geometry.
  16905. */
  16906. getTotalIndices(): number;
  16907. /**
  16908. * The source mesh of the instance
  16909. */
  16910. readonly sourceMesh: Mesh;
  16911. /**
  16912. * Is this node ready to be used/rendered
  16913. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16914. * @return {boolean} is it ready
  16915. */
  16916. isReady(completeCheck?: boolean): boolean;
  16917. /**
  16918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16919. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16920. * @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.
  16921. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16922. */
  16923. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16924. /**
  16925. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16926. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16927. * The `data` are either a numeric array either a Float32Array.
  16928. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16929. * 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).
  16930. * Note that a new underlying VertexBuffer object is created each call.
  16931. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16932. *
  16933. * Possible `kind` values :
  16934. * - VertexBuffer.PositionKind
  16935. * - VertexBuffer.UVKind
  16936. * - VertexBuffer.UV2Kind
  16937. * - VertexBuffer.UV3Kind
  16938. * - VertexBuffer.UV4Kind
  16939. * - VertexBuffer.UV5Kind
  16940. * - VertexBuffer.UV6Kind
  16941. * - VertexBuffer.ColorKind
  16942. * - VertexBuffer.MatricesIndicesKind
  16943. * - VertexBuffer.MatricesIndicesExtraKind
  16944. * - VertexBuffer.MatricesWeightsKind
  16945. * - VertexBuffer.MatricesWeightsExtraKind
  16946. *
  16947. * Returns the Mesh.
  16948. */
  16949. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16950. /**
  16951. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16952. * If the mesh has no geometry, it is simply returned as it is.
  16953. * The `data` are either a numeric array either a Float32Array.
  16954. * No new underlying VertexBuffer object is created.
  16955. * 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.
  16956. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16957. *
  16958. * Possible `kind` values :
  16959. * - VertexBuffer.PositionKind
  16960. * - VertexBuffer.UVKind
  16961. * - VertexBuffer.UV2Kind
  16962. * - VertexBuffer.UV3Kind
  16963. * - VertexBuffer.UV4Kind
  16964. * - VertexBuffer.UV5Kind
  16965. * - VertexBuffer.UV6Kind
  16966. * - VertexBuffer.ColorKind
  16967. * - VertexBuffer.MatricesIndicesKind
  16968. * - VertexBuffer.MatricesIndicesExtraKind
  16969. * - VertexBuffer.MatricesWeightsKind
  16970. * - VertexBuffer.MatricesWeightsExtraKind
  16971. *
  16972. * Returns the Mesh.
  16973. */
  16974. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16975. /**
  16976. * Sets the mesh indices.
  16977. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16978. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16979. * This method creates a new index buffer each call.
  16980. * Returns the Mesh.
  16981. */
  16982. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16983. /**
  16984. * Boolean : True if the mesh owns the requested kind of data.
  16985. */
  16986. isVerticesDataPresent(kind: string): boolean;
  16987. /**
  16988. * Returns an array of indices (IndicesArray).
  16989. */
  16990. getIndices(): Nullable<IndicesArray>;
  16991. readonly _positions: Nullable<Vector3[]>;
  16992. /**
  16993. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16994. * This means the mesh underlying bounding box and sphere are recomputed.
  16995. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16996. * @returns the current mesh
  16997. */
  16998. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16999. /** @hidden */
  17000. _preActivate(): InstancedMesh;
  17001. /** @hidden */
  17002. _activate(renderId: number): InstancedMesh;
  17003. /**
  17004. * Returns the current associated LOD AbstractMesh.
  17005. */
  17006. getLOD(camera: Camera): AbstractMesh;
  17007. /** @hidden */
  17008. _syncSubMeshes(): InstancedMesh;
  17009. /** @hidden */
  17010. _generatePointsArray(): boolean;
  17011. /**
  17012. * Creates a new InstancedMesh from the current mesh.
  17013. * - name (string) : the cloned mesh name
  17014. * - newParent (optional Node) : the optional Node to parent the clone to.
  17015. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17016. *
  17017. * Returns the clone.
  17018. */
  17019. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17020. /**
  17021. * Disposes the InstancedMesh.
  17022. * Returns nothing.
  17023. */
  17024. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17025. }
  17026. }
  17027. declare module "babylonjs/Materials/shaderMaterial" {
  17028. import { Scene } from "babylonjs/scene";
  17029. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17031. import { Mesh } from "babylonjs/Meshes/mesh";
  17032. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17034. import { Texture } from "babylonjs/Materials/Textures/texture";
  17035. import { Material } from "babylonjs/Materials/material";
  17036. /**
  17037. * Defines the options associated with the creation of a shader material.
  17038. */
  17039. export interface IShaderMaterialOptions {
  17040. /**
  17041. * Does the material work in alpha blend mode
  17042. */
  17043. needAlphaBlending: boolean;
  17044. /**
  17045. * Does the material work in alpha test mode
  17046. */
  17047. needAlphaTesting: boolean;
  17048. /**
  17049. * The list of attribute names used in the shader
  17050. */
  17051. attributes: string[];
  17052. /**
  17053. * The list of unifrom names used in the shader
  17054. */
  17055. uniforms: string[];
  17056. /**
  17057. * The list of UBO names used in the shader
  17058. */
  17059. uniformBuffers: string[];
  17060. /**
  17061. * The list of sampler names used in the shader
  17062. */
  17063. samplers: string[];
  17064. /**
  17065. * The list of defines used in the shader
  17066. */
  17067. defines: string[];
  17068. }
  17069. /**
  17070. * 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.
  17071. *
  17072. * This returned material effects how the mesh will look based on the code in the shaders.
  17073. *
  17074. * @see http://doc.babylonjs.com/how_to/shader_material
  17075. */
  17076. export class ShaderMaterial extends Material {
  17077. private _shaderPath;
  17078. private _options;
  17079. private _textures;
  17080. private _textureArrays;
  17081. private _floats;
  17082. private _ints;
  17083. private _floatsArrays;
  17084. private _colors3;
  17085. private _colors3Arrays;
  17086. private _colors4;
  17087. private _vectors2;
  17088. private _vectors3;
  17089. private _vectors4;
  17090. private _matrices;
  17091. private _matrices3x3;
  17092. private _matrices2x2;
  17093. private _vectors2Arrays;
  17094. private _vectors3Arrays;
  17095. private _cachedWorldViewMatrix;
  17096. private _renderId;
  17097. /**
  17098. * Instantiate a new shader material.
  17099. * 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.
  17100. * This returned material effects how the mesh will look based on the code in the shaders.
  17101. * @see http://doc.babylonjs.com/how_to/shader_material
  17102. * @param name Define the name of the material in the scene
  17103. * @param scene Define the scene the material belongs to
  17104. * @param shaderPath Defines the route to the shader code in one of three ways:
  17105. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17106. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17107. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17108. * @param options Define the options used to create the shader
  17109. */
  17110. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17111. /**
  17112. * Gets the options used to compile the shader.
  17113. * They can be modified to trigger a new compilation
  17114. */
  17115. readonly options: IShaderMaterialOptions;
  17116. /**
  17117. * Gets the current class name of the material e.g. "ShaderMaterial"
  17118. * Mainly use in serialization.
  17119. * @returns the class name
  17120. */
  17121. getClassName(): string;
  17122. /**
  17123. * Specifies if the material will require alpha blending
  17124. * @returns a boolean specifying if alpha blending is needed
  17125. */
  17126. needAlphaBlending(): boolean;
  17127. /**
  17128. * Specifies if this material should be rendered in alpha test mode
  17129. * @returns a boolean specifying if an alpha test is needed.
  17130. */
  17131. needAlphaTesting(): boolean;
  17132. private _checkUniform;
  17133. /**
  17134. * Set a texture in the shader.
  17135. * @param name Define the name of the uniform samplers as defined in the shader
  17136. * @param texture Define the texture to bind to this sampler
  17137. * @return the material itself allowing "fluent" like uniform updates
  17138. */
  17139. setTexture(name: string, texture: Texture): ShaderMaterial;
  17140. /**
  17141. * Set a texture array in the shader.
  17142. * @param name Define the name of the uniform sampler array as defined in the shader
  17143. * @param textures Define the list of textures to bind to this sampler
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17147. /**
  17148. * Set a float in the shader.
  17149. * @param name Define the name of the uniform as defined in the shader
  17150. * @param value Define the value to give to the uniform
  17151. * @return the material itself allowing "fluent" like uniform updates
  17152. */
  17153. setFloat(name: string, value: number): ShaderMaterial;
  17154. /**
  17155. * Set a int in the shader.
  17156. * @param name Define the name of the uniform as defined in the shader
  17157. * @param value Define the value to give to the uniform
  17158. * @return the material itself allowing "fluent" like uniform updates
  17159. */
  17160. setInt(name: string, value: number): ShaderMaterial;
  17161. /**
  17162. * Set an array of floats in the shader.
  17163. * @param name Define the name of the uniform as defined in the shader
  17164. * @param value Define the value to give to the uniform
  17165. * @return the material itself allowing "fluent" like uniform updates
  17166. */
  17167. setFloats(name: string, value: number[]): ShaderMaterial;
  17168. /**
  17169. * Set a vec3 in the shader from a Color3.
  17170. * @param name Define the name of the uniform as defined in the shader
  17171. * @param value Define the value to give to the uniform
  17172. * @return the material itself allowing "fluent" like uniform updates
  17173. */
  17174. setColor3(name: string, value: Color3): ShaderMaterial;
  17175. /**
  17176. * Set a vec3 array in the shader from a Color3 array.
  17177. * @param name Define the name of the uniform as defined in the shader
  17178. * @param value Define the value to give to the uniform
  17179. * @return the material itself allowing "fluent" like uniform updates
  17180. */
  17181. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17182. /**
  17183. * Set a vec4 in the shader from a Color4.
  17184. * @param name Define the name of the uniform as defined in the shader
  17185. * @param value Define the value to give to the uniform
  17186. * @return the material itself allowing "fluent" like uniform updates
  17187. */
  17188. setColor4(name: string, value: Color4): ShaderMaterial;
  17189. /**
  17190. * Set a vec2 in the shader from a Vector2.
  17191. * @param name Define the name of the uniform as defined in the shader
  17192. * @param value Define the value to give to the uniform
  17193. * @return the material itself allowing "fluent" like uniform updates
  17194. */
  17195. setVector2(name: string, value: Vector2): ShaderMaterial;
  17196. /**
  17197. * Set a vec3 in the shader from a Vector3.
  17198. * @param name Define the name of the uniform as defined in the shader
  17199. * @param value Define the value to give to the uniform
  17200. * @return the material itself allowing "fluent" like uniform updates
  17201. */
  17202. setVector3(name: string, value: Vector3): ShaderMaterial;
  17203. /**
  17204. * Set a vec4 in the shader from a Vector4.
  17205. * @param name Define the name of the uniform as defined in the shader
  17206. * @param value Define the value to give to the uniform
  17207. * @return the material itself allowing "fluent" like uniform updates
  17208. */
  17209. setVector4(name: string, value: Vector4): ShaderMaterial;
  17210. /**
  17211. * Set a mat4 in the shader from a Matrix.
  17212. * @param name Define the name of the uniform as defined in the shader
  17213. * @param value Define the value to give to the uniform
  17214. * @return the material itself allowing "fluent" like uniform updates
  17215. */
  17216. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17217. /**
  17218. * Set a mat3 in the shader from a Float32Array.
  17219. * @param name Define the name of the uniform as defined in the shader
  17220. * @param value Define the value to give to the uniform
  17221. * @return the material itself allowing "fluent" like uniform updates
  17222. */
  17223. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17224. /**
  17225. * Set a mat2 in the shader from a Float32Array.
  17226. * @param name Define the name of the uniform as defined in the shader
  17227. * @param value Define the value to give to the uniform
  17228. * @return the material itself allowing "fluent" like uniform updates
  17229. */
  17230. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17231. /**
  17232. * Set a vec2 array in the shader from a number array.
  17233. * @param name Define the name of the uniform as defined in the shader
  17234. * @param value Define the value to give to the uniform
  17235. * @return the material itself allowing "fluent" like uniform updates
  17236. */
  17237. setArray2(name: string, value: number[]): ShaderMaterial;
  17238. /**
  17239. * Set a vec3 array in the shader from a number array.
  17240. * @param name Define the name of the uniform as defined in the shader
  17241. * @param value Define the value to give to the uniform
  17242. * @return the material itself allowing "fluent" like uniform updates
  17243. */
  17244. setArray3(name: string, value: number[]): ShaderMaterial;
  17245. private _checkCache;
  17246. /**
  17247. * Specifies that the submesh is ready to be used
  17248. * @param mesh defines the mesh to check
  17249. * @param subMesh defines which submesh to check
  17250. * @param useInstances specifies that instances should be used
  17251. * @returns a boolean indicating that the submesh is ready or not
  17252. */
  17253. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17254. /**
  17255. * Checks if the material is ready to render the requested mesh
  17256. * @param mesh Define the mesh to render
  17257. * @param useInstances Define whether or not the material is used with instances
  17258. * @returns true if ready, otherwise false
  17259. */
  17260. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17261. /**
  17262. * Binds the world matrix to the material
  17263. * @param world defines the world transformation matrix
  17264. */
  17265. bindOnlyWorldMatrix(world: Matrix): void;
  17266. /**
  17267. * Binds the material to the mesh
  17268. * @param world defines the world transformation matrix
  17269. * @param mesh defines the mesh to bind the material to
  17270. */
  17271. bind(world: Matrix, mesh?: Mesh): void;
  17272. /**
  17273. * Gets the active textures from the material
  17274. * @returns an array of textures
  17275. */
  17276. getActiveTextures(): BaseTexture[];
  17277. /**
  17278. * Specifies if the material uses a texture
  17279. * @param texture defines the texture to check against the material
  17280. * @returns a boolean specifying if the material uses the texture
  17281. */
  17282. hasTexture(texture: BaseTexture): boolean;
  17283. /**
  17284. * Makes a duplicate of the material, and gives it a new name
  17285. * @param name defines the new name for the duplicated material
  17286. * @returns the cloned material
  17287. */
  17288. clone(name: string): ShaderMaterial;
  17289. /**
  17290. * Disposes the material
  17291. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17292. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17293. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17294. */
  17295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17296. /**
  17297. * Serializes this material in a JSON representation
  17298. * @returns the serialized material object
  17299. */
  17300. serialize(): any;
  17301. /**
  17302. * Creates a shader material from parsed shader material data
  17303. * @param source defines the JSON represnetation of the material
  17304. * @param scene defines the hosting scene
  17305. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17306. * @returns a new material
  17307. */
  17308. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17309. }
  17310. }
  17311. declare module "babylonjs/Shaders/color.fragment" {
  17312. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17313. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17314. /** @hidden */
  17315. export var colorPixelShader: {
  17316. name: string;
  17317. shader: string;
  17318. };
  17319. }
  17320. declare module "babylonjs/Shaders/color.vertex" {
  17321. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17322. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17323. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17324. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17325. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17327. /** @hidden */
  17328. export var colorVertexShader: {
  17329. name: string;
  17330. shader: string;
  17331. };
  17332. }
  17333. declare module "babylonjs/Meshes/linesMesh" {
  17334. import { Nullable } from "babylonjs/types";
  17335. import { Scene } from "babylonjs/scene";
  17336. import { Color3 } from "babylonjs/Maths/math";
  17337. import { Node } from "babylonjs/node";
  17338. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17339. import { Mesh } from "babylonjs/Meshes/mesh";
  17340. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17341. import { Effect } from "babylonjs/Materials/effect";
  17342. import { Material } from "babylonjs/Materials/material";
  17343. import "babylonjs/Shaders/color.fragment";
  17344. import "babylonjs/Shaders/color.vertex";
  17345. /**
  17346. * Line mesh
  17347. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17348. */
  17349. export class LinesMesh extends Mesh {
  17350. /**
  17351. * If vertex color should be applied to the mesh
  17352. */
  17353. useVertexColor?: boolean | undefined;
  17354. /**
  17355. * If vertex alpha should be applied to the mesh
  17356. */
  17357. useVertexAlpha?: boolean | undefined;
  17358. /**
  17359. * Color of the line (Default: White)
  17360. */
  17361. color: Color3;
  17362. /**
  17363. * Alpha of the line (Default: 1)
  17364. */
  17365. alpha: number;
  17366. /**
  17367. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17368. * This margin is expressed in world space coordinates, so its value may vary.
  17369. * Default value is 0.1
  17370. */
  17371. intersectionThreshold: number;
  17372. private _colorShader;
  17373. /**
  17374. * Creates a new LinesMesh
  17375. * @param name defines the name
  17376. * @param scene defines the hosting scene
  17377. * @param parent defines the parent mesh if any
  17378. * @param source defines the optional source LinesMesh used to clone data from
  17379. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17380. * When false, achieved by calling a clone(), also passing False.
  17381. * This will make creation of children, recursive.
  17382. * @param useVertexColor defines if this LinesMesh supports vertex color
  17383. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17384. */
  17385. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17386. /**
  17387. * If vertex color should be applied to the mesh
  17388. */
  17389. useVertexColor?: boolean | undefined,
  17390. /**
  17391. * If vertex alpha should be applied to the mesh
  17392. */
  17393. useVertexAlpha?: boolean | undefined);
  17394. private _addClipPlaneDefine;
  17395. private _removeClipPlaneDefine;
  17396. isReady(): boolean;
  17397. /**
  17398. * Returns the string "LineMesh"
  17399. */
  17400. getClassName(): string;
  17401. /**
  17402. * @hidden
  17403. */
  17404. /**
  17405. * @hidden
  17406. */
  17407. material: Material;
  17408. /**
  17409. * @hidden
  17410. */
  17411. readonly checkCollisions: boolean;
  17412. /** @hidden */
  17413. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17414. /** @hidden */
  17415. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17416. /**
  17417. * Disposes of the line mesh
  17418. * @param doNotRecurse If children should be disposed
  17419. */
  17420. dispose(doNotRecurse?: boolean): void;
  17421. /**
  17422. * Returns a new LineMesh object cloned from the current one.
  17423. */
  17424. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17425. /**
  17426. * Creates a new InstancedLinesMesh object from the mesh model.
  17427. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17428. * @param name defines the name of the new instance
  17429. * @returns a new InstancedLinesMesh
  17430. */
  17431. createInstance(name: string): InstancedLinesMesh;
  17432. }
  17433. /**
  17434. * Creates an instance based on a source LinesMesh
  17435. */
  17436. export class InstancedLinesMesh extends InstancedMesh {
  17437. /**
  17438. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17439. * This margin is expressed in world space coordinates, so its value may vary.
  17440. * Initilized with the intersectionThreshold value of the source LinesMesh
  17441. */
  17442. intersectionThreshold: number;
  17443. constructor(name: string, source: LinesMesh);
  17444. /**
  17445. * Returns the string "InstancedLinesMesh".
  17446. */
  17447. getClassName(): string;
  17448. }
  17449. }
  17450. declare module "babylonjs/Shaders/line.fragment" {
  17451. /** @hidden */
  17452. export var linePixelShader: {
  17453. name: string;
  17454. shader: string;
  17455. };
  17456. }
  17457. declare module "babylonjs/Shaders/line.vertex" {
  17458. /** @hidden */
  17459. export var lineVertexShader: {
  17460. name: string;
  17461. shader: string;
  17462. };
  17463. }
  17464. declare module "babylonjs/Rendering/edgesRenderer" {
  17465. import { Nullable } from "babylonjs/types";
  17466. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17468. import { Vector3 } from "babylonjs/Maths/math";
  17469. import { IDisposable } from "babylonjs/scene";
  17470. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17471. import "babylonjs/Shaders/line.fragment";
  17472. import "babylonjs/Shaders/line.vertex";
  17473. module "babylonjs/Meshes/abstractMesh" {
  17474. interface AbstractMesh {
  17475. /**
  17476. * Disables the mesh edge rendering mode
  17477. * @returns the currentAbstractMesh
  17478. */
  17479. disableEdgesRendering(): AbstractMesh;
  17480. /**
  17481. * Enables the edge rendering mode on the mesh.
  17482. * This mode makes the mesh edges visible
  17483. * @param epsilon defines the maximal distance between two angles to detect a face
  17484. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17485. * @returns the currentAbstractMesh
  17486. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17487. */
  17488. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17489. /**
  17490. * Gets the edgesRenderer associated with the mesh
  17491. */
  17492. edgesRenderer: Nullable<EdgesRenderer>;
  17493. }
  17494. }
  17495. module "babylonjs/Meshes/linesMesh" {
  17496. interface LinesMesh {
  17497. /**
  17498. * Enables the edge rendering mode on the mesh.
  17499. * This mode makes the mesh edges visible
  17500. * @param epsilon defines the maximal distance between two angles to detect a face
  17501. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17502. * @returns the currentAbstractMesh
  17503. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17504. */
  17505. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17506. }
  17507. }
  17508. module "babylonjs/Meshes/linesMesh" {
  17509. interface InstancedLinesMesh {
  17510. /**
  17511. * Enables the edge rendering mode on the mesh.
  17512. * This mode makes the mesh edges visible
  17513. * @param epsilon defines the maximal distance between two angles to detect a face
  17514. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17515. * @returns the current InstancedLinesMesh
  17516. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17517. */
  17518. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17519. }
  17520. }
  17521. /**
  17522. * Defines the minimum contract an Edges renderer should follow.
  17523. */
  17524. export interface IEdgesRenderer extends IDisposable {
  17525. /**
  17526. * Gets or sets a boolean indicating if the edgesRenderer is active
  17527. */
  17528. isEnabled: boolean;
  17529. /**
  17530. * Renders the edges of the attached mesh,
  17531. */
  17532. render(): void;
  17533. /**
  17534. * Checks wether or not the edges renderer is ready to render.
  17535. * @return true if ready, otherwise false.
  17536. */
  17537. isReady(): boolean;
  17538. }
  17539. /**
  17540. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17541. */
  17542. export class EdgesRenderer implements IEdgesRenderer {
  17543. /**
  17544. * Define the size of the edges with an orthographic camera
  17545. */
  17546. edgesWidthScalerForOrthographic: number;
  17547. /**
  17548. * Define the size of the edges with a perspective camera
  17549. */
  17550. edgesWidthScalerForPerspective: number;
  17551. protected _source: AbstractMesh;
  17552. protected _linesPositions: number[];
  17553. protected _linesNormals: number[];
  17554. protected _linesIndices: number[];
  17555. protected _epsilon: number;
  17556. protected _indicesCount: number;
  17557. protected _lineShader: ShaderMaterial;
  17558. protected _ib: WebGLBuffer;
  17559. protected _buffers: {
  17560. [key: string]: Nullable<VertexBuffer>;
  17561. };
  17562. protected _checkVerticesInsteadOfIndices: boolean;
  17563. private _meshRebuildObserver;
  17564. private _meshDisposeObserver;
  17565. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17566. isEnabled: boolean;
  17567. /**
  17568. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17569. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17570. * @param source Mesh used to create edges
  17571. * @param epsilon sum of angles in adjacency to check for edge
  17572. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17573. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17574. */
  17575. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17576. protected _prepareRessources(): void;
  17577. /** @hidden */
  17578. _rebuild(): void;
  17579. /**
  17580. * Releases the required resources for the edges renderer
  17581. */
  17582. dispose(): void;
  17583. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17584. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17585. /**
  17586. * Checks if the pair of p0 and p1 is en edge
  17587. * @param faceIndex
  17588. * @param edge
  17589. * @param faceNormals
  17590. * @param p0
  17591. * @param p1
  17592. * @private
  17593. */
  17594. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17595. /**
  17596. * push line into the position, normal and index buffer
  17597. * @protected
  17598. */
  17599. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17600. /**
  17601. * Generates lines edges from adjacencjes
  17602. * @private
  17603. */
  17604. _generateEdgesLines(): void;
  17605. /**
  17606. * Checks wether or not the edges renderer is ready to render.
  17607. * @return true if ready, otherwise false.
  17608. */
  17609. isReady(): boolean;
  17610. /**
  17611. * Renders the edges of the attached mesh,
  17612. */
  17613. render(): void;
  17614. }
  17615. /**
  17616. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17617. */
  17618. export class LineEdgesRenderer extends EdgesRenderer {
  17619. /**
  17620. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17621. * @param source LineMesh used to generate edges
  17622. * @param epsilon not important (specified angle for edge detection)
  17623. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17624. */
  17625. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17626. /**
  17627. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17628. */
  17629. _generateEdgesLines(): void;
  17630. }
  17631. }
  17632. declare module "babylonjs/Rendering/renderingGroup" {
  17633. import { SmartArray } from "babylonjs/Misc/smartArray";
  17634. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17636. import { Nullable } from "babylonjs/types";
  17637. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17638. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17639. import { Material } from "babylonjs/Materials/material";
  17640. import { Scene } from "babylonjs/scene";
  17641. /**
  17642. * This represents the object necessary to create a rendering group.
  17643. * This is exclusively used and created by the rendering manager.
  17644. * To modify the behavior, you use the available helpers in your scene or meshes.
  17645. * @hidden
  17646. */
  17647. export class RenderingGroup {
  17648. index: number;
  17649. private _scene;
  17650. private _opaqueSubMeshes;
  17651. private _transparentSubMeshes;
  17652. private _alphaTestSubMeshes;
  17653. private _depthOnlySubMeshes;
  17654. private _particleSystems;
  17655. private _spriteManagers;
  17656. private _opaqueSortCompareFn;
  17657. private _alphaTestSortCompareFn;
  17658. private _transparentSortCompareFn;
  17659. private _renderOpaque;
  17660. private _renderAlphaTest;
  17661. private _renderTransparent;
  17662. private _edgesRenderers;
  17663. onBeforeTransparentRendering: () => void;
  17664. /**
  17665. * Set the opaque sort comparison function.
  17666. * If null the sub meshes will be render in the order they were created
  17667. */
  17668. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17669. /**
  17670. * Set the alpha test sort comparison function.
  17671. * If null the sub meshes will be render in the order they were created
  17672. */
  17673. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17674. /**
  17675. * Set the transparent sort comparison function.
  17676. * If null the sub meshes will be render in the order they were created
  17677. */
  17678. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17679. /**
  17680. * Creates a new rendering group.
  17681. * @param index The rendering group index
  17682. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17683. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17684. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17685. */
  17686. 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>);
  17687. /**
  17688. * Render all the sub meshes contained in the group.
  17689. * @param customRenderFunction Used to override the default render behaviour of the group.
  17690. * @returns true if rendered some submeshes.
  17691. */
  17692. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17693. /**
  17694. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17695. * @param subMeshes The submeshes to render
  17696. */
  17697. private renderOpaqueSorted;
  17698. /**
  17699. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17700. * @param subMeshes The submeshes to render
  17701. */
  17702. private renderAlphaTestSorted;
  17703. /**
  17704. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17705. * @param subMeshes The submeshes to render
  17706. */
  17707. private renderTransparentSorted;
  17708. /**
  17709. * Renders the submeshes in a specified order.
  17710. * @param subMeshes The submeshes to sort before render
  17711. * @param sortCompareFn The comparison function use to sort
  17712. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17713. * @param transparent Specifies to activate blending if true
  17714. */
  17715. private static renderSorted;
  17716. /**
  17717. * Renders the submeshes in the order they were dispatched (no sort applied).
  17718. * @param subMeshes The submeshes to render
  17719. */
  17720. private static renderUnsorted;
  17721. /**
  17722. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17723. * are rendered back to front if in the same alpha index.
  17724. *
  17725. * @param a The first submesh
  17726. * @param b The second submesh
  17727. * @returns The result of the comparison
  17728. */
  17729. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17730. /**
  17731. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17732. * are rendered back to front.
  17733. *
  17734. * @param a The first submesh
  17735. * @param b The second submesh
  17736. * @returns The result of the comparison
  17737. */
  17738. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17739. /**
  17740. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17741. * are rendered front to back (prevent overdraw).
  17742. *
  17743. * @param a The first submesh
  17744. * @param b The second submesh
  17745. * @returns The result of the comparison
  17746. */
  17747. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17748. /**
  17749. * Resets the different lists of submeshes to prepare a new frame.
  17750. */
  17751. prepare(): void;
  17752. dispose(): void;
  17753. /**
  17754. * Inserts the submesh in its correct queue depending on its material.
  17755. * @param subMesh The submesh to dispatch
  17756. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17757. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17758. */
  17759. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17760. dispatchSprites(spriteManager: ISpriteManager): void;
  17761. dispatchParticles(particleSystem: IParticleSystem): void;
  17762. private _renderParticles;
  17763. private _renderSprites;
  17764. }
  17765. }
  17766. declare module "babylonjs/Rendering/renderingManager" {
  17767. import { Nullable } from "babylonjs/types";
  17768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17769. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17770. import { SmartArray } from "babylonjs/Misc/smartArray";
  17771. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17772. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17773. import { Material } from "babylonjs/Materials/material";
  17774. import { Scene } from "babylonjs/scene";
  17775. import { Camera } from "babylonjs/Cameras/camera";
  17776. /**
  17777. * Interface describing the different options available in the rendering manager
  17778. * regarding Auto Clear between groups.
  17779. */
  17780. export interface IRenderingManagerAutoClearSetup {
  17781. /**
  17782. * Defines whether or not autoclear is enable.
  17783. */
  17784. autoClear: boolean;
  17785. /**
  17786. * Defines whether or not to autoclear the depth buffer.
  17787. */
  17788. depth: boolean;
  17789. /**
  17790. * Defines whether or not to autoclear the stencil buffer.
  17791. */
  17792. stencil: boolean;
  17793. }
  17794. /**
  17795. * This class is used by the onRenderingGroupObservable
  17796. */
  17797. export class RenderingGroupInfo {
  17798. /**
  17799. * The Scene that being rendered
  17800. */
  17801. scene: Scene;
  17802. /**
  17803. * The camera currently used for the rendering pass
  17804. */
  17805. camera: Nullable<Camera>;
  17806. /**
  17807. * The ID of the renderingGroup being processed
  17808. */
  17809. renderingGroupId: number;
  17810. }
  17811. /**
  17812. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17813. * It is enable to manage the different groups as well as the different necessary sort functions.
  17814. * This should not be used directly aside of the few static configurations
  17815. */
  17816. export class RenderingManager {
  17817. /**
  17818. * The max id used for rendering groups (not included)
  17819. */
  17820. static MAX_RENDERINGGROUPS: number;
  17821. /**
  17822. * The min id used for rendering groups (included)
  17823. */
  17824. static MIN_RENDERINGGROUPS: number;
  17825. /**
  17826. * Used to globally prevent autoclearing scenes.
  17827. */
  17828. static AUTOCLEAR: boolean;
  17829. /**
  17830. * @hidden
  17831. */
  17832. _useSceneAutoClearSetup: boolean;
  17833. private _scene;
  17834. private _renderingGroups;
  17835. private _depthStencilBufferAlreadyCleaned;
  17836. private _autoClearDepthStencil;
  17837. private _customOpaqueSortCompareFn;
  17838. private _customAlphaTestSortCompareFn;
  17839. private _customTransparentSortCompareFn;
  17840. private _renderingGroupInfo;
  17841. /**
  17842. * Instantiates a new rendering group for a particular scene
  17843. * @param scene Defines the scene the groups belongs to
  17844. */
  17845. constructor(scene: Scene);
  17846. private _clearDepthStencilBuffer;
  17847. /**
  17848. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17849. * @hidden
  17850. */
  17851. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17852. /**
  17853. * Resets the different information of the group to prepare a new frame
  17854. * @hidden
  17855. */
  17856. reset(): void;
  17857. /**
  17858. * Dispose and release the group and its associated resources.
  17859. * @hidden
  17860. */
  17861. dispose(): void;
  17862. /**
  17863. * Clear the info related to rendering groups preventing retention points during dispose.
  17864. */
  17865. freeRenderingGroups(): void;
  17866. private _prepareRenderingGroup;
  17867. /**
  17868. * Add a sprite manager to the rendering manager in order to render it this frame.
  17869. * @param spriteManager Define the sprite manager to render
  17870. */
  17871. dispatchSprites(spriteManager: ISpriteManager): void;
  17872. /**
  17873. * Add a particle system to the rendering manager in order to render it this frame.
  17874. * @param particleSystem Define the particle system to render
  17875. */
  17876. dispatchParticles(particleSystem: IParticleSystem): void;
  17877. /**
  17878. * Add a submesh to the manager in order to render it this frame
  17879. * @param subMesh The submesh to dispatch
  17880. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17881. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17882. */
  17883. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17884. /**
  17885. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17886. * This allowed control for front to back rendering or reversly depending of the special needs.
  17887. *
  17888. * @param renderingGroupId The rendering group id corresponding to its index
  17889. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17890. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17891. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17892. */
  17893. 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;
  17894. /**
  17895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17896. *
  17897. * @param renderingGroupId The rendering group id corresponding to its index
  17898. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17899. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17900. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17901. */
  17902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17903. /**
  17904. * Gets the current auto clear configuration for one rendering group of the rendering
  17905. * manager.
  17906. * @param index the rendering group index to get the information for
  17907. * @returns The auto clear setup for the requested rendering group
  17908. */
  17909. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17910. }
  17911. }
  17912. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17913. import { Observable } from "babylonjs/Misc/observable";
  17914. import { SmartArray } from "babylonjs/Misc/smartArray";
  17915. import { Nullable } from "babylonjs/types";
  17916. import { Camera } from "babylonjs/Cameras/camera";
  17917. import { Scene } from "babylonjs/scene";
  17918. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17919. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17923. import { Texture } from "babylonjs/Materials/Textures/texture";
  17924. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17925. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17926. import { Engine } from "babylonjs/Engines/engine";
  17927. /**
  17928. * This Helps creating a texture that will be created from a camera in your scene.
  17929. * It is basically a dynamic texture that could be used to create special effects for instance.
  17930. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17931. */
  17932. export class RenderTargetTexture extends Texture {
  17933. isCube: boolean;
  17934. /**
  17935. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17936. */
  17937. static readonly REFRESHRATE_RENDER_ONCE: number;
  17938. /**
  17939. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17940. */
  17941. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17942. /**
  17943. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17944. * the central point of your effect and can save a lot of performances.
  17945. */
  17946. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17947. /**
  17948. * Use this predicate to dynamically define the list of mesh you want to render.
  17949. * If set, the renderList property will be overwritten.
  17950. */
  17951. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17952. private _renderList;
  17953. /**
  17954. * Use this list to define the list of mesh you want to render.
  17955. */
  17956. renderList: Nullable<Array<AbstractMesh>>;
  17957. private _hookArray;
  17958. /**
  17959. * Define if particles should be rendered in your texture.
  17960. */
  17961. renderParticles: boolean;
  17962. /**
  17963. * Define if sprites should be rendered in your texture.
  17964. */
  17965. renderSprites: boolean;
  17966. /**
  17967. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17968. */
  17969. coordinatesMode: number;
  17970. /**
  17971. * Define the camera used to render the texture.
  17972. */
  17973. activeCamera: Nullable<Camera>;
  17974. /**
  17975. * Override the render function of the texture with your own one.
  17976. */
  17977. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17978. /**
  17979. * Define if camera post processes should be use while rendering the texture.
  17980. */
  17981. useCameraPostProcesses: boolean;
  17982. /**
  17983. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17984. */
  17985. ignoreCameraViewport: boolean;
  17986. private _postProcessManager;
  17987. private _postProcesses;
  17988. private _resizeObserver;
  17989. /**
  17990. * An event triggered when the texture is unbind.
  17991. */
  17992. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17993. /**
  17994. * An event triggered when the texture is unbind.
  17995. */
  17996. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17997. private _onAfterUnbindObserver;
  17998. /**
  17999. * Set a after unbind callback in the texture.
  18000. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18001. */
  18002. onAfterUnbind: () => void;
  18003. /**
  18004. * An event triggered before rendering the texture
  18005. */
  18006. onBeforeRenderObservable: Observable<number>;
  18007. private _onBeforeRenderObserver;
  18008. /**
  18009. * Set a before render callback in the texture.
  18010. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18011. */
  18012. onBeforeRender: (faceIndex: number) => void;
  18013. /**
  18014. * An event triggered after rendering the texture
  18015. */
  18016. onAfterRenderObservable: Observable<number>;
  18017. private _onAfterRenderObserver;
  18018. /**
  18019. * Set a after render callback in the texture.
  18020. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18021. */
  18022. onAfterRender: (faceIndex: number) => void;
  18023. /**
  18024. * An event triggered after the texture clear
  18025. */
  18026. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18027. private _onClearObserver;
  18028. /**
  18029. * Set a clear callback in the texture.
  18030. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18031. */
  18032. onClear: (Engine: Engine) => void;
  18033. /**
  18034. * Define the clear color of the Render Target if it should be different from the scene.
  18035. */
  18036. clearColor: Color4;
  18037. protected _size: number | {
  18038. width: number;
  18039. height: number;
  18040. };
  18041. protected _initialSizeParameter: number | {
  18042. width: number;
  18043. height: number;
  18044. } | {
  18045. ratio: number;
  18046. };
  18047. protected _sizeRatio: Nullable<number>;
  18048. /** @hidden */
  18049. _generateMipMaps: boolean;
  18050. protected _renderingManager: RenderingManager;
  18051. /** @hidden */
  18052. _waitingRenderList: string[];
  18053. protected _doNotChangeAspectRatio: boolean;
  18054. protected _currentRefreshId: number;
  18055. protected _refreshRate: number;
  18056. protected _textureMatrix: Matrix;
  18057. protected _samples: number;
  18058. protected _renderTargetOptions: RenderTargetCreationOptions;
  18059. /**
  18060. * Gets render target creation options that were used.
  18061. */
  18062. readonly renderTargetOptions: RenderTargetCreationOptions;
  18063. protected _engine: Engine;
  18064. protected _onRatioRescale(): void;
  18065. /**
  18066. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18067. * It must define where the camera used to render the texture is set
  18068. */
  18069. boundingBoxPosition: Vector3;
  18070. private _boundingBoxSize;
  18071. /**
  18072. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18073. * When defined, the cubemap will switch to local mode
  18074. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18075. * @example https://www.babylonjs-playground.com/#RNASML
  18076. */
  18077. boundingBoxSize: Vector3;
  18078. /**
  18079. * In case the RTT has been created with a depth texture, get the associated
  18080. * depth texture.
  18081. * Otherwise, return null.
  18082. */
  18083. depthStencilTexture: Nullable<InternalTexture>;
  18084. /**
  18085. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18086. * or used a shadow, depth texture...
  18087. * @param name The friendly name of the texture
  18088. * @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)
  18089. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18090. * @param generateMipMaps True if mip maps need to be generated after render.
  18091. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18092. * @param type The type of the buffer in the RTT (int, half float, float...)
  18093. * @param isCube True if a cube texture needs to be created
  18094. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18095. * @param generateDepthBuffer True to generate a depth buffer
  18096. * @param generateStencilBuffer True to generate a stencil buffer
  18097. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18098. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18099. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18100. */
  18101. constructor(name: string, size: number | {
  18102. width: number;
  18103. height: number;
  18104. } | {
  18105. ratio: number;
  18106. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18107. /**
  18108. * Creates a depth stencil texture.
  18109. * This is only available in WebGL 2 or with the depth texture extension available.
  18110. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18111. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18112. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18113. */
  18114. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18115. private _processSizeParameter;
  18116. /**
  18117. * Define the number of samples to use in case of MSAA.
  18118. * It defaults to one meaning no MSAA has been enabled.
  18119. */
  18120. samples: number;
  18121. /**
  18122. * Resets the refresh counter of the texture and start bak from scratch.
  18123. * Could be useful to regenerate the texture if it is setup to render only once.
  18124. */
  18125. resetRefreshCounter(): void;
  18126. /**
  18127. * Define the refresh rate of the texture or the rendering frequency.
  18128. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18129. */
  18130. refreshRate: number;
  18131. /**
  18132. * Adds a post process to the render target rendering passes.
  18133. * @param postProcess define the post process to add
  18134. */
  18135. addPostProcess(postProcess: PostProcess): void;
  18136. /**
  18137. * Clear all the post processes attached to the render target
  18138. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18139. */
  18140. clearPostProcesses(dispose?: boolean): void;
  18141. /**
  18142. * Remove one of the post process from the list of attached post processes to the texture
  18143. * @param postProcess define the post process to remove from the list
  18144. */
  18145. removePostProcess(postProcess: PostProcess): void;
  18146. /** @hidden */
  18147. _shouldRender(): boolean;
  18148. /**
  18149. * Gets the actual render size of the texture.
  18150. * @returns the width of the render size
  18151. */
  18152. getRenderSize(): number;
  18153. /**
  18154. * Gets the actual render width of the texture.
  18155. * @returns the width of the render size
  18156. */
  18157. getRenderWidth(): number;
  18158. /**
  18159. * Gets the actual render height of the texture.
  18160. * @returns the height of the render size
  18161. */
  18162. getRenderHeight(): number;
  18163. /**
  18164. * Get if the texture can be rescaled or not.
  18165. */
  18166. readonly canRescale: boolean;
  18167. /**
  18168. * Resize the texture using a ratio.
  18169. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18170. */
  18171. scale(ratio: number): void;
  18172. /**
  18173. * Get the texture reflection matrix used to rotate/transform the reflection.
  18174. * @returns the reflection matrix
  18175. */
  18176. getReflectionTextureMatrix(): Matrix;
  18177. /**
  18178. * Resize the texture to a new desired size.
  18179. * Be carrefull as it will recreate all the data in the new texture.
  18180. * @param size Define the new size. It can be:
  18181. * - a number for squared texture,
  18182. * - an object containing { width: number, height: number }
  18183. * - or an object containing a ratio { ratio: number }
  18184. */
  18185. resize(size: number | {
  18186. width: number;
  18187. height: number;
  18188. } | {
  18189. ratio: number;
  18190. }): void;
  18191. /**
  18192. * Renders all the objects from the render list into the texture.
  18193. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18194. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18195. */
  18196. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18197. private _bestReflectionRenderTargetDimension;
  18198. /**
  18199. * @hidden
  18200. * @param faceIndex face index to bind to if this is a cubetexture
  18201. */
  18202. _bindFrameBuffer(faceIndex?: number): void;
  18203. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18204. private renderToTarget;
  18205. /**
  18206. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18207. * This allowed control for front to back rendering or reversly depending of the special needs.
  18208. *
  18209. * @param renderingGroupId The rendering group id corresponding to its index
  18210. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18211. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18212. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18213. */
  18214. 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;
  18215. /**
  18216. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18217. *
  18218. * @param renderingGroupId The rendering group id corresponding to its index
  18219. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18220. */
  18221. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18222. /**
  18223. * Clones the texture.
  18224. * @returns the cloned texture
  18225. */
  18226. clone(): RenderTargetTexture;
  18227. /**
  18228. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18229. * @returns The JSON representation of the texture
  18230. */
  18231. serialize(): any;
  18232. /**
  18233. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18234. */
  18235. disposeFramebufferObjects(): void;
  18236. /**
  18237. * Dispose the texture and release its associated resources.
  18238. */
  18239. dispose(): void;
  18240. /** @hidden */
  18241. _rebuild(): void;
  18242. /**
  18243. * Clear the info related to rendering groups preventing retention point in material dispose.
  18244. */
  18245. freeRenderingGroups(): void;
  18246. /**
  18247. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18248. * @returns the view count
  18249. */
  18250. getViewCount(): number;
  18251. }
  18252. /**
  18253. * Renders to multiple views with a single draw call
  18254. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  18255. */
  18256. export class MultiviewRenderTarget extends RenderTargetTexture {
  18257. /**
  18258. * Creates a multiview render target
  18259. * @param scene scene used with the render target
  18260. * @param size the size of the render target (used for each view)
  18261. */
  18262. constructor(scene: Scene, size?: number | {
  18263. width: number;
  18264. height: number;
  18265. } | {
  18266. ratio: number;
  18267. });
  18268. /**
  18269. * @hidden
  18270. * @param faceIndex the face index, if its a cube texture
  18271. */
  18272. _bindFrameBuffer(faceIndex?: number): void;
  18273. /**
  18274. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18275. * @returns the view count
  18276. */
  18277. getViewCount(): number;
  18278. }
  18279. }
  18280. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18281. import { Scene } from "babylonjs/scene";
  18282. import { Plane } from "babylonjs/Maths/math";
  18283. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18284. /**
  18285. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18286. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18287. * You can then easily use it as a reflectionTexture on a flat surface.
  18288. * In case the surface is not a plane, please consider relying on reflection probes.
  18289. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18290. */
  18291. export class MirrorTexture extends RenderTargetTexture {
  18292. private scene;
  18293. /**
  18294. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18295. * 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.
  18296. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18297. */
  18298. mirrorPlane: Plane;
  18299. /**
  18300. * Define the blur ratio used to blur the reflection if needed.
  18301. */
  18302. blurRatio: number;
  18303. /**
  18304. * Define the adaptive blur kernel used to blur the reflection if needed.
  18305. * This will autocompute the closest best match for the `blurKernel`
  18306. */
  18307. adaptiveBlurKernel: number;
  18308. /**
  18309. * Define the blur kernel used to blur the reflection if needed.
  18310. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18311. */
  18312. blurKernel: number;
  18313. /**
  18314. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18315. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18316. */
  18317. blurKernelX: number;
  18318. /**
  18319. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18320. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18321. */
  18322. blurKernelY: number;
  18323. private _autoComputeBlurKernel;
  18324. protected _onRatioRescale(): void;
  18325. private _updateGammaSpace;
  18326. private _imageProcessingConfigChangeObserver;
  18327. private _transformMatrix;
  18328. private _mirrorMatrix;
  18329. private _savedViewMatrix;
  18330. private _blurX;
  18331. private _blurY;
  18332. private _adaptiveBlurKernel;
  18333. private _blurKernelX;
  18334. private _blurKernelY;
  18335. private _blurRatio;
  18336. /**
  18337. * Instantiates a Mirror Texture.
  18338. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18339. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18340. * You can then easily use it as a reflectionTexture on a flat surface.
  18341. * In case the surface is not a plane, please consider relying on reflection probes.
  18342. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18343. * @param name
  18344. * @param size
  18345. * @param scene
  18346. * @param generateMipMaps
  18347. * @param type
  18348. * @param samplingMode
  18349. * @param generateDepthBuffer
  18350. */
  18351. constructor(name: string, size: number | {
  18352. width: number;
  18353. height: number;
  18354. } | {
  18355. ratio: number;
  18356. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18357. private _preparePostProcesses;
  18358. /**
  18359. * Clone the mirror texture.
  18360. * @returns the cloned texture
  18361. */
  18362. clone(): MirrorTexture;
  18363. /**
  18364. * Serialize the texture to a JSON representation you could use in Parse later on
  18365. * @returns the serialized JSON representation
  18366. */
  18367. serialize(): any;
  18368. /**
  18369. * Dispose the texture and release its associated resources.
  18370. */
  18371. dispose(): void;
  18372. }
  18373. }
  18374. declare module "babylonjs/Materials/Textures/texture" {
  18375. import { Observable } from "babylonjs/Misc/observable";
  18376. import { Nullable } from "babylonjs/types";
  18377. import { Scene } from "babylonjs/scene";
  18378. import { Matrix } from "babylonjs/Maths/math";
  18379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18380. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18381. /**
  18382. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18383. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18384. */
  18385. export class Texture extends BaseTexture {
  18386. /** @hidden */
  18387. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18388. /** @hidden */
  18389. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18390. /** @hidden */
  18391. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18392. /** nearest is mag = nearest and min = nearest and mip = linear */
  18393. static readonly NEAREST_SAMPLINGMODE: number;
  18394. /** nearest is mag = nearest and min = nearest and mip = linear */
  18395. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18396. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18397. static readonly BILINEAR_SAMPLINGMODE: number;
  18398. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18399. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18400. /** Trilinear is mag = linear and min = linear and mip = linear */
  18401. static readonly TRILINEAR_SAMPLINGMODE: number;
  18402. /** Trilinear is mag = linear and min = linear and mip = linear */
  18403. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18404. /** mag = nearest and min = nearest and mip = nearest */
  18405. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18406. /** mag = nearest and min = linear and mip = nearest */
  18407. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18408. /** mag = nearest and min = linear and mip = linear */
  18409. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18410. /** mag = nearest and min = linear and mip = none */
  18411. static readonly NEAREST_LINEAR: number;
  18412. /** mag = nearest and min = nearest and mip = none */
  18413. static readonly NEAREST_NEAREST: number;
  18414. /** mag = linear and min = nearest and mip = nearest */
  18415. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18416. /** mag = linear and min = nearest and mip = linear */
  18417. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18418. /** mag = linear and min = linear and mip = none */
  18419. static readonly LINEAR_LINEAR: number;
  18420. /** mag = linear and min = nearest and mip = none */
  18421. static readonly LINEAR_NEAREST: number;
  18422. /** Explicit coordinates mode */
  18423. static readonly EXPLICIT_MODE: number;
  18424. /** Spherical coordinates mode */
  18425. static readonly SPHERICAL_MODE: number;
  18426. /** Planar coordinates mode */
  18427. static readonly PLANAR_MODE: number;
  18428. /** Cubic coordinates mode */
  18429. static readonly CUBIC_MODE: number;
  18430. /** Projection coordinates mode */
  18431. static readonly PROJECTION_MODE: number;
  18432. /** Inverse Cubic coordinates mode */
  18433. static readonly SKYBOX_MODE: number;
  18434. /** Inverse Cubic coordinates mode */
  18435. static readonly INVCUBIC_MODE: number;
  18436. /** Equirectangular coordinates mode */
  18437. static readonly EQUIRECTANGULAR_MODE: number;
  18438. /** Equirectangular Fixed coordinates mode */
  18439. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18440. /** Equirectangular Fixed Mirrored coordinates mode */
  18441. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18442. /** Texture is not repeating outside of 0..1 UVs */
  18443. static readonly CLAMP_ADDRESSMODE: number;
  18444. /** Texture is repeating outside of 0..1 UVs */
  18445. static readonly WRAP_ADDRESSMODE: number;
  18446. /** Texture is repeating and mirrored */
  18447. static readonly MIRROR_ADDRESSMODE: number;
  18448. /**
  18449. * 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
  18450. */
  18451. static UseSerializedUrlIfAny: boolean;
  18452. /**
  18453. * Define the url of the texture.
  18454. */
  18455. url: Nullable<string>;
  18456. /**
  18457. * Define an offset on the texture to offset the u coordinates of the UVs
  18458. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18459. */
  18460. uOffset: number;
  18461. /**
  18462. * Define an offset on the texture to offset the v coordinates of the UVs
  18463. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18464. */
  18465. vOffset: number;
  18466. /**
  18467. * Define an offset on the texture to scale the u coordinates of the UVs
  18468. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18469. */
  18470. uScale: number;
  18471. /**
  18472. * Define an offset on the texture to scale the v coordinates of the UVs
  18473. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18474. */
  18475. vScale: number;
  18476. /**
  18477. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18478. * @see http://doc.babylonjs.com/how_to/more_materials
  18479. */
  18480. uAng: number;
  18481. /**
  18482. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18483. * @see http://doc.babylonjs.com/how_to/more_materials
  18484. */
  18485. vAng: number;
  18486. /**
  18487. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18488. * @see http://doc.babylonjs.com/how_to/more_materials
  18489. */
  18490. wAng: number;
  18491. /**
  18492. * Defines the center of rotation (U)
  18493. */
  18494. uRotationCenter: number;
  18495. /**
  18496. * Defines the center of rotation (V)
  18497. */
  18498. vRotationCenter: number;
  18499. /**
  18500. * Defines the center of rotation (W)
  18501. */
  18502. wRotationCenter: number;
  18503. /**
  18504. * Are mip maps generated for this texture or not.
  18505. */
  18506. readonly noMipmap: boolean;
  18507. /**
  18508. * List of inspectable custom properties (used by the Inspector)
  18509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18510. */
  18511. inspectableCustomProperties: IInspectable[];
  18512. private _noMipmap;
  18513. /** @hidden */
  18514. _invertY: boolean;
  18515. private _rowGenerationMatrix;
  18516. private _cachedTextureMatrix;
  18517. private _projectionModeMatrix;
  18518. private _t0;
  18519. private _t1;
  18520. private _t2;
  18521. private _cachedUOffset;
  18522. private _cachedVOffset;
  18523. private _cachedUScale;
  18524. private _cachedVScale;
  18525. private _cachedUAng;
  18526. private _cachedVAng;
  18527. private _cachedWAng;
  18528. private _cachedProjectionMatrixId;
  18529. private _cachedCoordinatesMode;
  18530. /** @hidden */
  18531. protected _initialSamplingMode: number;
  18532. /** @hidden */
  18533. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18534. private _deleteBuffer;
  18535. protected _format: Nullable<number>;
  18536. private _delayedOnLoad;
  18537. private _delayedOnError;
  18538. /**
  18539. * Observable triggered once the texture has been loaded.
  18540. */
  18541. onLoadObservable: Observable<Texture>;
  18542. protected _isBlocking: boolean;
  18543. /**
  18544. * Is the texture preventing material to render while loading.
  18545. * If false, a default texture will be used instead of the loading one during the preparation step.
  18546. */
  18547. isBlocking: boolean;
  18548. /**
  18549. * Get the current sampling mode associated with the texture.
  18550. */
  18551. readonly samplingMode: number;
  18552. /**
  18553. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18554. */
  18555. readonly invertY: boolean;
  18556. /**
  18557. * Instantiates a new texture.
  18558. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18559. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18560. * @param url define the url of the picture to load as a texture
  18561. * @param scene define the scene the texture will belong to
  18562. * @param noMipmap define if the texture will require mip maps or not
  18563. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18564. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18565. * @param onLoad define a callback triggered when the texture has been loaded
  18566. * @param onError define a callback triggered when an error occurred during the loading session
  18567. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18568. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18569. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18570. */
  18571. 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);
  18572. /**
  18573. * Update the url (and optional buffer) of this texture if url was null during construction.
  18574. * @param url the url of the texture
  18575. * @param buffer the buffer of the texture (defaults to null)
  18576. * @param onLoad callback called when the texture is loaded (defaults to null)
  18577. */
  18578. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18579. /**
  18580. * Finish the loading sequence of a texture flagged as delayed load.
  18581. * @hidden
  18582. */
  18583. delayLoad(): void;
  18584. private _prepareRowForTextureGeneration;
  18585. /**
  18586. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18587. * @returns the transform matrix of the texture.
  18588. */
  18589. getTextureMatrix(): Matrix;
  18590. /**
  18591. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18592. * @returns The reflection texture transform
  18593. */
  18594. getReflectionTextureMatrix(): Matrix;
  18595. /**
  18596. * Clones the texture.
  18597. * @returns the cloned texture
  18598. */
  18599. clone(): Texture;
  18600. /**
  18601. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18602. * @returns The JSON representation of the texture
  18603. */
  18604. serialize(): any;
  18605. /**
  18606. * Get the current class name of the texture useful for serialization or dynamic coding.
  18607. * @returns "Texture"
  18608. */
  18609. getClassName(): string;
  18610. /**
  18611. * Dispose the texture and release its associated resources.
  18612. */
  18613. dispose(): void;
  18614. /**
  18615. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18616. * @param parsedTexture Define the JSON representation of the texture
  18617. * @param scene Define the scene the parsed texture should be instantiated in
  18618. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18619. * @returns The parsed texture if successful
  18620. */
  18621. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18622. /**
  18623. * Creates a texture from its base 64 representation.
  18624. * @param data Define the base64 payload without the data: prefix
  18625. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18626. * @param scene Define the scene the texture should belong to
  18627. * @param noMipmap Forces the texture to not create mip map information if true
  18628. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18629. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18630. * @param onLoad define a callback triggered when the texture has been loaded
  18631. * @param onError define a callback triggered when an error occurred during the loading session
  18632. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18633. * @returns the created texture
  18634. */
  18635. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18636. /**
  18637. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18638. * @param data Define the base64 payload without the data: prefix
  18639. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18640. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18641. * @param scene Define the scene the texture should belong to
  18642. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18643. * @param noMipmap Forces the texture to not create mip map information if true
  18644. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18645. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18646. * @param onLoad define a callback triggered when the texture has been loaded
  18647. * @param onError define a callback triggered when an error occurred during the loading session
  18648. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18649. * @returns the created texture
  18650. */
  18651. 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;
  18652. }
  18653. }
  18654. declare module "babylonjs/Materials/Textures/rawTexture" {
  18655. import { Scene } from "babylonjs/scene";
  18656. import { Texture } from "babylonjs/Materials/Textures/texture";
  18657. /**
  18658. * Raw texture can help creating a texture directly from an array of data.
  18659. * This can be super useful if you either get the data from an uncompressed source or
  18660. * if you wish to create your texture pixel by pixel.
  18661. */
  18662. export class RawTexture extends Texture {
  18663. /**
  18664. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18665. */
  18666. format: number;
  18667. private _engine;
  18668. /**
  18669. * Instantiates a new RawTexture.
  18670. * Raw texture can help creating a texture directly from an array of data.
  18671. * This can be super useful if you either get the data from an uncompressed source or
  18672. * if you wish to create your texture pixel by pixel.
  18673. * @param data define the array of data to use to create the texture
  18674. * @param width define the width of the texture
  18675. * @param height define the height of the texture
  18676. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18677. * @param scene define the scene the texture belongs to
  18678. * @param generateMipMaps define whether mip maps should be generated or not
  18679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18682. */
  18683. constructor(data: ArrayBufferView, width: number, height: number,
  18684. /**
  18685. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18686. */
  18687. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18688. /**
  18689. * Updates the texture underlying data.
  18690. * @param data Define the new data of the texture
  18691. */
  18692. update(data: ArrayBufferView): void;
  18693. /**
  18694. * Creates a luminance texture from some data.
  18695. * @param data Define the texture data
  18696. * @param width Define the width of the texture
  18697. * @param height Define the height of the texture
  18698. * @param scene Define the scene the texture belongs to
  18699. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18700. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18701. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18702. * @returns the luminance texture
  18703. */
  18704. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18705. /**
  18706. * Creates a luminance alpha texture from some data.
  18707. * @param data Define the texture data
  18708. * @param width Define the width of the texture
  18709. * @param height Define the height of the texture
  18710. * @param scene Define the scene the texture belongs to
  18711. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18712. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18713. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18714. * @returns the luminance alpha texture
  18715. */
  18716. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18717. /**
  18718. * Creates an alpha texture from some data.
  18719. * @param data Define the texture data
  18720. * @param width Define the width of the texture
  18721. * @param height Define the height of the texture
  18722. * @param scene Define the scene the texture belongs to
  18723. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18726. * @returns the alpha texture
  18727. */
  18728. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18729. /**
  18730. * Creates a RGB texture from some data.
  18731. * @param data Define the texture data
  18732. * @param width Define the width of the texture
  18733. * @param height Define the height of the texture
  18734. * @param scene Define the scene the texture belongs to
  18735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18739. * @returns the RGB alpha texture
  18740. */
  18741. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18742. /**
  18743. * Creates a RGBA texture from some data.
  18744. * @param data Define the texture data
  18745. * @param width Define the width of the texture
  18746. * @param height Define the height of the texture
  18747. * @param scene Define the scene the texture belongs to
  18748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18752. * @returns the RGBA texture
  18753. */
  18754. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18755. /**
  18756. * Creates a R texture from some data.
  18757. * @param data Define the texture data
  18758. * @param width Define the width of the texture
  18759. * @param height Define the height of the texture
  18760. * @param scene Define the scene the texture belongs to
  18761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18765. * @returns the R texture
  18766. */
  18767. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18768. }
  18769. }
  18770. declare module "babylonjs/Animations/runtimeAnimation" {
  18771. import { Animation } from "babylonjs/Animations/animation";
  18772. import { Animatable } from "babylonjs/Animations/animatable";
  18773. import { Scene } from "babylonjs/scene";
  18774. /**
  18775. * Defines a runtime animation
  18776. */
  18777. export class RuntimeAnimation {
  18778. private _events;
  18779. /**
  18780. * The current frame of the runtime animation
  18781. */
  18782. private _currentFrame;
  18783. /**
  18784. * The animation used by the runtime animation
  18785. */
  18786. private _animation;
  18787. /**
  18788. * The target of the runtime animation
  18789. */
  18790. private _target;
  18791. /**
  18792. * The initiating animatable
  18793. */
  18794. private _host;
  18795. /**
  18796. * The original value of the runtime animation
  18797. */
  18798. private _originalValue;
  18799. /**
  18800. * The original blend value of the runtime animation
  18801. */
  18802. private _originalBlendValue;
  18803. /**
  18804. * The offsets cache of the runtime animation
  18805. */
  18806. private _offsetsCache;
  18807. /**
  18808. * The high limits cache of the runtime animation
  18809. */
  18810. private _highLimitsCache;
  18811. /**
  18812. * Specifies if the runtime animation has been stopped
  18813. */
  18814. private _stopped;
  18815. /**
  18816. * The blending factor of the runtime animation
  18817. */
  18818. private _blendingFactor;
  18819. /**
  18820. * The BabylonJS scene
  18821. */
  18822. private _scene;
  18823. /**
  18824. * The current value of the runtime animation
  18825. */
  18826. private _currentValue;
  18827. /** @hidden */
  18828. _workValue: any;
  18829. /**
  18830. * The active target of the runtime animation
  18831. */
  18832. private _activeTarget;
  18833. /**
  18834. * The target path of the runtime animation
  18835. */
  18836. private _targetPath;
  18837. /**
  18838. * The weight of the runtime animation
  18839. */
  18840. private _weight;
  18841. /**
  18842. * The ratio offset of the runtime animation
  18843. */
  18844. private _ratioOffset;
  18845. /**
  18846. * The previous delay of the runtime animation
  18847. */
  18848. private _previousDelay;
  18849. /**
  18850. * The previous ratio of the runtime animation
  18851. */
  18852. private _previousRatio;
  18853. /**
  18854. * Gets the current frame of the runtime animation
  18855. */
  18856. readonly currentFrame: number;
  18857. /**
  18858. * Gets the weight of the runtime animation
  18859. */
  18860. readonly weight: number;
  18861. /**
  18862. * Gets the current value of the runtime animation
  18863. */
  18864. readonly currentValue: any;
  18865. /**
  18866. * Gets the target path of the runtime animation
  18867. */
  18868. readonly targetPath: string;
  18869. /**
  18870. * Gets the actual target of the runtime animation
  18871. */
  18872. readonly target: any;
  18873. /**
  18874. * Create a new RuntimeAnimation object
  18875. * @param target defines the target of the animation
  18876. * @param animation defines the source animation object
  18877. * @param scene defines the hosting scene
  18878. * @param host defines the initiating Animatable
  18879. */
  18880. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18881. /**
  18882. * Gets the animation from the runtime animation
  18883. */
  18884. readonly animation: Animation;
  18885. /**
  18886. * Resets the runtime animation to the beginning
  18887. * @param restoreOriginal defines whether to restore the target property to the original value
  18888. */
  18889. reset(restoreOriginal?: boolean): void;
  18890. /**
  18891. * Specifies if the runtime animation is stopped
  18892. * @returns Boolean specifying if the runtime animation is stopped
  18893. */
  18894. isStopped(): boolean;
  18895. /**
  18896. * Disposes of the runtime animation
  18897. */
  18898. dispose(): void;
  18899. /**
  18900. * Interpolates the animation from the current frame
  18901. * @param currentFrame The frame to interpolate the animation to
  18902. * @param repeatCount The number of times that the animation should loop
  18903. * @param loopMode The type of looping mode to use
  18904. * @param offsetValue Animation offset value
  18905. * @param highLimitValue The high limit value
  18906. * @returns The interpolated value
  18907. */
  18908. private _interpolate;
  18909. /**
  18910. * Apply the interpolated value to the target
  18911. * @param currentValue defines the value computed by the animation
  18912. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18913. */
  18914. setValue(currentValue: any, weight?: number): void;
  18915. private _setValue;
  18916. /**
  18917. * Gets the loop pmode of the runtime animation
  18918. * @returns Loop Mode
  18919. */
  18920. private _getCorrectLoopMode;
  18921. /**
  18922. * Move the current animation to a given frame
  18923. * @param frame defines the frame to move to
  18924. */
  18925. goToFrame(frame: number): void;
  18926. /**
  18927. * @hidden Internal use only
  18928. */
  18929. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18930. /**
  18931. * Execute the current animation
  18932. * @param delay defines the delay to add to the current frame
  18933. * @param from defines the lower bound of the animation range
  18934. * @param to defines the upper bound of the animation range
  18935. * @param loop defines if the current animation must loop
  18936. * @param speedRatio defines the current speed ratio
  18937. * @param weight defines the weight of the animation (default is -1 so no weight)
  18938. * @param onLoop optional callback called when animation loops
  18939. * @returns a boolean indicating if the animation is running
  18940. */
  18941. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18942. }
  18943. }
  18944. declare module "babylonjs/Animations/animatable" {
  18945. import { Animation } from "babylonjs/Animations/animation";
  18946. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18947. import { Nullable } from "babylonjs/types";
  18948. import { Observable } from "babylonjs/Misc/observable";
  18949. import { Scene } from "babylonjs/scene";
  18950. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18951. import { Node } from "babylonjs/node";
  18952. /**
  18953. * Class used to store an actual running animation
  18954. */
  18955. export class Animatable {
  18956. /** defines the target object */
  18957. target: any;
  18958. /** defines the starting frame number (default is 0) */
  18959. fromFrame: number;
  18960. /** defines the ending frame number (default is 100) */
  18961. toFrame: number;
  18962. /** defines if the animation must loop (default is false) */
  18963. loopAnimation: boolean;
  18964. /** defines a callback to call when animation ends if it is not looping */
  18965. onAnimationEnd?: (() => void) | null | undefined;
  18966. /** defines a callback to call when animation loops */
  18967. onAnimationLoop?: (() => void) | null | undefined;
  18968. private _localDelayOffset;
  18969. private _pausedDelay;
  18970. private _runtimeAnimations;
  18971. private _paused;
  18972. private _scene;
  18973. private _speedRatio;
  18974. private _weight;
  18975. private _syncRoot;
  18976. /**
  18977. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18978. * This will only apply for non looping animation (default is true)
  18979. */
  18980. disposeOnEnd: boolean;
  18981. /**
  18982. * Gets a boolean indicating if the animation has started
  18983. */
  18984. animationStarted: boolean;
  18985. /**
  18986. * Observer raised when the animation ends
  18987. */
  18988. onAnimationEndObservable: Observable<Animatable>;
  18989. /**
  18990. * Observer raised when the animation loops
  18991. */
  18992. onAnimationLoopObservable: Observable<Animatable>;
  18993. /**
  18994. * Gets the root Animatable used to synchronize and normalize animations
  18995. */
  18996. readonly syncRoot: Animatable;
  18997. /**
  18998. * Gets the current frame of the first RuntimeAnimation
  18999. * Used to synchronize Animatables
  19000. */
  19001. readonly masterFrame: number;
  19002. /**
  19003. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19004. */
  19005. weight: number;
  19006. /**
  19007. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19008. */
  19009. speedRatio: number;
  19010. /**
  19011. * Creates a new Animatable
  19012. * @param scene defines the hosting scene
  19013. * @param target defines the target object
  19014. * @param fromFrame defines the starting frame number (default is 0)
  19015. * @param toFrame defines the ending frame number (default is 100)
  19016. * @param loopAnimation defines if the animation must loop (default is false)
  19017. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19018. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19019. * @param animations defines a group of animation to add to the new Animatable
  19020. * @param onAnimationLoop defines a callback to call when animation loops
  19021. */
  19022. constructor(scene: Scene,
  19023. /** defines the target object */
  19024. target: any,
  19025. /** defines the starting frame number (default is 0) */
  19026. fromFrame?: number,
  19027. /** defines the ending frame number (default is 100) */
  19028. toFrame?: number,
  19029. /** defines if the animation must loop (default is false) */
  19030. loopAnimation?: boolean, speedRatio?: number,
  19031. /** defines a callback to call when animation ends if it is not looping */
  19032. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19033. /** defines a callback to call when animation loops */
  19034. onAnimationLoop?: (() => void) | null | undefined);
  19035. /**
  19036. * Synchronize and normalize current Animatable with a source Animatable
  19037. * This is useful when using animation weights and when animations are not of the same length
  19038. * @param root defines the root Animatable to synchronize with
  19039. * @returns the current Animatable
  19040. */
  19041. syncWith(root: Animatable): Animatable;
  19042. /**
  19043. * Gets the list of runtime animations
  19044. * @returns an array of RuntimeAnimation
  19045. */
  19046. getAnimations(): RuntimeAnimation[];
  19047. /**
  19048. * Adds more animations to the current animatable
  19049. * @param target defines the target of the animations
  19050. * @param animations defines the new animations to add
  19051. */
  19052. appendAnimations(target: any, animations: Animation[]): void;
  19053. /**
  19054. * Gets the source animation for a specific property
  19055. * @param property defines the propertyu to look for
  19056. * @returns null or the source animation for the given property
  19057. */
  19058. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19059. /**
  19060. * Gets the runtime animation for a specific property
  19061. * @param property defines the propertyu to look for
  19062. * @returns null or the runtime animation for the given property
  19063. */
  19064. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19065. /**
  19066. * Resets the animatable to its original state
  19067. */
  19068. reset(): void;
  19069. /**
  19070. * Allows the animatable to blend with current running animations
  19071. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19072. * @param blendingSpeed defines the blending speed to use
  19073. */
  19074. enableBlending(blendingSpeed: number): void;
  19075. /**
  19076. * Disable animation blending
  19077. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19078. */
  19079. disableBlending(): void;
  19080. /**
  19081. * Jump directly to a given frame
  19082. * @param frame defines the frame to jump to
  19083. */
  19084. goToFrame(frame: number): void;
  19085. /**
  19086. * Pause the animation
  19087. */
  19088. pause(): void;
  19089. /**
  19090. * Restart the animation
  19091. */
  19092. restart(): void;
  19093. private _raiseOnAnimationEnd;
  19094. /**
  19095. * Stop and delete the current animation
  19096. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19097. * @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)
  19098. */
  19099. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19100. /**
  19101. * Wait asynchronously for the animation to end
  19102. * @returns a promise which will be fullfilled when the animation ends
  19103. */
  19104. waitAsync(): Promise<Animatable>;
  19105. /** @hidden */
  19106. _animate(delay: number): boolean;
  19107. }
  19108. module "babylonjs/scene" {
  19109. interface Scene {
  19110. /** @hidden */
  19111. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19112. /** @hidden */
  19113. _processLateAnimationBindingsForMatrices(holder: {
  19114. totalWeight: number;
  19115. animations: RuntimeAnimation[];
  19116. originalValue: Matrix;
  19117. }): any;
  19118. /** @hidden */
  19119. _processLateAnimationBindingsForQuaternions(holder: {
  19120. totalWeight: number;
  19121. animations: RuntimeAnimation[];
  19122. originalValue: Quaternion;
  19123. }, refQuaternion: Quaternion): Quaternion;
  19124. /** @hidden */
  19125. _processLateAnimationBindings(): void;
  19126. /**
  19127. * Will start the animation sequence of a given target
  19128. * @param target defines the target
  19129. * @param from defines from which frame should animation start
  19130. * @param to defines until which frame should animation run.
  19131. * @param weight defines the weight to apply to the animation (1.0 by default)
  19132. * @param loop defines if the animation loops
  19133. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19134. * @param onAnimationEnd defines the function to be executed when the animation ends
  19135. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19136. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19137. * @param onAnimationLoop defines the callback to call when an animation loops
  19138. * @returns the animatable object created for this animation
  19139. */
  19140. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19141. /**
  19142. * Will start the animation sequence of a given target
  19143. * @param target defines the target
  19144. * @param from defines from which frame should animation start
  19145. * @param to defines until which frame should animation run.
  19146. * @param loop defines if the animation loops
  19147. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19148. * @param onAnimationEnd defines the function to be executed when the animation ends
  19149. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19150. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19151. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19152. * @param onAnimationLoop defines the callback to call when an animation loops
  19153. * @returns the animatable object created for this animation
  19154. */
  19155. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19156. /**
  19157. * Will start the animation sequence of a given target and its hierarchy
  19158. * @param target defines the target
  19159. * @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.
  19160. * @param from defines from which frame should animation start
  19161. * @param to defines until which frame should animation run.
  19162. * @param loop defines if the animation loops
  19163. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19164. * @param onAnimationEnd defines the function to be executed when the animation ends
  19165. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19166. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19167. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19168. * @param onAnimationLoop defines the callback to call when an animation loops
  19169. * @returns the list of created animatables
  19170. */
  19171. 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[];
  19172. /**
  19173. * Begin a new animation on a given node
  19174. * @param target defines the target where the animation will take place
  19175. * @param animations defines the list of animations to start
  19176. * @param from defines the initial value
  19177. * @param to defines the final value
  19178. * @param loop defines if you want animation to loop (off by default)
  19179. * @param speedRatio defines the speed ratio to apply to all animations
  19180. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19181. * @param onAnimationLoop defines the callback to call when an animation loops
  19182. * @returns the list of created animatables
  19183. */
  19184. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19185. /**
  19186. * Begin a new animation on a given node and its hierarchy
  19187. * @param target defines the root node where the animation will take place
  19188. * @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.
  19189. * @param animations defines the list of animations to start
  19190. * @param from defines the initial value
  19191. * @param to defines the final value
  19192. * @param loop defines if you want animation to loop (off by default)
  19193. * @param speedRatio defines the speed ratio to apply to all animations
  19194. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19195. * @param onAnimationLoop defines the callback to call when an animation loops
  19196. * @returns the list of animatables created for all nodes
  19197. */
  19198. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19199. /**
  19200. * Gets the animatable associated with a specific target
  19201. * @param target defines the target of the animatable
  19202. * @returns the required animatable if found
  19203. */
  19204. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19205. /**
  19206. * Gets all animatables associated with a given target
  19207. * @param target defines the target to look animatables for
  19208. * @returns an array of Animatables
  19209. */
  19210. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19211. /**
  19212. * Will stop the animation of the given target
  19213. * @param target - the target
  19214. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19215. * @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)
  19216. */
  19217. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19218. /**
  19219. * Stops and removes all animations that have been applied to the scene
  19220. */
  19221. stopAllAnimations(): void;
  19222. }
  19223. }
  19224. module "babylonjs/Bones/bone" {
  19225. interface Bone {
  19226. /**
  19227. * Copy an animation range from another bone
  19228. * @param source defines the source bone
  19229. * @param rangeName defines the range name to copy
  19230. * @param frameOffset defines the frame offset
  19231. * @param rescaleAsRequired defines if rescaling must be applied if required
  19232. * @param skelDimensionsRatio defines the scaling ratio
  19233. * @returns true if operation was successful
  19234. */
  19235. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19236. }
  19237. }
  19238. }
  19239. declare module "babylonjs/Bones/skeleton" {
  19240. import { Bone } from "babylonjs/Bones/bone";
  19241. import { IAnimatable } from "babylonjs/Misc/tools";
  19242. import { Observable } from "babylonjs/Misc/observable";
  19243. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19244. import { Scene } from "babylonjs/scene";
  19245. import { Nullable } from "babylonjs/types";
  19246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19247. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19248. import { Animatable } from "babylonjs/Animations/animatable";
  19249. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19250. import { Animation } from "babylonjs/Animations/animation";
  19251. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19252. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19253. /**
  19254. * Class used to handle skinning animations
  19255. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19256. */
  19257. export class Skeleton implements IAnimatable {
  19258. /** defines the skeleton name */
  19259. name: string;
  19260. /** defines the skeleton Id */
  19261. id: string;
  19262. /**
  19263. * Defines the list of child bones
  19264. */
  19265. bones: Bone[];
  19266. /**
  19267. * Defines an estimate of the dimension of the skeleton at rest
  19268. */
  19269. dimensionsAtRest: Vector3;
  19270. /**
  19271. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19272. */
  19273. needInitialSkinMatrix: boolean;
  19274. /**
  19275. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19276. */
  19277. overrideMesh: Nullable<AbstractMesh>;
  19278. /**
  19279. * Gets the list of animations attached to this skeleton
  19280. */
  19281. animations: Array<Animation>;
  19282. private _scene;
  19283. private _isDirty;
  19284. private _transformMatrices;
  19285. private _transformMatrixTexture;
  19286. private _meshesWithPoseMatrix;
  19287. private _animatables;
  19288. private _identity;
  19289. private _synchronizedWithMesh;
  19290. private _ranges;
  19291. private _lastAbsoluteTransformsUpdateId;
  19292. private _canUseTextureForBones;
  19293. private _uniqueId;
  19294. /** @hidden */
  19295. _numBonesWithLinkedTransformNode: number;
  19296. /**
  19297. * Specifies if the skeleton should be serialized
  19298. */
  19299. doNotSerialize: boolean;
  19300. private _useTextureToStoreBoneMatrices;
  19301. /**
  19302. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19303. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19304. */
  19305. useTextureToStoreBoneMatrices: boolean;
  19306. private _animationPropertiesOverride;
  19307. /**
  19308. * Gets or sets the animation properties override
  19309. */
  19310. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19311. /**
  19312. * List of inspectable custom properties (used by the Inspector)
  19313. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19314. */
  19315. inspectableCustomProperties: IInspectable[];
  19316. /**
  19317. * An observable triggered before computing the skeleton's matrices
  19318. */
  19319. onBeforeComputeObservable: Observable<Skeleton>;
  19320. /**
  19321. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19322. */
  19323. readonly isUsingTextureForMatrices: boolean;
  19324. /**
  19325. * Gets the unique ID of this skeleton
  19326. */
  19327. readonly uniqueId: number;
  19328. /**
  19329. * Creates a new skeleton
  19330. * @param name defines the skeleton name
  19331. * @param id defines the skeleton Id
  19332. * @param scene defines the hosting scene
  19333. */
  19334. constructor(
  19335. /** defines the skeleton name */
  19336. name: string,
  19337. /** defines the skeleton Id */
  19338. id: string, scene: Scene);
  19339. /**
  19340. * Gets the current object class name.
  19341. * @return the class name
  19342. */
  19343. getClassName(): string;
  19344. /**
  19345. * Returns an array containing the root bones
  19346. * @returns an array containing the root bones
  19347. */
  19348. getChildren(): Array<Bone>;
  19349. /**
  19350. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19351. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19352. * @returns a Float32Array containing matrices data
  19353. */
  19354. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19355. /**
  19356. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19357. * @returns a raw texture containing the data
  19358. */
  19359. getTransformMatrixTexture(): Nullable<RawTexture>;
  19360. /**
  19361. * Gets the current hosting scene
  19362. * @returns a scene object
  19363. */
  19364. getScene(): Scene;
  19365. /**
  19366. * Gets a string representing the current skeleton data
  19367. * @param fullDetails defines a boolean indicating if we want a verbose version
  19368. * @returns a string representing the current skeleton data
  19369. */
  19370. toString(fullDetails?: boolean): string;
  19371. /**
  19372. * Get bone's index searching by name
  19373. * @param name defines bone's name to search for
  19374. * @return the indice of the bone. Returns -1 if not found
  19375. */
  19376. getBoneIndexByName(name: string): number;
  19377. /**
  19378. * Creater a new animation range
  19379. * @param name defines the name of the range
  19380. * @param from defines the start key
  19381. * @param to defines the end key
  19382. */
  19383. createAnimationRange(name: string, from: number, to: number): void;
  19384. /**
  19385. * Delete a specific animation range
  19386. * @param name defines the name of the range
  19387. * @param deleteFrames defines if frames must be removed as well
  19388. */
  19389. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19390. /**
  19391. * Gets a specific animation range
  19392. * @param name defines the name of the range to look for
  19393. * @returns the requested animation range or null if not found
  19394. */
  19395. getAnimationRange(name: string): Nullable<AnimationRange>;
  19396. /**
  19397. * Gets the list of all animation ranges defined on this skeleton
  19398. * @returns an array
  19399. */
  19400. getAnimationRanges(): Nullable<AnimationRange>[];
  19401. /**
  19402. * Copy animation range from a source skeleton.
  19403. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19404. * @param source defines the source skeleton
  19405. * @param name defines the name of the range to copy
  19406. * @param rescaleAsRequired defines if rescaling must be applied if required
  19407. * @returns true if operation was successful
  19408. */
  19409. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19410. /**
  19411. * Forces the skeleton to go to rest pose
  19412. */
  19413. returnToRest(): void;
  19414. private _getHighestAnimationFrame;
  19415. /**
  19416. * Begin a specific animation range
  19417. * @param name defines the name of the range to start
  19418. * @param loop defines if looping must be turned on (false by default)
  19419. * @param speedRatio defines the speed ratio to apply (1 by default)
  19420. * @param onAnimationEnd defines a callback which will be called when animation will end
  19421. * @returns a new animatable
  19422. */
  19423. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19424. /** @hidden */
  19425. _markAsDirty(): void;
  19426. /** @hidden */
  19427. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19428. /** @hidden */
  19429. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19430. private _computeTransformMatrices;
  19431. /**
  19432. * Build all resources required to render a skeleton
  19433. */
  19434. prepare(): void;
  19435. /**
  19436. * Gets the list of animatables currently running for this skeleton
  19437. * @returns an array of animatables
  19438. */
  19439. getAnimatables(): IAnimatable[];
  19440. /**
  19441. * Clone the current skeleton
  19442. * @param name defines the name of the new skeleton
  19443. * @param id defines the id of the enw skeleton
  19444. * @returns the new skeleton
  19445. */
  19446. clone(name: string, id: string): Skeleton;
  19447. /**
  19448. * Enable animation blending for this skeleton
  19449. * @param blendingSpeed defines the blending speed to apply
  19450. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19451. */
  19452. enableBlending(blendingSpeed?: number): void;
  19453. /**
  19454. * Releases all resources associated with the current skeleton
  19455. */
  19456. dispose(): void;
  19457. /**
  19458. * Serialize the skeleton in a JSON object
  19459. * @returns a JSON object
  19460. */
  19461. serialize(): any;
  19462. /**
  19463. * Creates a new skeleton from serialized data
  19464. * @param parsedSkeleton defines the serialized data
  19465. * @param scene defines the hosting scene
  19466. * @returns a new skeleton
  19467. */
  19468. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19469. /**
  19470. * Compute all node absolute transforms
  19471. * @param forceUpdate defines if computation must be done even if cache is up to date
  19472. */
  19473. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19474. /**
  19475. * Gets the root pose matrix
  19476. * @returns a matrix
  19477. */
  19478. getPoseMatrix(): Nullable<Matrix>;
  19479. /**
  19480. * Sorts bones per internal index
  19481. */
  19482. sortBones(): void;
  19483. private _sortBones;
  19484. }
  19485. }
  19486. declare module "babylonjs/Morph/morphTarget" {
  19487. import { IAnimatable } from "babylonjs/Misc/tools";
  19488. import { Observable } from "babylonjs/Misc/observable";
  19489. import { Nullable, FloatArray } from "babylonjs/types";
  19490. import { Scene } from "babylonjs/scene";
  19491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19493. /**
  19494. * Defines a target to use with MorphTargetManager
  19495. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19496. */
  19497. export class MorphTarget implements IAnimatable {
  19498. /** defines the name of the target */
  19499. name: string;
  19500. /**
  19501. * Gets or sets the list of animations
  19502. */
  19503. animations: import("babylonjs/Animations/animation").Animation[];
  19504. private _scene;
  19505. private _positions;
  19506. private _normals;
  19507. private _tangents;
  19508. private _influence;
  19509. /**
  19510. * Observable raised when the influence changes
  19511. */
  19512. onInfluenceChanged: Observable<boolean>;
  19513. /** @hidden */
  19514. _onDataLayoutChanged: Observable<void>;
  19515. /**
  19516. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19517. */
  19518. influence: number;
  19519. /**
  19520. * Gets or sets the id of the morph Target
  19521. */
  19522. id: string;
  19523. private _animationPropertiesOverride;
  19524. /**
  19525. * Gets or sets the animation properties override
  19526. */
  19527. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19528. /**
  19529. * Creates a new MorphTarget
  19530. * @param name defines the name of the target
  19531. * @param influence defines the influence to use
  19532. * @param scene defines the scene the morphtarget belongs to
  19533. */
  19534. constructor(
  19535. /** defines the name of the target */
  19536. name: string, influence?: number, scene?: Nullable<Scene>);
  19537. /**
  19538. * Gets a boolean defining if the target contains position data
  19539. */
  19540. readonly hasPositions: boolean;
  19541. /**
  19542. * Gets a boolean defining if the target contains normal data
  19543. */
  19544. readonly hasNormals: boolean;
  19545. /**
  19546. * Gets a boolean defining if the target contains tangent data
  19547. */
  19548. readonly hasTangents: boolean;
  19549. /**
  19550. * Affects position data to this target
  19551. * @param data defines the position data to use
  19552. */
  19553. setPositions(data: Nullable<FloatArray>): void;
  19554. /**
  19555. * Gets the position data stored in this target
  19556. * @returns a FloatArray containing the position data (or null if not present)
  19557. */
  19558. getPositions(): Nullable<FloatArray>;
  19559. /**
  19560. * Affects normal data to this target
  19561. * @param data defines the normal data to use
  19562. */
  19563. setNormals(data: Nullable<FloatArray>): void;
  19564. /**
  19565. * Gets the normal data stored in this target
  19566. * @returns a FloatArray containing the normal data (or null if not present)
  19567. */
  19568. getNormals(): Nullable<FloatArray>;
  19569. /**
  19570. * Affects tangent data to this target
  19571. * @param data defines the tangent data to use
  19572. */
  19573. setTangents(data: Nullable<FloatArray>): void;
  19574. /**
  19575. * Gets the tangent data stored in this target
  19576. * @returns a FloatArray containing the tangent data (or null if not present)
  19577. */
  19578. getTangents(): Nullable<FloatArray>;
  19579. /**
  19580. * Serializes the current target into a Serialization object
  19581. * @returns the serialized object
  19582. */
  19583. serialize(): any;
  19584. /**
  19585. * Returns the string "MorphTarget"
  19586. * @returns "MorphTarget"
  19587. */
  19588. getClassName(): string;
  19589. /**
  19590. * Creates a new target from serialized data
  19591. * @param serializationObject defines the serialized data to use
  19592. * @returns a new MorphTarget
  19593. */
  19594. static Parse(serializationObject: any): MorphTarget;
  19595. /**
  19596. * Creates a MorphTarget from mesh data
  19597. * @param mesh defines the source mesh
  19598. * @param name defines the name to use for the new target
  19599. * @param influence defines the influence to attach to the target
  19600. * @returns a new MorphTarget
  19601. */
  19602. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19603. }
  19604. }
  19605. declare module "babylonjs/Morph/morphTargetManager" {
  19606. import { Nullable } from "babylonjs/types";
  19607. import { Scene } from "babylonjs/scene";
  19608. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19609. /**
  19610. * This class is used to deform meshes using morphing between different targets
  19611. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19612. */
  19613. export class MorphTargetManager {
  19614. private _targets;
  19615. private _targetInfluenceChangedObservers;
  19616. private _targetDataLayoutChangedObservers;
  19617. private _activeTargets;
  19618. private _scene;
  19619. private _influences;
  19620. private _supportsNormals;
  19621. private _supportsTangents;
  19622. private _vertexCount;
  19623. private _uniqueId;
  19624. private _tempInfluences;
  19625. /**
  19626. * Creates a new MorphTargetManager
  19627. * @param scene defines the current scene
  19628. */
  19629. constructor(scene?: Nullable<Scene>);
  19630. /**
  19631. * Gets the unique ID of this manager
  19632. */
  19633. readonly uniqueId: number;
  19634. /**
  19635. * Gets the number of vertices handled by this manager
  19636. */
  19637. readonly vertexCount: number;
  19638. /**
  19639. * Gets a boolean indicating if this manager supports morphing of normals
  19640. */
  19641. readonly supportsNormals: boolean;
  19642. /**
  19643. * Gets a boolean indicating if this manager supports morphing of tangents
  19644. */
  19645. readonly supportsTangents: boolean;
  19646. /**
  19647. * Gets the number of targets stored in this manager
  19648. */
  19649. readonly numTargets: number;
  19650. /**
  19651. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19652. */
  19653. readonly numInfluencers: number;
  19654. /**
  19655. * Gets the list of influences (one per target)
  19656. */
  19657. readonly influences: Float32Array;
  19658. /**
  19659. * Gets the active target at specified index. An active target is a target with an influence > 0
  19660. * @param index defines the index to check
  19661. * @returns the requested target
  19662. */
  19663. getActiveTarget(index: number): MorphTarget;
  19664. /**
  19665. * Gets the target at specified index
  19666. * @param index defines the index to check
  19667. * @returns the requested target
  19668. */
  19669. getTarget(index: number): MorphTarget;
  19670. /**
  19671. * Add a new target to this manager
  19672. * @param target defines the target to add
  19673. */
  19674. addTarget(target: MorphTarget): void;
  19675. /**
  19676. * Removes a target from the manager
  19677. * @param target defines the target to remove
  19678. */
  19679. removeTarget(target: MorphTarget): void;
  19680. /**
  19681. * Serializes the current manager into a Serialization object
  19682. * @returns the serialized object
  19683. */
  19684. serialize(): any;
  19685. private _syncActiveTargets;
  19686. /**
  19687. * Syncrhonize the targets with all the meshes using this morph target manager
  19688. */
  19689. synchronize(): void;
  19690. /**
  19691. * Creates a new MorphTargetManager from serialized data
  19692. * @param serializationObject defines the serialized data
  19693. * @param scene defines the hosting scene
  19694. * @returns the new MorphTargetManager
  19695. */
  19696. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19697. }
  19698. }
  19699. declare module "babylonjs/Meshes/groundMesh" {
  19700. import { Scene } from "babylonjs/scene";
  19701. import { Vector3 } from "babylonjs/Maths/math";
  19702. import { Mesh } from "babylonjs/Meshes/mesh";
  19703. /**
  19704. * Mesh representing the gorund
  19705. */
  19706. export class GroundMesh extends Mesh {
  19707. /** If octree should be generated */
  19708. generateOctree: boolean;
  19709. private _heightQuads;
  19710. /** @hidden */
  19711. _subdivisionsX: number;
  19712. /** @hidden */
  19713. _subdivisionsY: number;
  19714. /** @hidden */
  19715. _width: number;
  19716. /** @hidden */
  19717. _height: number;
  19718. /** @hidden */
  19719. _minX: number;
  19720. /** @hidden */
  19721. _maxX: number;
  19722. /** @hidden */
  19723. _minZ: number;
  19724. /** @hidden */
  19725. _maxZ: number;
  19726. constructor(name: string, scene: Scene);
  19727. /**
  19728. * "GroundMesh"
  19729. * @returns "GroundMesh"
  19730. */
  19731. getClassName(): string;
  19732. /**
  19733. * The minimum of x and y subdivisions
  19734. */
  19735. readonly subdivisions: number;
  19736. /**
  19737. * X subdivisions
  19738. */
  19739. readonly subdivisionsX: number;
  19740. /**
  19741. * Y subdivisions
  19742. */
  19743. readonly subdivisionsY: number;
  19744. /**
  19745. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19746. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19747. * @param chunksCount the number of subdivisions for x and y
  19748. * @param octreeBlocksSize (Default: 32)
  19749. */
  19750. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19751. /**
  19752. * Returns a height (y) value in the Worl system :
  19753. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19754. * @param x x coordinate
  19755. * @param z z coordinate
  19756. * @returns the ground y position if (x, z) are outside the ground surface.
  19757. */
  19758. getHeightAtCoordinates(x: number, z: number): number;
  19759. /**
  19760. * Returns a normalized vector (Vector3) orthogonal to the ground
  19761. * at the ground coordinates (x, z) expressed in the World system.
  19762. * @param x x coordinate
  19763. * @param z z coordinate
  19764. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19765. */
  19766. getNormalAtCoordinates(x: number, z: number): Vector3;
  19767. /**
  19768. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19769. * at the ground coordinates (x, z) expressed in the World system.
  19770. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19771. * @param x x coordinate
  19772. * @param z z coordinate
  19773. * @param ref vector to store the result
  19774. * @returns the GroundMesh.
  19775. */
  19776. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19777. /**
  19778. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19779. * if the ground has been updated.
  19780. * This can be used in the render loop.
  19781. * @returns the GroundMesh.
  19782. */
  19783. updateCoordinateHeights(): GroundMesh;
  19784. private _getFacetAt;
  19785. private _initHeightQuads;
  19786. private _computeHeightQuads;
  19787. /**
  19788. * Serializes this ground mesh
  19789. * @param serializationObject object to write serialization to
  19790. */
  19791. serialize(serializationObject: any): void;
  19792. /**
  19793. * Parses a serialized ground mesh
  19794. * @param parsedMesh the serialized mesh
  19795. * @param scene the scene to create the ground mesh in
  19796. * @returns the created ground mesh
  19797. */
  19798. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19799. }
  19800. }
  19801. declare module "babylonjs/Physics/physicsJoint" {
  19802. import { Vector3 } from "babylonjs/Maths/math";
  19803. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19804. /**
  19805. * Interface for Physics-Joint data
  19806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19807. */
  19808. export interface PhysicsJointData {
  19809. /**
  19810. * The main pivot of the joint
  19811. */
  19812. mainPivot?: Vector3;
  19813. /**
  19814. * The connected pivot of the joint
  19815. */
  19816. connectedPivot?: Vector3;
  19817. /**
  19818. * The main axis of the joint
  19819. */
  19820. mainAxis?: Vector3;
  19821. /**
  19822. * The connected axis of the joint
  19823. */
  19824. connectedAxis?: Vector3;
  19825. /**
  19826. * The collision of the joint
  19827. */
  19828. collision?: boolean;
  19829. /**
  19830. * Native Oimo/Cannon/Energy data
  19831. */
  19832. nativeParams?: any;
  19833. }
  19834. /**
  19835. * This is a holder class for the physics joint created by the physics plugin
  19836. * It holds a set of functions to control the underlying joint
  19837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19838. */
  19839. export class PhysicsJoint {
  19840. /**
  19841. * The type of the physics joint
  19842. */
  19843. type: number;
  19844. /**
  19845. * The data for the physics joint
  19846. */
  19847. jointData: PhysicsJointData;
  19848. private _physicsJoint;
  19849. protected _physicsPlugin: IPhysicsEnginePlugin;
  19850. /**
  19851. * Initializes the physics joint
  19852. * @param type The type of the physics joint
  19853. * @param jointData The data for the physics joint
  19854. */
  19855. constructor(
  19856. /**
  19857. * The type of the physics joint
  19858. */
  19859. type: number,
  19860. /**
  19861. * The data for the physics joint
  19862. */
  19863. jointData: PhysicsJointData);
  19864. /**
  19865. * Gets the physics joint
  19866. */
  19867. /**
  19868. * Sets the physics joint
  19869. */
  19870. physicsJoint: any;
  19871. /**
  19872. * Sets the physics plugin
  19873. */
  19874. physicsPlugin: IPhysicsEnginePlugin;
  19875. /**
  19876. * Execute a function that is physics-plugin specific.
  19877. * @param {Function} func the function that will be executed.
  19878. * It accepts two parameters: the physics world and the physics joint
  19879. */
  19880. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19881. /**
  19882. * Distance-Joint type
  19883. */
  19884. static DistanceJoint: number;
  19885. /**
  19886. * Hinge-Joint type
  19887. */
  19888. static HingeJoint: number;
  19889. /**
  19890. * Ball-and-Socket joint type
  19891. */
  19892. static BallAndSocketJoint: number;
  19893. /**
  19894. * Wheel-Joint type
  19895. */
  19896. static WheelJoint: number;
  19897. /**
  19898. * Slider-Joint type
  19899. */
  19900. static SliderJoint: number;
  19901. /**
  19902. * Prismatic-Joint type
  19903. */
  19904. static PrismaticJoint: number;
  19905. /**
  19906. * Universal-Joint type
  19907. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19908. */
  19909. static UniversalJoint: number;
  19910. /**
  19911. * Hinge-Joint 2 type
  19912. */
  19913. static Hinge2Joint: number;
  19914. /**
  19915. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19916. */
  19917. static PointToPointJoint: number;
  19918. /**
  19919. * Spring-Joint type
  19920. */
  19921. static SpringJoint: number;
  19922. /**
  19923. * Lock-Joint type
  19924. */
  19925. static LockJoint: number;
  19926. }
  19927. /**
  19928. * A class representing a physics distance joint
  19929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19930. */
  19931. export class DistanceJoint extends PhysicsJoint {
  19932. /**
  19933. *
  19934. * @param jointData The data for the Distance-Joint
  19935. */
  19936. constructor(jointData: DistanceJointData);
  19937. /**
  19938. * Update the predefined distance.
  19939. * @param maxDistance The maximum preferred distance
  19940. * @param minDistance The minimum preferred distance
  19941. */
  19942. updateDistance(maxDistance: number, minDistance?: number): void;
  19943. }
  19944. /**
  19945. * Represents a Motor-Enabled Joint
  19946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19947. */
  19948. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19949. /**
  19950. * Initializes the Motor-Enabled Joint
  19951. * @param type The type of the joint
  19952. * @param jointData The physica joint data for the joint
  19953. */
  19954. constructor(type: number, jointData: PhysicsJointData);
  19955. /**
  19956. * Set the motor values.
  19957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19958. * @param force the force to apply
  19959. * @param maxForce max force for this motor.
  19960. */
  19961. setMotor(force?: number, maxForce?: number): void;
  19962. /**
  19963. * Set the motor's limits.
  19964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19965. * @param upperLimit The upper limit of the motor
  19966. * @param lowerLimit The lower limit of the motor
  19967. */
  19968. setLimit(upperLimit: number, lowerLimit?: number): void;
  19969. }
  19970. /**
  19971. * This class represents a single physics Hinge-Joint
  19972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19973. */
  19974. export class HingeJoint extends MotorEnabledJoint {
  19975. /**
  19976. * Initializes the Hinge-Joint
  19977. * @param jointData The joint data for the Hinge-Joint
  19978. */
  19979. constructor(jointData: PhysicsJointData);
  19980. /**
  19981. * Set the motor values.
  19982. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19983. * @param {number} force the force to apply
  19984. * @param {number} maxForce max force for this motor.
  19985. */
  19986. setMotor(force?: number, maxForce?: number): void;
  19987. /**
  19988. * Set the motor's limits.
  19989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19990. * @param upperLimit The upper limit of the motor
  19991. * @param lowerLimit The lower limit of the motor
  19992. */
  19993. setLimit(upperLimit: number, lowerLimit?: number): void;
  19994. }
  19995. /**
  19996. * This class represents a dual hinge physics joint (same as wheel joint)
  19997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19998. */
  19999. export class Hinge2Joint extends MotorEnabledJoint {
  20000. /**
  20001. * Initializes the Hinge2-Joint
  20002. * @param jointData The joint data for the Hinge2-Joint
  20003. */
  20004. constructor(jointData: PhysicsJointData);
  20005. /**
  20006. * Set the motor values.
  20007. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20008. * @param {number} targetSpeed the speed the motor is to reach
  20009. * @param {number} maxForce max force for this motor.
  20010. * @param {motorIndex} the motor's index, 0 or 1.
  20011. */
  20012. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20013. /**
  20014. * Set the motor limits.
  20015. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20016. * @param {number} upperLimit the upper limit
  20017. * @param {number} lowerLimit lower limit
  20018. * @param {motorIndex} the motor's index, 0 or 1.
  20019. */
  20020. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20021. }
  20022. /**
  20023. * Interface for a motor enabled joint
  20024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20025. */
  20026. export interface IMotorEnabledJoint {
  20027. /**
  20028. * Physics joint
  20029. */
  20030. physicsJoint: any;
  20031. /**
  20032. * Sets the motor of the motor-enabled joint
  20033. * @param force The force of the motor
  20034. * @param maxForce The maximum force of the motor
  20035. * @param motorIndex The index of the motor
  20036. */
  20037. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20038. /**
  20039. * Sets the limit of the motor
  20040. * @param upperLimit The upper limit of the motor
  20041. * @param lowerLimit The lower limit of the motor
  20042. * @param motorIndex The index of the motor
  20043. */
  20044. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20045. }
  20046. /**
  20047. * Joint data for a Distance-Joint
  20048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20049. */
  20050. export interface DistanceJointData extends PhysicsJointData {
  20051. /**
  20052. * Max distance the 2 joint objects can be apart
  20053. */
  20054. maxDistance: number;
  20055. }
  20056. /**
  20057. * Joint data from a spring joint
  20058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20059. */
  20060. export interface SpringJointData extends PhysicsJointData {
  20061. /**
  20062. * Length of the spring
  20063. */
  20064. length: number;
  20065. /**
  20066. * Stiffness of the spring
  20067. */
  20068. stiffness: number;
  20069. /**
  20070. * Damping of the spring
  20071. */
  20072. damping: number;
  20073. /** this callback will be called when applying the force to the impostors. */
  20074. forceApplicationCallback: () => void;
  20075. }
  20076. }
  20077. declare module "babylonjs/Physics/physicsRaycastResult" {
  20078. import { Vector3 } from "babylonjs/Maths/math";
  20079. /**
  20080. * Holds the data for the raycast result
  20081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20082. */
  20083. export class PhysicsRaycastResult {
  20084. private _hasHit;
  20085. private _hitDistance;
  20086. private _hitNormalWorld;
  20087. private _hitPointWorld;
  20088. private _rayFromWorld;
  20089. private _rayToWorld;
  20090. /**
  20091. * Gets if there was a hit
  20092. */
  20093. readonly hasHit: boolean;
  20094. /**
  20095. * Gets the distance from the hit
  20096. */
  20097. readonly hitDistance: number;
  20098. /**
  20099. * Gets the hit normal/direction in the world
  20100. */
  20101. readonly hitNormalWorld: Vector3;
  20102. /**
  20103. * Gets the hit point in the world
  20104. */
  20105. readonly hitPointWorld: Vector3;
  20106. /**
  20107. * Gets the ray "start point" of the ray in the world
  20108. */
  20109. readonly rayFromWorld: Vector3;
  20110. /**
  20111. * Gets the ray "end point" of the ray in the world
  20112. */
  20113. readonly rayToWorld: Vector3;
  20114. /**
  20115. * Sets the hit data (normal & point in world space)
  20116. * @param hitNormalWorld defines the normal in world space
  20117. * @param hitPointWorld defines the point in world space
  20118. */
  20119. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20120. /**
  20121. * Sets the distance from the start point to the hit point
  20122. * @param distance
  20123. */
  20124. setHitDistance(distance: number): void;
  20125. /**
  20126. * Calculates the distance manually
  20127. */
  20128. calculateHitDistance(): void;
  20129. /**
  20130. * Resets all the values to default
  20131. * @param from The from point on world space
  20132. * @param to The to point on world space
  20133. */
  20134. reset(from?: Vector3, to?: Vector3): void;
  20135. }
  20136. /**
  20137. * Interface for the size containing width and height
  20138. */
  20139. interface IXYZ {
  20140. /**
  20141. * X
  20142. */
  20143. x: number;
  20144. /**
  20145. * Y
  20146. */
  20147. y: number;
  20148. /**
  20149. * Z
  20150. */
  20151. z: number;
  20152. }
  20153. }
  20154. declare module "babylonjs/Physics/IPhysicsEngine" {
  20155. import { Nullable } from "babylonjs/types";
  20156. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20158. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20159. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20160. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20161. /**
  20162. * Interface used to describe a physics joint
  20163. */
  20164. export interface PhysicsImpostorJoint {
  20165. /** Defines the main impostor to which the joint is linked */
  20166. mainImpostor: PhysicsImpostor;
  20167. /** Defines the impostor that is connected to the main impostor using this joint */
  20168. connectedImpostor: PhysicsImpostor;
  20169. /** Defines the joint itself */
  20170. joint: PhysicsJoint;
  20171. }
  20172. /** @hidden */
  20173. export interface IPhysicsEnginePlugin {
  20174. world: any;
  20175. name: string;
  20176. setGravity(gravity: Vector3): void;
  20177. setTimeStep(timeStep: number): void;
  20178. getTimeStep(): number;
  20179. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20180. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20181. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20182. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20183. removePhysicsBody(impostor: PhysicsImpostor): void;
  20184. generateJoint(joint: PhysicsImpostorJoint): void;
  20185. removeJoint(joint: PhysicsImpostorJoint): void;
  20186. isSupported(): boolean;
  20187. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20188. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20189. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20190. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20191. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20192. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20193. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20194. getBodyMass(impostor: PhysicsImpostor): number;
  20195. getBodyFriction(impostor: PhysicsImpostor): number;
  20196. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20197. getBodyRestitution(impostor: PhysicsImpostor): number;
  20198. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20199. getBodyPressure?(impostor: PhysicsImpostor): number;
  20200. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20201. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20202. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20203. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20204. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20205. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20206. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20207. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20208. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20209. sleepBody(impostor: PhysicsImpostor): void;
  20210. wakeUpBody(impostor: PhysicsImpostor): void;
  20211. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20212. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20213. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20214. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20215. getRadius(impostor: PhysicsImpostor): number;
  20216. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20217. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20218. dispose(): void;
  20219. }
  20220. /**
  20221. * Interface used to define a physics engine
  20222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20223. */
  20224. export interface IPhysicsEngine {
  20225. /**
  20226. * Gets the gravity vector used by the simulation
  20227. */
  20228. gravity: Vector3;
  20229. /**
  20230. * Sets the gravity vector used by the simulation
  20231. * @param gravity defines the gravity vector to use
  20232. */
  20233. setGravity(gravity: Vector3): void;
  20234. /**
  20235. * Set the time step of the physics engine.
  20236. * Default is 1/60.
  20237. * To slow it down, enter 1/600 for example.
  20238. * To speed it up, 1/30
  20239. * @param newTimeStep the new timestep to apply to this world.
  20240. */
  20241. setTimeStep(newTimeStep: number): void;
  20242. /**
  20243. * Get the time step of the physics engine.
  20244. * @returns the current time step
  20245. */
  20246. getTimeStep(): number;
  20247. /**
  20248. * Release all resources
  20249. */
  20250. dispose(): void;
  20251. /**
  20252. * Gets the name of the current physics plugin
  20253. * @returns the name of the plugin
  20254. */
  20255. getPhysicsPluginName(): string;
  20256. /**
  20257. * Adding a new impostor for the impostor tracking.
  20258. * This will be done by the impostor itself.
  20259. * @param impostor the impostor to add
  20260. */
  20261. addImpostor(impostor: PhysicsImpostor): void;
  20262. /**
  20263. * Remove an impostor from the engine.
  20264. * This impostor and its mesh will not longer be updated by the physics engine.
  20265. * @param impostor the impostor to remove
  20266. */
  20267. removeImpostor(impostor: PhysicsImpostor): void;
  20268. /**
  20269. * Add a joint to the physics engine
  20270. * @param mainImpostor defines the main impostor to which the joint is added.
  20271. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20272. * @param joint defines the joint that will connect both impostors.
  20273. */
  20274. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20275. /**
  20276. * Removes a joint from the simulation
  20277. * @param mainImpostor defines the impostor used with the joint
  20278. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20279. * @param joint defines the joint to remove
  20280. */
  20281. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20282. /**
  20283. * Gets the current plugin used to run the simulation
  20284. * @returns current plugin
  20285. */
  20286. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20287. /**
  20288. * Gets the list of physic impostors
  20289. * @returns an array of PhysicsImpostor
  20290. */
  20291. getImpostors(): Array<PhysicsImpostor>;
  20292. /**
  20293. * Gets the impostor for a physics enabled object
  20294. * @param object defines the object impersonated by the impostor
  20295. * @returns the PhysicsImpostor or null if not found
  20296. */
  20297. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20298. /**
  20299. * Gets the impostor for a physics body object
  20300. * @param body defines physics body used by the impostor
  20301. * @returns the PhysicsImpostor or null if not found
  20302. */
  20303. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20304. /**
  20305. * Does a raycast in the physics world
  20306. * @param from when should the ray start?
  20307. * @param to when should the ray end?
  20308. * @returns PhysicsRaycastResult
  20309. */
  20310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20311. /**
  20312. * Called by the scene. No need to call it.
  20313. * @param delta defines the timespam between frames
  20314. */
  20315. _step(delta: number): void;
  20316. }
  20317. }
  20318. declare module "babylonjs/Physics/physicsImpostor" {
  20319. import { Nullable, IndicesArray } from "babylonjs/types";
  20320. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20321. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20323. import { Scene } from "babylonjs/scene";
  20324. import { Bone } from "babylonjs/Bones/bone";
  20325. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20326. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20327. /**
  20328. * The interface for the physics imposter parameters
  20329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20330. */
  20331. export interface PhysicsImpostorParameters {
  20332. /**
  20333. * The mass of the physics imposter
  20334. */
  20335. mass: number;
  20336. /**
  20337. * The friction of the physics imposter
  20338. */
  20339. friction?: number;
  20340. /**
  20341. * The coefficient of restitution of the physics imposter
  20342. */
  20343. restitution?: number;
  20344. /**
  20345. * The native options of the physics imposter
  20346. */
  20347. nativeOptions?: any;
  20348. /**
  20349. * Specifies if the parent should be ignored
  20350. */
  20351. ignoreParent?: boolean;
  20352. /**
  20353. * Specifies if bi-directional transformations should be disabled
  20354. */
  20355. disableBidirectionalTransformation?: boolean;
  20356. /**
  20357. * The pressure inside the physics imposter, soft object only
  20358. */
  20359. pressure?: number;
  20360. /**
  20361. * The stiffness the physics imposter, soft object only
  20362. */
  20363. stiffness?: number;
  20364. /**
  20365. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20366. */
  20367. velocityIterations?: number;
  20368. /**
  20369. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20370. */
  20371. positionIterations?: number;
  20372. /**
  20373. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20374. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20375. * Add to fix multiple points
  20376. */
  20377. fixedPoints?: number;
  20378. /**
  20379. * The collision margin around a soft object
  20380. */
  20381. margin?: number;
  20382. /**
  20383. * The collision margin around a soft object
  20384. */
  20385. damping?: number;
  20386. /**
  20387. * The path for a rope based on an extrusion
  20388. */
  20389. path?: any;
  20390. /**
  20391. * The shape of an extrusion used for a rope based on an extrusion
  20392. */
  20393. shape?: any;
  20394. }
  20395. /**
  20396. * Interface for a physics-enabled object
  20397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20398. */
  20399. export interface IPhysicsEnabledObject {
  20400. /**
  20401. * The position of the physics-enabled object
  20402. */
  20403. position: Vector3;
  20404. /**
  20405. * The rotation of the physics-enabled object
  20406. */
  20407. rotationQuaternion: Nullable<Quaternion>;
  20408. /**
  20409. * The scale of the physics-enabled object
  20410. */
  20411. scaling: Vector3;
  20412. /**
  20413. * The rotation of the physics-enabled object
  20414. */
  20415. rotation?: Vector3;
  20416. /**
  20417. * The parent of the physics-enabled object
  20418. */
  20419. parent?: any;
  20420. /**
  20421. * The bounding info of the physics-enabled object
  20422. * @returns The bounding info of the physics-enabled object
  20423. */
  20424. getBoundingInfo(): BoundingInfo;
  20425. /**
  20426. * Computes the world matrix
  20427. * @param force Specifies if the world matrix should be computed by force
  20428. * @returns A world matrix
  20429. */
  20430. computeWorldMatrix(force: boolean): Matrix;
  20431. /**
  20432. * Gets the world matrix
  20433. * @returns A world matrix
  20434. */
  20435. getWorldMatrix?(): Matrix;
  20436. /**
  20437. * Gets the child meshes
  20438. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20439. * @returns An array of abstract meshes
  20440. */
  20441. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20442. /**
  20443. * Gets the vertex data
  20444. * @param kind The type of vertex data
  20445. * @returns A nullable array of numbers, or a float32 array
  20446. */
  20447. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20448. /**
  20449. * Gets the indices from the mesh
  20450. * @returns A nullable array of index arrays
  20451. */
  20452. getIndices?(): Nullable<IndicesArray>;
  20453. /**
  20454. * Gets the scene from the mesh
  20455. * @returns the indices array or null
  20456. */
  20457. getScene?(): Scene;
  20458. /**
  20459. * Gets the absolute position from the mesh
  20460. * @returns the absolute position
  20461. */
  20462. getAbsolutePosition(): Vector3;
  20463. /**
  20464. * Gets the absolute pivot point from the mesh
  20465. * @returns the absolute pivot point
  20466. */
  20467. getAbsolutePivotPoint(): Vector3;
  20468. /**
  20469. * Rotates the mesh
  20470. * @param axis The axis of rotation
  20471. * @param amount The amount of rotation
  20472. * @param space The space of the rotation
  20473. * @returns The rotation transform node
  20474. */
  20475. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20476. /**
  20477. * Translates the mesh
  20478. * @param axis The axis of translation
  20479. * @param distance The distance of translation
  20480. * @param space The space of the translation
  20481. * @returns The transform node
  20482. */
  20483. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20484. /**
  20485. * Sets the absolute position of the mesh
  20486. * @param absolutePosition The absolute position of the mesh
  20487. * @returns The transform node
  20488. */
  20489. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20490. /**
  20491. * Gets the class name of the mesh
  20492. * @returns The class name
  20493. */
  20494. getClassName(): string;
  20495. }
  20496. /**
  20497. * Represents a physics imposter
  20498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20499. */
  20500. export class PhysicsImpostor {
  20501. /**
  20502. * The physics-enabled object used as the physics imposter
  20503. */
  20504. object: IPhysicsEnabledObject;
  20505. /**
  20506. * The type of the physics imposter
  20507. */
  20508. type: number;
  20509. private _options;
  20510. private _scene?;
  20511. /**
  20512. * The default object size of the imposter
  20513. */
  20514. static DEFAULT_OBJECT_SIZE: Vector3;
  20515. /**
  20516. * The identity quaternion of the imposter
  20517. */
  20518. static IDENTITY_QUATERNION: Quaternion;
  20519. /** @hidden */
  20520. _pluginData: any;
  20521. private _physicsEngine;
  20522. private _physicsBody;
  20523. private _bodyUpdateRequired;
  20524. private _onBeforePhysicsStepCallbacks;
  20525. private _onAfterPhysicsStepCallbacks;
  20526. /** @hidden */
  20527. _onPhysicsCollideCallbacks: Array<{
  20528. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20529. otherImpostors: Array<PhysicsImpostor>;
  20530. }>;
  20531. private _deltaPosition;
  20532. private _deltaRotation;
  20533. private _deltaRotationConjugated;
  20534. /** hidden */
  20535. _isFromLine: boolean;
  20536. private _parent;
  20537. private _isDisposed;
  20538. private static _tmpVecs;
  20539. private static _tmpQuat;
  20540. /**
  20541. * Specifies if the physics imposter is disposed
  20542. */
  20543. readonly isDisposed: boolean;
  20544. /**
  20545. * Gets the mass of the physics imposter
  20546. */
  20547. mass: number;
  20548. /**
  20549. * Gets the coefficient of friction
  20550. */
  20551. /**
  20552. * Sets the coefficient of friction
  20553. */
  20554. friction: number;
  20555. /**
  20556. * Gets the coefficient of restitution
  20557. */
  20558. /**
  20559. * Sets the coefficient of restitution
  20560. */
  20561. restitution: number;
  20562. /**
  20563. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20564. */
  20565. /**
  20566. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20567. */
  20568. pressure: number;
  20569. /**
  20570. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20571. */
  20572. /**
  20573. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20574. */
  20575. stiffness: number;
  20576. /**
  20577. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20578. */
  20579. /**
  20580. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20581. */
  20582. velocityIterations: number;
  20583. /**
  20584. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20585. */
  20586. /**
  20587. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20588. */
  20589. positionIterations: number;
  20590. /**
  20591. * The unique id of the physics imposter
  20592. * set by the physics engine when adding this impostor to the array
  20593. */
  20594. uniqueId: number;
  20595. /**
  20596. * @hidden
  20597. */
  20598. soft: boolean;
  20599. /**
  20600. * @hidden
  20601. */
  20602. segments: number;
  20603. private _joints;
  20604. /**
  20605. * Initializes the physics imposter
  20606. * @param object The physics-enabled object used as the physics imposter
  20607. * @param type The type of the physics imposter
  20608. * @param _options The options for the physics imposter
  20609. * @param _scene The Babylon scene
  20610. */
  20611. constructor(
  20612. /**
  20613. * The physics-enabled object used as the physics imposter
  20614. */
  20615. object: IPhysicsEnabledObject,
  20616. /**
  20617. * The type of the physics imposter
  20618. */
  20619. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20620. /**
  20621. * This function will completly initialize this impostor.
  20622. * It will create a new body - but only if this mesh has no parent.
  20623. * If it has, this impostor will not be used other than to define the impostor
  20624. * of the child mesh.
  20625. * @hidden
  20626. */
  20627. _init(): void;
  20628. private _getPhysicsParent;
  20629. /**
  20630. * Should a new body be generated.
  20631. * @returns boolean specifying if body initialization is required
  20632. */
  20633. isBodyInitRequired(): boolean;
  20634. /**
  20635. * Sets the updated scaling
  20636. * @param updated Specifies if the scaling is updated
  20637. */
  20638. setScalingUpdated(): void;
  20639. /**
  20640. * Force a regeneration of this or the parent's impostor's body.
  20641. * Use under cautious - This will remove all joints already implemented.
  20642. */
  20643. forceUpdate(): void;
  20644. /**
  20645. * Gets the body that holds this impostor. Either its own, or its parent.
  20646. */
  20647. /**
  20648. * Set the physics body. Used mainly by the physics engine/plugin
  20649. */
  20650. physicsBody: any;
  20651. /**
  20652. * Get the parent of the physics imposter
  20653. * @returns Physics imposter or null
  20654. */
  20655. /**
  20656. * Sets the parent of the physics imposter
  20657. */
  20658. parent: Nullable<PhysicsImpostor>;
  20659. /**
  20660. * Resets the update flags
  20661. */
  20662. resetUpdateFlags(): void;
  20663. /**
  20664. * Gets the object extend size
  20665. * @returns the object extend size
  20666. */
  20667. getObjectExtendSize(): Vector3;
  20668. /**
  20669. * Gets the object center
  20670. * @returns The object center
  20671. */
  20672. getObjectCenter(): Vector3;
  20673. /**
  20674. * Get a specific parametes from the options parameter
  20675. * @param paramName The object parameter name
  20676. * @returns The object parameter
  20677. */
  20678. getParam(paramName: string): any;
  20679. /**
  20680. * Sets a specific parameter in the options given to the physics plugin
  20681. * @param paramName The parameter name
  20682. * @param value The value of the parameter
  20683. */
  20684. setParam(paramName: string, value: number): void;
  20685. /**
  20686. * Specifically change the body's mass option. Won't recreate the physics body object
  20687. * @param mass The mass of the physics imposter
  20688. */
  20689. setMass(mass: number): void;
  20690. /**
  20691. * Gets the linear velocity
  20692. * @returns linear velocity or null
  20693. */
  20694. getLinearVelocity(): Nullable<Vector3>;
  20695. /**
  20696. * Sets the linear velocity
  20697. * @param velocity linear velocity or null
  20698. */
  20699. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20700. /**
  20701. * Gets the angular velocity
  20702. * @returns angular velocity or null
  20703. */
  20704. getAngularVelocity(): Nullable<Vector3>;
  20705. /**
  20706. * Sets the angular velocity
  20707. * @param velocity The velocity or null
  20708. */
  20709. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20710. /**
  20711. * Execute a function with the physics plugin native code
  20712. * Provide a function the will have two variables - the world object and the physics body object
  20713. * @param func The function to execute with the physics plugin native code
  20714. */
  20715. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20716. /**
  20717. * Register a function that will be executed before the physics world is stepping forward
  20718. * @param func The function to execute before the physics world is stepped forward
  20719. */
  20720. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20721. /**
  20722. * Unregister a function that will be executed before the physics world is stepping forward
  20723. * @param func The function to execute before the physics world is stepped forward
  20724. */
  20725. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20726. /**
  20727. * Register a function that will be executed after the physics step
  20728. * @param func The function to execute after physics step
  20729. */
  20730. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20731. /**
  20732. * Unregisters a function that will be executed after the physics step
  20733. * @param func The function to execute after physics step
  20734. */
  20735. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20736. /**
  20737. * register a function that will be executed when this impostor collides against a different body
  20738. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20739. * @param func Callback that is executed on collision
  20740. */
  20741. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20742. /**
  20743. * Unregisters the physics imposter on contact
  20744. * @param collideAgainst The physics object to collide against
  20745. * @param func Callback to execute on collision
  20746. */
  20747. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20748. private _tmpQuat;
  20749. private _tmpQuat2;
  20750. /**
  20751. * Get the parent rotation
  20752. * @returns The parent rotation
  20753. */
  20754. getParentsRotation(): Quaternion;
  20755. /**
  20756. * this function is executed by the physics engine.
  20757. */
  20758. beforeStep: () => void;
  20759. /**
  20760. * this function is executed by the physics engine
  20761. */
  20762. afterStep: () => void;
  20763. /**
  20764. * Legacy collision detection event support
  20765. */
  20766. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20767. /**
  20768. * event and body object due to cannon's event-based architecture.
  20769. */
  20770. onCollide: (e: {
  20771. body: any;
  20772. }) => void;
  20773. /**
  20774. * Apply a force
  20775. * @param force The force to apply
  20776. * @param contactPoint The contact point for the force
  20777. * @returns The physics imposter
  20778. */
  20779. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20780. /**
  20781. * Apply an impulse
  20782. * @param force The impulse force
  20783. * @param contactPoint The contact point for the impulse force
  20784. * @returns The physics imposter
  20785. */
  20786. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20787. /**
  20788. * A help function to create a joint
  20789. * @param otherImpostor A physics imposter used to create a joint
  20790. * @param jointType The type of joint
  20791. * @param jointData The data for the joint
  20792. * @returns The physics imposter
  20793. */
  20794. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20795. /**
  20796. * Add a joint to this impostor with a different impostor
  20797. * @param otherImpostor A physics imposter used to add a joint
  20798. * @param joint The joint to add
  20799. * @returns The physics imposter
  20800. */
  20801. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20802. /**
  20803. * Add an anchor to a cloth impostor
  20804. * @param otherImpostor rigid impostor to anchor to
  20805. * @param width ratio across width from 0 to 1
  20806. * @param height ratio up height from 0 to 1
  20807. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20808. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20809. * @returns impostor the soft imposter
  20810. */
  20811. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20812. /**
  20813. * Add a hook to a rope impostor
  20814. * @param otherImpostor rigid impostor to anchor to
  20815. * @param length ratio across rope from 0 to 1
  20816. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20817. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20818. * @returns impostor the rope imposter
  20819. */
  20820. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20821. /**
  20822. * Will keep this body still, in a sleep mode.
  20823. * @returns the physics imposter
  20824. */
  20825. sleep(): PhysicsImpostor;
  20826. /**
  20827. * Wake the body up.
  20828. * @returns The physics imposter
  20829. */
  20830. wakeUp(): PhysicsImpostor;
  20831. /**
  20832. * Clones the physics imposter
  20833. * @param newObject The physics imposter clones to this physics-enabled object
  20834. * @returns A nullable physics imposter
  20835. */
  20836. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20837. /**
  20838. * Disposes the physics imposter
  20839. */
  20840. dispose(): void;
  20841. /**
  20842. * Sets the delta position
  20843. * @param position The delta position amount
  20844. */
  20845. setDeltaPosition(position: Vector3): void;
  20846. /**
  20847. * Sets the delta rotation
  20848. * @param rotation The delta rotation amount
  20849. */
  20850. setDeltaRotation(rotation: Quaternion): void;
  20851. /**
  20852. * Gets the box size of the physics imposter and stores the result in the input parameter
  20853. * @param result Stores the box size
  20854. * @returns The physics imposter
  20855. */
  20856. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20857. /**
  20858. * Gets the radius of the physics imposter
  20859. * @returns Radius of the physics imposter
  20860. */
  20861. getRadius(): number;
  20862. /**
  20863. * Sync a bone with this impostor
  20864. * @param bone The bone to sync to the impostor.
  20865. * @param boneMesh The mesh that the bone is influencing.
  20866. * @param jointPivot The pivot of the joint / bone in local space.
  20867. * @param distToJoint Optional distance from the impostor to the joint.
  20868. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20869. */
  20870. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20871. /**
  20872. * Sync impostor to a bone
  20873. * @param bone The bone that the impostor will be synced to.
  20874. * @param boneMesh The mesh that the bone is influencing.
  20875. * @param jointPivot The pivot of the joint / bone in local space.
  20876. * @param distToJoint Optional distance from the impostor to the joint.
  20877. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20878. * @param boneAxis Optional vector3 axis the bone is aligned with
  20879. */
  20880. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20881. /**
  20882. * No-Imposter type
  20883. */
  20884. static NoImpostor: number;
  20885. /**
  20886. * Sphere-Imposter type
  20887. */
  20888. static SphereImpostor: number;
  20889. /**
  20890. * Box-Imposter type
  20891. */
  20892. static BoxImpostor: number;
  20893. /**
  20894. * Plane-Imposter type
  20895. */
  20896. static PlaneImpostor: number;
  20897. /**
  20898. * Mesh-imposter type
  20899. */
  20900. static MeshImpostor: number;
  20901. /**
  20902. * Cylinder-Imposter type
  20903. */
  20904. static CylinderImpostor: number;
  20905. /**
  20906. * Particle-Imposter type
  20907. */
  20908. static ParticleImpostor: number;
  20909. /**
  20910. * Heightmap-Imposter type
  20911. */
  20912. static HeightmapImpostor: number;
  20913. /**
  20914. * ConvexHull-Impostor type (Ammo.js plugin only)
  20915. */
  20916. static ConvexHullImpostor: number;
  20917. /**
  20918. * Rope-Imposter type
  20919. */
  20920. static RopeImpostor: number;
  20921. /**
  20922. * Cloth-Imposter type
  20923. */
  20924. static ClothImpostor: number;
  20925. /**
  20926. * Softbody-Imposter type
  20927. */
  20928. static SoftbodyImpostor: number;
  20929. }
  20930. }
  20931. declare module "babylonjs/Meshes/mesh" {
  20932. import { Observable } from "babylonjs/Misc/observable";
  20933. import { IAnimatable } from "babylonjs/Misc/tools";
  20934. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20935. import { Camera } from "babylonjs/Cameras/camera";
  20936. import { Scene } from "babylonjs/scene";
  20937. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20938. import { Engine } from "babylonjs/Engines/engine";
  20939. import { Node } from "babylonjs/node";
  20940. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20941. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20942. import { Buffer } from "babylonjs/Meshes/buffer";
  20943. import { Geometry } from "babylonjs/Meshes/geometry";
  20944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20946. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20947. import { Effect } from "babylonjs/Materials/effect";
  20948. import { Material } from "babylonjs/Materials/material";
  20949. import { Skeleton } from "babylonjs/Bones/skeleton";
  20950. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20951. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20952. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20953. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20954. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20955. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20956. /**
  20957. * Class used to represent a specific level of detail of a mesh
  20958. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20959. */
  20960. export class MeshLODLevel {
  20961. /** Defines the distance where this level should star being displayed */
  20962. distance: number;
  20963. /** Defines the mesh to use to render this level */
  20964. mesh: Nullable<Mesh>;
  20965. /**
  20966. * Creates a new LOD level
  20967. * @param distance defines the distance where this level should star being displayed
  20968. * @param mesh defines the mesh to use to render this level
  20969. */
  20970. constructor(
  20971. /** Defines the distance where this level should star being displayed */
  20972. distance: number,
  20973. /** Defines the mesh to use to render this level */
  20974. mesh: Nullable<Mesh>);
  20975. }
  20976. /**
  20977. * @hidden
  20978. **/
  20979. export class _CreationDataStorage {
  20980. closePath?: boolean;
  20981. closeArray?: boolean;
  20982. idx: number[];
  20983. dashSize: number;
  20984. gapSize: number;
  20985. path3D: Path3D;
  20986. pathArray: Vector3[][];
  20987. arc: number;
  20988. radius: number;
  20989. cap: number;
  20990. tessellation: number;
  20991. }
  20992. /**
  20993. * @hidden
  20994. **/
  20995. class _InstanceDataStorage {
  20996. visibleInstances: any;
  20997. renderIdForInstances: number[];
  20998. batchCache: _InstancesBatch;
  20999. instancesBufferSize: number;
  21000. instancesBuffer: Nullable<Buffer>;
  21001. instancesData: Float32Array;
  21002. overridenInstanceCount: number;
  21003. }
  21004. /**
  21005. * @hidden
  21006. **/
  21007. export class _InstancesBatch {
  21008. mustReturn: boolean;
  21009. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21010. renderSelf: boolean[];
  21011. }
  21012. /**
  21013. * Class used to represent renderable models
  21014. */
  21015. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21016. /**
  21017. * Mesh side orientation : usually the external or front surface
  21018. */
  21019. static readonly FRONTSIDE: number;
  21020. /**
  21021. * Mesh side orientation : usually the internal or back surface
  21022. */
  21023. static readonly BACKSIDE: number;
  21024. /**
  21025. * Mesh side orientation : both internal and external or front and back surfaces
  21026. */
  21027. static readonly DOUBLESIDE: number;
  21028. /**
  21029. * Mesh side orientation : by default, `FRONTSIDE`
  21030. */
  21031. static readonly DEFAULTSIDE: number;
  21032. /**
  21033. * Mesh cap setting : no cap
  21034. */
  21035. static readonly NO_CAP: number;
  21036. /**
  21037. * Mesh cap setting : one cap at the beginning of the mesh
  21038. */
  21039. static readonly CAP_START: number;
  21040. /**
  21041. * Mesh cap setting : one cap at the end of the mesh
  21042. */
  21043. static readonly CAP_END: number;
  21044. /**
  21045. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21046. */
  21047. static readonly CAP_ALL: number;
  21048. /**
  21049. * Gets the default side orientation.
  21050. * @param orientation the orientation to value to attempt to get
  21051. * @returns the default orientation
  21052. * @hidden
  21053. */
  21054. static _GetDefaultSideOrientation(orientation?: number): number;
  21055. private _onBeforeRenderObservable;
  21056. private _onBeforeBindObservable;
  21057. private _onAfterRenderObservable;
  21058. private _onBeforeDrawObservable;
  21059. /**
  21060. * An event triggered before rendering the mesh
  21061. */
  21062. readonly onBeforeRenderObservable: Observable<Mesh>;
  21063. /**
  21064. * An event triggered before binding the mesh
  21065. */
  21066. readonly onBeforeBindObservable: Observable<Mesh>;
  21067. /**
  21068. * An event triggered after rendering the mesh
  21069. */
  21070. readonly onAfterRenderObservable: Observable<Mesh>;
  21071. /**
  21072. * An event triggered before drawing the mesh
  21073. */
  21074. readonly onBeforeDrawObservable: Observable<Mesh>;
  21075. private _onBeforeDrawObserver;
  21076. /**
  21077. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21078. */
  21079. onBeforeDraw: () => void;
  21080. /**
  21081. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21082. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21083. */
  21084. delayLoadState: number;
  21085. /**
  21086. * Gets the list of instances created from this mesh
  21087. * it is not supposed to be modified manually.
  21088. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21089. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21090. */
  21091. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21092. /**
  21093. * Gets the file containing delay loading data for this mesh
  21094. */
  21095. delayLoadingFile: string;
  21096. /** @hidden */
  21097. _binaryInfo: any;
  21098. private _LODLevels;
  21099. /**
  21100. * User defined function used to change how LOD level selection is done
  21101. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21102. */
  21103. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21104. private _morphTargetManager;
  21105. /**
  21106. * Gets or sets the morph target manager
  21107. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21108. */
  21109. morphTargetManager: Nullable<MorphTargetManager>;
  21110. /** @hidden */
  21111. _creationDataStorage: Nullable<_CreationDataStorage>;
  21112. /** @hidden */
  21113. _geometry: Nullable<Geometry>;
  21114. /** @hidden */
  21115. _delayInfo: Array<string>;
  21116. /** @hidden */
  21117. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21118. /** @hidden */
  21119. _instanceDataStorage: _InstanceDataStorage;
  21120. private _effectiveMaterial;
  21121. /** @hidden */
  21122. _shouldGenerateFlatShading: boolean;
  21123. private _preActivateId;
  21124. /** @hidden */
  21125. _originalBuilderSideOrientation: number;
  21126. /**
  21127. * Use this property to change the original side orientation defined at construction time
  21128. */
  21129. overrideMaterialSideOrientation: Nullable<number>;
  21130. private _areNormalsFrozen;
  21131. private _sourcePositions;
  21132. private _sourceNormals;
  21133. private _source;
  21134. private meshMap;
  21135. /**
  21136. * Gets the source mesh (the one used to clone this one from)
  21137. */
  21138. readonly source: Nullable<Mesh>;
  21139. /**
  21140. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21141. */
  21142. isUnIndexed: boolean;
  21143. /**
  21144. * @constructor
  21145. * @param name The value used by scene.getMeshByName() to do a lookup.
  21146. * @param scene The scene to add this mesh to.
  21147. * @param parent The parent of this mesh, if it has one
  21148. * @param source An optional Mesh from which geometry is shared, cloned.
  21149. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21150. * When false, achieved by calling a clone(), also passing False.
  21151. * This will make creation of children, recursive.
  21152. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21153. */
  21154. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21155. /**
  21156. * Gets the class name
  21157. * @returns the string "Mesh".
  21158. */
  21159. getClassName(): string;
  21160. /** @hidden */
  21161. readonly _isMesh: boolean;
  21162. /**
  21163. * Returns a description of this mesh
  21164. * @param fullDetails define if full details about this mesh must be used
  21165. * @returns a descriptive string representing this mesh
  21166. */
  21167. toString(fullDetails?: boolean): string;
  21168. /** @hidden */
  21169. _unBindEffect(): void;
  21170. /**
  21171. * Gets a boolean indicating if this mesh has LOD
  21172. */
  21173. readonly hasLODLevels: boolean;
  21174. /**
  21175. * Gets the list of MeshLODLevel associated with the current mesh
  21176. * @returns an array of MeshLODLevel
  21177. */
  21178. getLODLevels(): MeshLODLevel[];
  21179. private _sortLODLevels;
  21180. /**
  21181. * Add a mesh as LOD level triggered at the given distance.
  21182. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21183. * @param distance The distance from the center of the object to show this level
  21184. * @param mesh The mesh to be added as LOD level (can be null)
  21185. * @return This mesh (for chaining)
  21186. */
  21187. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21188. /**
  21189. * Returns the LOD level mesh at the passed distance or null if not found.
  21190. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21191. * @param distance The distance from the center of the object to show this level
  21192. * @returns a Mesh or `null`
  21193. */
  21194. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21195. /**
  21196. * Remove a mesh from the LOD array
  21197. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21198. * @param mesh defines the mesh to be removed
  21199. * @return This mesh (for chaining)
  21200. */
  21201. removeLODLevel(mesh: Mesh): Mesh;
  21202. /**
  21203. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21204. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21205. * @param camera defines the camera to use to compute distance
  21206. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21207. * @return This mesh (for chaining)
  21208. */
  21209. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21210. /**
  21211. * Gets the mesh internal Geometry object
  21212. */
  21213. readonly geometry: Nullable<Geometry>;
  21214. /**
  21215. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21216. * @returns the total number of vertices
  21217. */
  21218. getTotalVertices(): number;
  21219. /**
  21220. * Returns the content of an associated vertex buffer
  21221. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21222. * - VertexBuffer.PositionKind
  21223. * - VertexBuffer.UVKind
  21224. * - VertexBuffer.UV2Kind
  21225. * - VertexBuffer.UV3Kind
  21226. * - VertexBuffer.UV4Kind
  21227. * - VertexBuffer.UV5Kind
  21228. * - VertexBuffer.UV6Kind
  21229. * - VertexBuffer.ColorKind
  21230. * - VertexBuffer.MatricesIndicesKind
  21231. * - VertexBuffer.MatricesIndicesExtraKind
  21232. * - VertexBuffer.MatricesWeightsKind
  21233. * - VertexBuffer.MatricesWeightsExtraKind
  21234. * @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
  21235. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21236. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21237. */
  21238. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21239. /**
  21240. * Returns the mesh VertexBuffer object from the requested `kind`
  21241. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21242. * - VertexBuffer.PositionKind
  21243. * - VertexBuffer.UVKind
  21244. * - VertexBuffer.UV2Kind
  21245. * - VertexBuffer.UV3Kind
  21246. * - VertexBuffer.UV4Kind
  21247. * - VertexBuffer.UV5Kind
  21248. * - VertexBuffer.UV6Kind
  21249. * - VertexBuffer.ColorKind
  21250. * - VertexBuffer.MatricesIndicesKind
  21251. * - VertexBuffer.MatricesIndicesExtraKind
  21252. * - VertexBuffer.MatricesWeightsKind
  21253. * - VertexBuffer.MatricesWeightsExtraKind
  21254. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21255. */
  21256. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21257. /**
  21258. * Tests if a specific vertex buffer is associated with this mesh
  21259. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21260. * - VertexBuffer.PositionKind
  21261. * - VertexBuffer.UVKind
  21262. * - VertexBuffer.UV2Kind
  21263. * - VertexBuffer.UV3Kind
  21264. * - VertexBuffer.UV4Kind
  21265. * - VertexBuffer.UV5Kind
  21266. * - VertexBuffer.UV6Kind
  21267. * - VertexBuffer.ColorKind
  21268. * - VertexBuffer.MatricesIndicesKind
  21269. * - VertexBuffer.MatricesIndicesExtraKind
  21270. * - VertexBuffer.MatricesWeightsKind
  21271. * - VertexBuffer.MatricesWeightsExtraKind
  21272. * @returns a boolean
  21273. */
  21274. isVerticesDataPresent(kind: string): boolean;
  21275. /**
  21276. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21277. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21278. * - VertexBuffer.PositionKind
  21279. * - VertexBuffer.UVKind
  21280. * - VertexBuffer.UV2Kind
  21281. * - VertexBuffer.UV3Kind
  21282. * - VertexBuffer.UV4Kind
  21283. * - VertexBuffer.UV5Kind
  21284. * - VertexBuffer.UV6Kind
  21285. * - VertexBuffer.ColorKind
  21286. * - VertexBuffer.MatricesIndicesKind
  21287. * - VertexBuffer.MatricesIndicesExtraKind
  21288. * - VertexBuffer.MatricesWeightsKind
  21289. * - VertexBuffer.MatricesWeightsExtraKind
  21290. * @returns a boolean
  21291. */
  21292. isVertexBufferUpdatable(kind: string): boolean;
  21293. /**
  21294. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21295. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21296. * - VertexBuffer.PositionKind
  21297. * - VertexBuffer.UVKind
  21298. * - VertexBuffer.UV2Kind
  21299. * - VertexBuffer.UV3Kind
  21300. * - VertexBuffer.UV4Kind
  21301. * - VertexBuffer.UV5Kind
  21302. * - VertexBuffer.UV6Kind
  21303. * - VertexBuffer.ColorKind
  21304. * - VertexBuffer.MatricesIndicesKind
  21305. * - VertexBuffer.MatricesIndicesExtraKind
  21306. * - VertexBuffer.MatricesWeightsKind
  21307. * - VertexBuffer.MatricesWeightsExtraKind
  21308. * @returns an array of strings
  21309. */
  21310. getVerticesDataKinds(): string[];
  21311. /**
  21312. * Returns a positive integer : the total number of indices in this mesh geometry.
  21313. * @returns the numner of indices or zero if the mesh has no geometry.
  21314. */
  21315. getTotalIndices(): number;
  21316. /**
  21317. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21318. * @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.
  21319. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21320. * @returns the indices array or an empty array if the mesh has no geometry
  21321. */
  21322. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21323. readonly isBlocked: boolean;
  21324. /**
  21325. * Determine if the current mesh is ready to be rendered
  21326. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21327. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21328. * @returns true if all associated assets are ready (material, textures, shaders)
  21329. */
  21330. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21331. /**
  21332. * 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.
  21333. */
  21334. readonly areNormalsFrozen: boolean;
  21335. /**
  21336. * 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.
  21337. * @returns the current mesh
  21338. */
  21339. freezeNormals(): Mesh;
  21340. /**
  21341. * 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
  21342. * @returns the current mesh
  21343. */
  21344. unfreezeNormals(): Mesh;
  21345. /**
  21346. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21347. */
  21348. overridenInstanceCount: number;
  21349. /** @hidden */
  21350. _preActivate(): Mesh;
  21351. /** @hidden */
  21352. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21353. /** @hidden */
  21354. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21355. /**
  21356. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21357. * This means the mesh underlying bounding box and sphere are recomputed.
  21358. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21359. * @returns the current mesh
  21360. */
  21361. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21362. /** @hidden */
  21363. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21364. /**
  21365. * This function will subdivide the mesh into multiple submeshes
  21366. * @param count defines the expected number of submeshes
  21367. */
  21368. subdivide(count: number): void;
  21369. /**
  21370. * Copy a FloatArray into a specific associated vertex buffer
  21371. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21372. * - VertexBuffer.PositionKind
  21373. * - VertexBuffer.UVKind
  21374. * - VertexBuffer.UV2Kind
  21375. * - VertexBuffer.UV3Kind
  21376. * - VertexBuffer.UV4Kind
  21377. * - VertexBuffer.UV5Kind
  21378. * - VertexBuffer.UV6Kind
  21379. * - VertexBuffer.ColorKind
  21380. * - VertexBuffer.MatricesIndicesKind
  21381. * - VertexBuffer.MatricesIndicesExtraKind
  21382. * - VertexBuffer.MatricesWeightsKind
  21383. * - VertexBuffer.MatricesWeightsExtraKind
  21384. * @param data defines the data source
  21385. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21386. * @param stride defines the data stride size (can be null)
  21387. * @returns the current mesh
  21388. */
  21389. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21390. /**
  21391. * Flags an associated vertex buffer as updatable
  21392. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21393. * - VertexBuffer.PositionKind
  21394. * - VertexBuffer.UVKind
  21395. * - VertexBuffer.UV2Kind
  21396. * - VertexBuffer.UV3Kind
  21397. * - VertexBuffer.UV4Kind
  21398. * - VertexBuffer.UV5Kind
  21399. * - VertexBuffer.UV6Kind
  21400. * - VertexBuffer.ColorKind
  21401. * - VertexBuffer.MatricesIndicesKind
  21402. * - VertexBuffer.MatricesIndicesExtraKind
  21403. * - VertexBuffer.MatricesWeightsKind
  21404. * - VertexBuffer.MatricesWeightsExtraKind
  21405. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21406. */
  21407. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21408. /**
  21409. * Sets the mesh global Vertex Buffer
  21410. * @param buffer defines the buffer to use
  21411. * @returns the current mesh
  21412. */
  21413. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21414. /**
  21415. * Update a specific associated vertex buffer
  21416. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21417. * - VertexBuffer.PositionKind
  21418. * - VertexBuffer.UVKind
  21419. * - VertexBuffer.UV2Kind
  21420. * - VertexBuffer.UV3Kind
  21421. * - VertexBuffer.UV4Kind
  21422. * - VertexBuffer.UV5Kind
  21423. * - VertexBuffer.UV6Kind
  21424. * - VertexBuffer.ColorKind
  21425. * - VertexBuffer.MatricesIndicesKind
  21426. * - VertexBuffer.MatricesIndicesExtraKind
  21427. * - VertexBuffer.MatricesWeightsKind
  21428. * - VertexBuffer.MatricesWeightsExtraKind
  21429. * @param data defines the data source
  21430. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21431. * @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)
  21432. * @returns the current mesh
  21433. */
  21434. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21435. /**
  21436. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21437. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21438. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21439. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21440. * @returns the current mesh
  21441. */
  21442. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21443. /**
  21444. * Creates a un-shared specific occurence of the geometry for the mesh.
  21445. * @returns the current mesh
  21446. */
  21447. makeGeometryUnique(): Mesh;
  21448. /**
  21449. * Set the index buffer of this mesh
  21450. * @param indices defines the source data
  21451. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21452. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21453. * @returns the current mesh
  21454. */
  21455. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21456. /**
  21457. * Update the current index buffer
  21458. * @param indices defines the source data
  21459. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21460. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21461. * @returns the current mesh
  21462. */
  21463. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21464. /**
  21465. * Invert the geometry to move from a right handed system to a left handed one.
  21466. * @returns the current mesh
  21467. */
  21468. toLeftHanded(): Mesh;
  21469. /** @hidden */
  21470. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21471. /** @hidden */
  21472. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21473. /**
  21474. * Registers for this mesh a javascript function called just before the rendering process
  21475. * @param func defines the function to call before rendering this mesh
  21476. * @returns the current mesh
  21477. */
  21478. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21479. /**
  21480. * Disposes a previously registered javascript function called before the rendering
  21481. * @param func defines the function to remove
  21482. * @returns the current mesh
  21483. */
  21484. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21485. /**
  21486. * Registers for this mesh a javascript function called just after the rendering is complete
  21487. * @param func defines the function to call after rendering this mesh
  21488. * @returns the current mesh
  21489. */
  21490. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21491. /**
  21492. * Disposes a previously registered javascript function called after the rendering.
  21493. * @param func defines the function to remove
  21494. * @returns the current mesh
  21495. */
  21496. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21497. /** @hidden */
  21498. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21499. /** @hidden */
  21500. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21501. /** @hidden */
  21502. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21503. /**
  21504. * 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
  21505. * @param subMesh defines the subMesh to render
  21506. * @param enableAlphaMode defines if alpha mode can be changed
  21507. * @returns the current mesh
  21508. */
  21509. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21510. private _onBeforeDraw;
  21511. /**
  21512. * Renormalize the mesh and patch it up if there are no weights
  21513. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21514. * However in the case of zero weights then we set just a single influence to 1.
  21515. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21516. */
  21517. cleanMatrixWeights(): void;
  21518. private normalizeSkinFourWeights;
  21519. private normalizeSkinWeightsAndExtra;
  21520. /**
  21521. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21522. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21523. * the user know there was an issue with importing the mesh
  21524. * @returns a validation object with skinned, valid and report string
  21525. */
  21526. validateSkinning(): {
  21527. skinned: boolean;
  21528. valid: boolean;
  21529. report: string;
  21530. };
  21531. /** @hidden */
  21532. _checkDelayState(): Mesh;
  21533. private _queueLoad;
  21534. /**
  21535. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21536. * A mesh is in the frustum if its bounding box intersects the frustum
  21537. * @param frustumPlanes defines the frustum to test
  21538. * @returns true if the mesh is in the frustum planes
  21539. */
  21540. isInFrustum(frustumPlanes: Plane[]): boolean;
  21541. /**
  21542. * Sets the mesh material by the material or multiMaterial `id` property
  21543. * @param id is a string identifying the material or the multiMaterial
  21544. * @returns the current mesh
  21545. */
  21546. setMaterialByID(id: string): Mesh;
  21547. /**
  21548. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21549. * @returns an array of IAnimatable
  21550. */
  21551. getAnimatables(): IAnimatable[];
  21552. /**
  21553. * Modifies the mesh geometry according to the passed transformation matrix.
  21554. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21555. * The mesh normals are modified using the same transformation.
  21556. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21557. * @param transform defines the transform matrix to use
  21558. * @see http://doc.babylonjs.com/resources/baking_transformations
  21559. * @returns the current mesh
  21560. */
  21561. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21562. /**
  21563. * Modifies the mesh geometry according to its own current World Matrix.
  21564. * The mesh World Matrix is then reset.
  21565. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21566. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21567. * @see http://doc.babylonjs.com/resources/baking_transformations
  21568. * @returns the current mesh
  21569. */
  21570. bakeCurrentTransformIntoVertices(): Mesh;
  21571. /** @hidden */
  21572. readonly _positions: Nullable<Vector3[]>;
  21573. /** @hidden */
  21574. _resetPointsArrayCache(): Mesh;
  21575. /** @hidden */
  21576. _generatePointsArray(): boolean;
  21577. /**
  21578. * Returns a new Mesh object generated from the current mesh properties.
  21579. * This method must not get confused with createInstance()
  21580. * @param name is a string, the name given to the new mesh
  21581. * @param newParent can be any Node object (default `null`)
  21582. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21583. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21584. * @returns a new mesh
  21585. */
  21586. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21587. /**
  21588. * Releases resources associated with this mesh.
  21589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21591. */
  21592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21593. /**
  21594. * Modifies the mesh geometry according to a displacement map.
  21595. * 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.
  21596. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21597. * @param url is a string, the URL from the image file is to be downloaded.
  21598. * @param minHeight is the lower limit of the displacement.
  21599. * @param maxHeight is the upper limit of the displacement.
  21600. * @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.
  21601. * @param uvOffset is an optional vector2 used to offset UV.
  21602. * @param uvScale is an optional vector2 used to scale UV.
  21603. * @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.
  21604. * @returns the Mesh.
  21605. */
  21606. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21607. /**
  21608. * Modifies the mesh geometry according to a displacementMap buffer.
  21609. * 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.
  21610. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21611. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21612. * @param heightMapWidth is the width of the buffer image.
  21613. * @param heightMapHeight is the height of the buffer image.
  21614. * @param minHeight is the lower limit of the displacement.
  21615. * @param maxHeight is the upper limit of the displacement.
  21616. * @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.
  21617. * @param uvOffset is an optional vector2 used to offset UV.
  21618. * @param uvScale is an optional vector2 used to scale UV.
  21619. * @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.
  21620. * @returns the Mesh.
  21621. */
  21622. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21623. /**
  21624. * Modify the mesh to get a flat shading rendering.
  21625. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21626. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21627. * @returns current mesh
  21628. */
  21629. convertToFlatShadedMesh(): Mesh;
  21630. /**
  21631. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21632. * In other words, more vertices, no more indices and a single bigger VBO.
  21633. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21634. * @returns current mesh
  21635. */
  21636. convertToUnIndexedMesh(): Mesh;
  21637. /**
  21638. * Inverses facet orientations.
  21639. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21640. * @param flipNormals will also inverts the normals
  21641. * @returns current mesh
  21642. */
  21643. flipFaces(flipNormals?: boolean): Mesh;
  21644. /**
  21645. * Increase the number of facets and hence vertices in a mesh
  21646. * Vertex normals are interpolated from existing vertex normals
  21647. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21648. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21649. */
  21650. increaseVertices(numberPerEdge: number): void;
  21651. /**
  21652. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21653. * This will undo any application of covertToFlatShadedMesh
  21654. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21655. */
  21656. forceSharedVertices(): void;
  21657. /** @hidden */
  21658. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21659. /** @hidden */
  21660. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21661. /**
  21662. * Creates a new InstancedMesh object from the mesh model.
  21663. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21664. * @param name defines the name of the new instance
  21665. * @returns a new InstancedMesh
  21666. */
  21667. createInstance(name: string): InstancedMesh;
  21668. /**
  21669. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21670. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21671. * @returns the current mesh
  21672. */
  21673. synchronizeInstances(): Mesh;
  21674. /**
  21675. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21676. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21677. * This should be used together with the simplification to avoid disappearing triangles.
  21678. * @param successCallback an optional success callback to be called after the optimization finished.
  21679. * @returns the current mesh
  21680. */
  21681. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21682. /**
  21683. * Serialize current mesh
  21684. * @param serializationObject defines the object which will receive the serialization data
  21685. */
  21686. serialize(serializationObject: any): void;
  21687. /** @hidden */
  21688. _syncGeometryWithMorphTargetManager(): void;
  21689. /** @hidden */
  21690. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21691. /**
  21692. * Returns a new Mesh object parsed from the source provided.
  21693. * @param parsedMesh is the source
  21694. * @param scene defines the hosting scene
  21695. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21696. * @returns a new Mesh
  21697. */
  21698. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21699. /**
  21700. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21701. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21702. * @param name defines the name of the mesh to create
  21703. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21704. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21705. * @param closePath creates a seam between the first and the last points of each path of the path array
  21706. * @param offset is taken in account only if the `pathArray` is containing a single path
  21707. * @param scene defines the hosting scene
  21708. * @param updatable defines if the mesh must be flagged as updatable
  21709. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21710. * @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)
  21711. * @returns a new Mesh
  21712. */
  21713. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21714. /**
  21715. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21716. * @param name defines the name of the mesh to create
  21717. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21718. * @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
  21719. * @param scene defines the hosting scene
  21720. * @param updatable defines if the mesh must be flagged as updatable
  21721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21722. * @returns a new Mesh
  21723. */
  21724. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21725. /**
  21726. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21727. * @param name defines the name of the mesh to create
  21728. * @param size sets the size (float) of each box side (default 1)
  21729. * @param scene defines the hosting scene
  21730. * @param updatable defines if the mesh must be flagged as updatable
  21731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21732. * @returns a new Mesh
  21733. */
  21734. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21735. /**
  21736. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21737. * @param name defines the name of the mesh to create
  21738. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21739. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21740. * @param scene defines the hosting scene
  21741. * @param updatable defines if the mesh must be flagged as updatable
  21742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21743. * @returns a new Mesh
  21744. */
  21745. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21746. /**
  21747. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21748. * @param name defines the name of the mesh to create
  21749. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21750. * @param diameterTop set the top cap diameter (floats, default 1)
  21751. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21752. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21753. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21754. * @param scene defines the hosting scene
  21755. * @param updatable defines if the mesh must be flagged as updatable
  21756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21757. * @returns a new Mesh
  21758. */
  21759. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21760. /**
  21761. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21762. * @param name defines the name of the mesh to create
  21763. * @param diameter sets the diameter size (float) of the torus (default 1)
  21764. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21765. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21766. * @param scene defines the hosting scene
  21767. * @param updatable defines if the mesh must be flagged as updatable
  21768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21769. * @returns a new Mesh
  21770. */
  21771. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21772. /**
  21773. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21774. * @param name defines the name of the mesh to create
  21775. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21776. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21777. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21778. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21779. * @param p the number of windings on X axis (positive integers, default 2)
  21780. * @param q the number of windings on Y axis (positive integers, default 3)
  21781. * @param scene defines the hosting scene
  21782. * @param updatable defines if the mesh must be flagged as updatable
  21783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21784. * @returns a new Mesh
  21785. */
  21786. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21787. /**
  21788. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21789. * @param name defines the name of the mesh to create
  21790. * @param points is an array successive Vector3
  21791. * @param scene defines the hosting scene
  21792. * @param updatable defines if the mesh must be flagged as updatable
  21793. * @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).
  21794. * @returns a new Mesh
  21795. */
  21796. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21797. /**
  21798. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21799. * @param name defines the name of the mesh to create
  21800. * @param points is an array successive Vector3
  21801. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21802. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21803. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21804. * @param scene defines the hosting scene
  21805. * @param updatable defines if the mesh must be flagged as updatable
  21806. * @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)
  21807. * @returns a new Mesh
  21808. */
  21809. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21810. /**
  21811. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21812. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21813. * 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.
  21814. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21815. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21816. * Remember you can only change the shape positions, not their number when updating a polygon.
  21817. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21818. * @param name defines the name of the mesh to create
  21819. * @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
  21820. * @param scene defines the hosting scene
  21821. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21822. * @param updatable defines if the mesh must be flagged as updatable
  21823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21824. * @param earcutInjection can be used to inject your own earcut reference
  21825. * @returns a new Mesh
  21826. */
  21827. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21828. /**
  21829. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21830. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21831. * @param name defines the name of the mesh to create
  21832. * @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
  21833. * @param depth defines the height of extrusion
  21834. * @param scene defines the hosting scene
  21835. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21836. * @param updatable defines if the mesh must be flagged as updatable
  21837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21838. * @param earcutInjection can be used to inject your own earcut reference
  21839. * @returns a new Mesh
  21840. */
  21841. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21842. /**
  21843. * Creates an extruded shape mesh.
  21844. * 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
  21845. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21846. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21847. * @param name defines the name of the mesh to create
  21848. * @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
  21849. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21850. * @param scale is the value to scale the shape
  21851. * @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
  21852. * @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
  21853. * @param scene defines the hosting scene
  21854. * @param updatable defines if the mesh must be flagged as updatable
  21855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21856. * @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)
  21857. * @returns a new Mesh
  21858. */
  21859. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21860. /**
  21861. * Creates an custom extruded shape mesh.
  21862. * The custom extrusion is a parametric shape.
  21863. * It has no predefined shape. Its final shape will depend on the input parameters.
  21864. * Please consider using the same method from the MeshBuilder class instead
  21865. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21866. * @param name defines the name of the mesh to create
  21867. * @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
  21868. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21869. * @param scaleFunction is a custom Javascript function called on each path point
  21870. * @param rotationFunction is a custom Javascript function called on each path point
  21871. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21872. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21873. * @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
  21874. * @param scene defines the hosting scene
  21875. * @param updatable defines if the mesh must be flagged as updatable
  21876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21877. * @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)
  21878. * @returns a new Mesh
  21879. */
  21880. 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;
  21881. /**
  21882. * Creates lathe mesh.
  21883. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21884. * Please consider using the same method from the MeshBuilder class instead
  21885. * @param name defines the name of the mesh to create
  21886. * @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
  21887. * @param radius is the radius value of the lathe
  21888. * @param tessellation is the side number of the lathe.
  21889. * @param scene defines the hosting scene
  21890. * @param updatable defines if the mesh must be flagged as updatable
  21891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21892. * @returns a new Mesh
  21893. */
  21894. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21895. /**
  21896. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21897. * @param name defines the name of the mesh to create
  21898. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21899. * @param scene defines the hosting scene
  21900. * @param updatable defines if the mesh must be flagged as updatable
  21901. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21902. * @returns a new Mesh
  21903. */
  21904. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21905. /**
  21906. * Creates a ground mesh.
  21907. * Please consider using the same method from the MeshBuilder class instead
  21908. * @param name defines the name of the mesh to create
  21909. * @param width set the width of the ground
  21910. * @param height set the height of the ground
  21911. * @param subdivisions sets the number of subdivisions per side
  21912. * @param scene defines the hosting scene
  21913. * @param updatable defines if the mesh must be flagged as updatable
  21914. * @returns a new Mesh
  21915. */
  21916. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21917. /**
  21918. * Creates a tiled ground mesh.
  21919. * Please consider using the same method from the MeshBuilder class instead
  21920. * @param name defines the name of the mesh to create
  21921. * @param xmin set the ground minimum X coordinate
  21922. * @param zmin set the ground minimum Y coordinate
  21923. * @param xmax set the ground maximum X coordinate
  21924. * @param zmax set the ground maximum Z coordinate
  21925. * @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
  21926. * @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
  21927. * @param scene defines the hosting scene
  21928. * @param updatable defines if the mesh must be flagged as updatable
  21929. * @returns a new Mesh
  21930. */
  21931. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21932. w: number;
  21933. h: number;
  21934. }, precision: {
  21935. w: number;
  21936. h: number;
  21937. }, scene: Scene, updatable?: boolean): Mesh;
  21938. /**
  21939. * Creates a ground mesh from a height map.
  21940. * Please consider using the same method from the MeshBuilder class instead
  21941. * @see http://doc.babylonjs.com/babylon101/height_map
  21942. * @param name defines the name of the mesh to create
  21943. * @param url sets the URL of the height map image resource
  21944. * @param width set the ground width size
  21945. * @param height set the ground height size
  21946. * @param subdivisions sets the number of subdivision per side
  21947. * @param minHeight is the minimum altitude on the ground
  21948. * @param maxHeight is the maximum altitude on the ground
  21949. * @param scene defines the hosting scene
  21950. * @param updatable defines if the mesh must be flagged as updatable
  21951. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21952. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21953. * @returns a new Mesh
  21954. */
  21955. 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;
  21956. /**
  21957. * Creates a tube mesh.
  21958. * The tube is a parametric shape.
  21959. * It has no predefined shape. Its final shape will depend on the input parameters.
  21960. * Please consider using the same method from the MeshBuilder class instead
  21961. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21962. * @param name defines the name of the mesh to create
  21963. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21964. * @param radius sets the tube radius size
  21965. * @param tessellation is the number of sides on the tubular surface
  21966. * @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
  21967. * @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
  21968. * @param scene defines the hosting scene
  21969. * @param updatable defines if the mesh must be flagged as updatable
  21970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21971. * @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)
  21972. * @returns a new Mesh
  21973. */
  21974. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21975. (i: number, distance: number): number;
  21976. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21977. /**
  21978. * Creates a polyhedron mesh.
  21979. * Please consider using the same method from the MeshBuilder class instead.
  21980. * * 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
  21981. * * The parameter `size` (positive float, default 1) sets the polygon size
  21982. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21983. * * 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`
  21984. * * 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
  21985. * * 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)`)
  21986. * * 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
  21987. * * 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
  21988. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21989. * * If you create a double-sided mesh, you can choose what parts of 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
  21990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21991. * @param name defines the name of the mesh to create
  21992. * @param options defines the options used to create the mesh
  21993. * @param scene defines the hosting scene
  21994. * @returns a new Mesh
  21995. */
  21996. static CreatePolyhedron(name: string, options: {
  21997. type?: number;
  21998. size?: number;
  21999. sizeX?: number;
  22000. sizeY?: number;
  22001. sizeZ?: number;
  22002. custom?: any;
  22003. faceUV?: Vector4[];
  22004. faceColors?: Color4[];
  22005. updatable?: boolean;
  22006. sideOrientation?: number;
  22007. }, scene: Scene): Mesh;
  22008. /**
  22009. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22010. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22011. * * 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`)
  22012. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22013. * * 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
  22014. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22015. * * If you create a double-sided mesh, you can choose what parts of 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
  22016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22017. * @param name defines the name of the mesh
  22018. * @param options defines the options used to create the mesh
  22019. * @param scene defines the hosting scene
  22020. * @returns a new Mesh
  22021. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22022. */
  22023. static CreateIcoSphere(name: string, options: {
  22024. radius?: number;
  22025. flat?: boolean;
  22026. subdivisions?: number;
  22027. sideOrientation?: number;
  22028. updatable?: boolean;
  22029. }, scene: Scene): Mesh;
  22030. /**
  22031. * Creates a decal mesh.
  22032. * Please consider using the same method from the MeshBuilder class instead.
  22033. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22034. * @param name defines the name of the mesh
  22035. * @param sourceMesh defines the mesh receiving the decal
  22036. * @param position sets the position of the decal in world coordinates
  22037. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22038. * @param size sets the decal scaling
  22039. * @param angle sets the angle to rotate the decal
  22040. * @returns a new Mesh
  22041. */
  22042. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22043. /**
  22044. * Prepare internal position array for software CPU skinning
  22045. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22046. */
  22047. setPositionsForCPUSkinning(): Float32Array;
  22048. /**
  22049. * Prepare internal normal array for software CPU skinning
  22050. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22051. */
  22052. setNormalsForCPUSkinning(): Float32Array;
  22053. /**
  22054. * Updates the vertex buffer by applying transformation from the bones
  22055. * @param skeleton defines the skeleton to apply to current mesh
  22056. * @returns the current mesh
  22057. */
  22058. applySkeleton(skeleton: Skeleton): Mesh;
  22059. /**
  22060. * 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
  22061. * @param meshes defines the list of meshes to scan
  22062. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22063. */
  22064. static MinMax(meshes: AbstractMesh[]): {
  22065. min: Vector3;
  22066. max: Vector3;
  22067. };
  22068. /**
  22069. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22070. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22071. * @returns a vector3
  22072. */
  22073. static Center(meshesOrMinMaxVector: {
  22074. min: Vector3;
  22075. max: Vector3;
  22076. } | AbstractMesh[]): Vector3;
  22077. /**
  22078. * Merge the array of meshes into a single mesh for performance reasons.
  22079. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22080. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22081. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22082. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22083. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22084. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22085. * @returns a new mesh
  22086. */
  22087. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22088. /** @hidden */
  22089. addInstance(instance: InstancedMesh): void;
  22090. /** @hidden */
  22091. removeInstance(instance: InstancedMesh): void;
  22092. }
  22093. }
  22094. declare module "babylonjs/Materials/material" {
  22095. import { IAnimatable } from "babylonjs/Misc/tools";
  22096. import { SmartArray } from "babylonjs/Misc/smartArray";
  22097. import { Observable } from "babylonjs/Misc/observable";
  22098. import { Nullable } from "babylonjs/types";
  22099. import { Scene } from "babylonjs/scene";
  22100. import { Matrix } from "babylonjs/Maths/math";
  22101. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22103. import { Mesh } from "babylonjs/Meshes/mesh";
  22104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22105. import { Effect } from "babylonjs/Materials/effect";
  22106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22107. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22108. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22109. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22110. import { Animation } from "babylonjs/Animations/animation";
  22111. /**
  22112. * Base class for the main features of a material in Babylon.js
  22113. */
  22114. export class Material implements IAnimatable {
  22115. /**
  22116. * Returns the triangle fill mode
  22117. */
  22118. static readonly TriangleFillMode: number;
  22119. /**
  22120. * Returns the wireframe mode
  22121. */
  22122. static readonly WireFrameFillMode: number;
  22123. /**
  22124. * Returns the point fill mode
  22125. */
  22126. static readonly PointFillMode: number;
  22127. /**
  22128. * Returns the point list draw mode
  22129. */
  22130. static readonly PointListDrawMode: number;
  22131. /**
  22132. * Returns the line list draw mode
  22133. */
  22134. static readonly LineListDrawMode: number;
  22135. /**
  22136. * Returns the line loop draw mode
  22137. */
  22138. static readonly LineLoopDrawMode: number;
  22139. /**
  22140. * Returns the line strip draw mode
  22141. */
  22142. static readonly LineStripDrawMode: number;
  22143. /**
  22144. * Returns the triangle strip draw mode
  22145. */
  22146. static readonly TriangleStripDrawMode: number;
  22147. /**
  22148. * Returns the triangle fan draw mode
  22149. */
  22150. static readonly TriangleFanDrawMode: number;
  22151. /**
  22152. * Stores the clock-wise side orientation
  22153. */
  22154. static readonly ClockWiseSideOrientation: number;
  22155. /**
  22156. * Stores the counter clock-wise side orientation
  22157. */
  22158. static readonly CounterClockWiseSideOrientation: number;
  22159. /**
  22160. * The dirty texture flag value
  22161. */
  22162. static readonly TextureDirtyFlag: number;
  22163. /**
  22164. * The dirty light flag value
  22165. */
  22166. static readonly LightDirtyFlag: number;
  22167. /**
  22168. * The dirty fresnel flag value
  22169. */
  22170. static readonly FresnelDirtyFlag: number;
  22171. /**
  22172. * The dirty attribute flag value
  22173. */
  22174. static readonly AttributesDirtyFlag: number;
  22175. /**
  22176. * The dirty misc flag value
  22177. */
  22178. static readonly MiscDirtyFlag: number;
  22179. /**
  22180. * The all dirty flag value
  22181. */
  22182. static readonly AllDirtyFlag: number;
  22183. /**
  22184. * The ID of the material
  22185. */
  22186. id: string;
  22187. /**
  22188. * Gets or sets the unique id of the material
  22189. */
  22190. uniqueId: number;
  22191. /**
  22192. * The name of the material
  22193. */
  22194. name: string;
  22195. /**
  22196. * Gets or sets user defined metadata
  22197. */
  22198. metadata: any;
  22199. /**
  22200. * For internal use only. Please do not use.
  22201. */
  22202. reservedDataStore: any;
  22203. /**
  22204. * Specifies if the ready state should be checked on each call
  22205. */
  22206. checkReadyOnEveryCall: boolean;
  22207. /**
  22208. * Specifies if the ready state should be checked once
  22209. */
  22210. checkReadyOnlyOnce: boolean;
  22211. /**
  22212. * The state of the material
  22213. */
  22214. state: string;
  22215. /**
  22216. * The alpha value of the material
  22217. */
  22218. protected _alpha: number;
  22219. /**
  22220. * List of inspectable custom properties (used by the Inspector)
  22221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22222. */
  22223. inspectableCustomProperties: IInspectable[];
  22224. /**
  22225. * Sets the alpha value of the material
  22226. */
  22227. /**
  22228. * Gets the alpha value of the material
  22229. */
  22230. alpha: number;
  22231. /**
  22232. * Specifies if back face culling is enabled
  22233. */
  22234. protected _backFaceCulling: boolean;
  22235. /**
  22236. * Sets the back-face culling state
  22237. */
  22238. /**
  22239. * Gets the back-face culling state
  22240. */
  22241. backFaceCulling: boolean;
  22242. /**
  22243. * Stores the value for side orientation
  22244. */
  22245. sideOrientation: number;
  22246. /**
  22247. * Callback triggered when the material is compiled
  22248. */
  22249. onCompiled: (effect: Effect) => void;
  22250. /**
  22251. * Callback triggered when an error occurs
  22252. */
  22253. onError: (effect: Effect, errors: string) => void;
  22254. /**
  22255. * Callback triggered to get the render target textures
  22256. */
  22257. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22258. /**
  22259. * Gets a boolean indicating that current material needs to register RTT
  22260. */
  22261. readonly hasRenderTargetTextures: boolean;
  22262. /**
  22263. * Specifies if the material should be serialized
  22264. */
  22265. doNotSerialize: boolean;
  22266. /**
  22267. * @hidden
  22268. */
  22269. _storeEffectOnSubMeshes: boolean;
  22270. /**
  22271. * Stores the animations for the material
  22272. */
  22273. animations: Array<Animation>;
  22274. /**
  22275. * An event triggered when the material is disposed
  22276. */
  22277. onDisposeObservable: Observable<Material>;
  22278. /**
  22279. * An observer which watches for dispose events
  22280. */
  22281. private _onDisposeObserver;
  22282. private _onUnBindObservable;
  22283. /**
  22284. * Called during a dispose event
  22285. */
  22286. onDispose: () => void;
  22287. private _onBindObservable;
  22288. /**
  22289. * An event triggered when the material is bound
  22290. */
  22291. readonly onBindObservable: Observable<AbstractMesh>;
  22292. /**
  22293. * An observer which watches for bind events
  22294. */
  22295. private _onBindObserver;
  22296. /**
  22297. * Called during a bind event
  22298. */
  22299. onBind: (Mesh: AbstractMesh) => void;
  22300. /**
  22301. * An event triggered when the material is unbound
  22302. */
  22303. readonly onUnBindObservable: Observable<Material>;
  22304. /**
  22305. * Stores the value of the alpha mode
  22306. */
  22307. private _alphaMode;
  22308. /**
  22309. * Sets the value of the alpha mode.
  22310. *
  22311. * | Value | Type | Description |
  22312. * | --- | --- | --- |
  22313. * | 0 | ALPHA_DISABLE | |
  22314. * | 1 | ALPHA_ADD | |
  22315. * | 2 | ALPHA_COMBINE | |
  22316. * | 3 | ALPHA_SUBTRACT | |
  22317. * | 4 | ALPHA_MULTIPLY | |
  22318. * | 5 | ALPHA_MAXIMIZED | |
  22319. * | 6 | ALPHA_ONEONE | |
  22320. * | 7 | ALPHA_PREMULTIPLIED | |
  22321. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22322. * | 9 | ALPHA_INTERPOLATE | |
  22323. * | 10 | ALPHA_SCREENMODE | |
  22324. *
  22325. */
  22326. /**
  22327. * Gets the value of the alpha mode
  22328. */
  22329. alphaMode: number;
  22330. /**
  22331. * Stores the state of the need depth pre-pass value
  22332. */
  22333. private _needDepthPrePass;
  22334. /**
  22335. * Sets the need depth pre-pass value
  22336. */
  22337. /**
  22338. * Gets the depth pre-pass value
  22339. */
  22340. needDepthPrePass: boolean;
  22341. /**
  22342. * Specifies if depth writing should be disabled
  22343. */
  22344. disableDepthWrite: boolean;
  22345. /**
  22346. * Specifies if depth writing should be forced
  22347. */
  22348. forceDepthWrite: boolean;
  22349. /**
  22350. * Specifies if there should be a separate pass for culling
  22351. */
  22352. separateCullingPass: boolean;
  22353. /**
  22354. * Stores the state specifing if fog should be enabled
  22355. */
  22356. private _fogEnabled;
  22357. /**
  22358. * Sets the state for enabling fog
  22359. */
  22360. /**
  22361. * Gets the value of the fog enabled state
  22362. */
  22363. fogEnabled: boolean;
  22364. /**
  22365. * Stores the size of points
  22366. */
  22367. pointSize: number;
  22368. /**
  22369. * Stores the z offset value
  22370. */
  22371. zOffset: number;
  22372. /**
  22373. * Gets a value specifying if wireframe mode is enabled
  22374. */
  22375. /**
  22376. * Sets the state of wireframe mode
  22377. */
  22378. wireframe: boolean;
  22379. /**
  22380. * Gets the value specifying if point clouds are enabled
  22381. */
  22382. /**
  22383. * Sets the state of point cloud mode
  22384. */
  22385. pointsCloud: boolean;
  22386. /**
  22387. * Gets the material fill mode
  22388. */
  22389. /**
  22390. * Sets the material fill mode
  22391. */
  22392. fillMode: number;
  22393. /**
  22394. * @hidden
  22395. * Stores the effects for the material
  22396. */
  22397. _effect: Nullable<Effect>;
  22398. /**
  22399. * @hidden
  22400. * Specifies if the material was previously ready
  22401. */
  22402. _wasPreviouslyReady: boolean;
  22403. /**
  22404. * Specifies if uniform buffers should be used
  22405. */
  22406. private _useUBO;
  22407. /**
  22408. * Stores a reference to the scene
  22409. */
  22410. private _scene;
  22411. /**
  22412. * Stores the fill mode state
  22413. */
  22414. private _fillMode;
  22415. /**
  22416. * Specifies if the depth write state should be cached
  22417. */
  22418. private _cachedDepthWriteState;
  22419. /**
  22420. * Stores the uniform buffer
  22421. */
  22422. protected _uniformBuffer: UniformBuffer;
  22423. /** @hidden */
  22424. _indexInSceneMaterialArray: number;
  22425. /** @hidden */
  22426. meshMap: Nullable<{
  22427. [id: string]: AbstractMesh | undefined;
  22428. }>;
  22429. /**
  22430. * Creates a material instance
  22431. * @param name defines the name of the material
  22432. * @param scene defines the scene to reference
  22433. * @param doNotAdd specifies if the material should be added to the scene
  22434. */
  22435. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22436. /**
  22437. * Returns a string representation of the current material
  22438. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22439. * @returns a string with material information
  22440. */
  22441. toString(fullDetails?: boolean): string;
  22442. /**
  22443. * Gets the class name of the material
  22444. * @returns a string with the class name of the material
  22445. */
  22446. getClassName(): string;
  22447. /**
  22448. * Specifies if updates for the material been locked
  22449. */
  22450. readonly isFrozen: boolean;
  22451. /**
  22452. * Locks updates for the material
  22453. */
  22454. freeze(): void;
  22455. /**
  22456. * Unlocks updates for the material
  22457. */
  22458. unfreeze(): void;
  22459. /**
  22460. * Specifies if the material is ready to be used
  22461. * @param mesh defines the mesh to check
  22462. * @param useInstances specifies if instances should be used
  22463. * @returns a boolean indicating if the material is ready to be used
  22464. */
  22465. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22466. /**
  22467. * Specifies that the submesh is ready to be used
  22468. * @param mesh defines the mesh to check
  22469. * @param subMesh defines which submesh to check
  22470. * @param useInstances specifies that instances should be used
  22471. * @returns a boolean indicating that the submesh is ready or not
  22472. */
  22473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22474. /**
  22475. * Returns the material effect
  22476. * @returns the effect associated with the material
  22477. */
  22478. getEffect(): Nullable<Effect>;
  22479. /**
  22480. * Returns the current scene
  22481. * @returns a Scene
  22482. */
  22483. getScene(): Scene;
  22484. /**
  22485. * Specifies if the material will require alpha blending
  22486. * @returns a boolean specifying if alpha blending is needed
  22487. */
  22488. needAlphaBlending(): boolean;
  22489. /**
  22490. * Specifies if the mesh will require alpha blending
  22491. * @param mesh defines the mesh to check
  22492. * @returns a boolean specifying if alpha blending is needed for the mesh
  22493. */
  22494. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22495. /**
  22496. * Specifies if this material should be rendered in alpha test mode
  22497. * @returns a boolean specifying if an alpha test is needed.
  22498. */
  22499. needAlphaTesting(): boolean;
  22500. /**
  22501. * Gets the texture used for the alpha test
  22502. * @returns the texture to use for alpha testing
  22503. */
  22504. getAlphaTestTexture(): Nullable<BaseTexture>;
  22505. /**
  22506. * Marks the material to indicate that it needs to be re-calculated
  22507. */
  22508. markDirty(): void;
  22509. /** @hidden */
  22510. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22511. /**
  22512. * Binds the material to the mesh
  22513. * @param world defines the world transformation matrix
  22514. * @param mesh defines the mesh to bind the material to
  22515. */
  22516. bind(world: Matrix, mesh?: Mesh): void;
  22517. /**
  22518. * Binds the submesh to the material
  22519. * @param world defines the world transformation matrix
  22520. * @param mesh defines the mesh containing the submesh
  22521. * @param subMesh defines the submesh to bind the material to
  22522. */
  22523. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22524. /**
  22525. * Binds the world matrix to the material
  22526. * @param world defines the world transformation matrix
  22527. */
  22528. bindOnlyWorldMatrix(world: Matrix): void;
  22529. /**
  22530. * Binds the scene's uniform buffer to the effect.
  22531. * @param effect defines the effect to bind to the scene uniform buffer
  22532. * @param sceneUbo defines the uniform buffer storing scene data
  22533. */
  22534. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22535. /**
  22536. * Binds the view matrix to the effect
  22537. * @param effect defines the effect to bind the view matrix to
  22538. */
  22539. bindView(effect: Effect): void;
  22540. /**
  22541. * Binds the view projection matrix to the effect
  22542. * @param effect defines the effect to bind the view projection matrix to
  22543. */
  22544. bindViewProjection(effect: Effect): void;
  22545. /**
  22546. * Specifies if material alpha testing should be turned on for the mesh
  22547. * @param mesh defines the mesh to check
  22548. */
  22549. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22550. /**
  22551. * Processes to execute after binding the material to a mesh
  22552. * @param mesh defines the rendered mesh
  22553. */
  22554. protected _afterBind(mesh?: Mesh): void;
  22555. /**
  22556. * Unbinds the material from the mesh
  22557. */
  22558. unbind(): void;
  22559. /**
  22560. * Gets the active textures from the material
  22561. * @returns an array of textures
  22562. */
  22563. getActiveTextures(): BaseTexture[];
  22564. /**
  22565. * Specifies if the material uses a texture
  22566. * @param texture defines the texture to check against the material
  22567. * @returns a boolean specifying if the material uses the texture
  22568. */
  22569. hasTexture(texture: BaseTexture): boolean;
  22570. /**
  22571. * Makes a duplicate of the material, and gives it a new name
  22572. * @param name defines the new name for the duplicated material
  22573. * @returns the cloned material
  22574. */
  22575. clone(name: string): Nullable<Material>;
  22576. /**
  22577. * Gets the meshes bound to the material
  22578. * @returns an array of meshes bound to the material
  22579. */
  22580. getBindedMeshes(): AbstractMesh[];
  22581. /**
  22582. * Force shader compilation
  22583. * @param mesh defines the mesh associated with this material
  22584. * @param onCompiled defines a function to execute once the material is compiled
  22585. * @param options defines the options to configure the compilation
  22586. */
  22587. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22588. clipPlane: boolean;
  22589. }>): void;
  22590. /**
  22591. * Force shader compilation
  22592. * @param mesh defines the mesh that will use this material
  22593. * @param options defines additional options for compiling the shaders
  22594. * @returns a promise that resolves when the compilation completes
  22595. */
  22596. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22597. clipPlane: boolean;
  22598. }>): Promise<void>;
  22599. private static readonly _ImageProcessingDirtyCallBack;
  22600. private static readonly _TextureDirtyCallBack;
  22601. private static readonly _FresnelDirtyCallBack;
  22602. private static readonly _MiscDirtyCallBack;
  22603. private static readonly _LightsDirtyCallBack;
  22604. private static readonly _AttributeDirtyCallBack;
  22605. private static _FresnelAndMiscDirtyCallBack;
  22606. private static _TextureAndMiscDirtyCallBack;
  22607. private static readonly _DirtyCallbackArray;
  22608. private static readonly _RunDirtyCallBacks;
  22609. /**
  22610. * Marks a define in the material to indicate that it needs to be re-computed
  22611. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22612. */
  22613. markAsDirty(flag: number): void;
  22614. /**
  22615. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22616. * @param func defines a function which checks material defines against the submeshes
  22617. */
  22618. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22619. /**
  22620. * Indicates that image processing needs to be re-calculated for all submeshes
  22621. */
  22622. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22623. /**
  22624. * Indicates that textures need to be re-calculated for all submeshes
  22625. */
  22626. protected _markAllSubMeshesAsTexturesDirty(): void;
  22627. /**
  22628. * Indicates that fresnel needs to be re-calculated for all submeshes
  22629. */
  22630. protected _markAllSubMeshesAsFresnelDirty(): void;
  22631. /**
  22632. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22633. */
  22634. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22635. /**
  22636. * Indicates that lights need to be re-calculated for all submeshes
  22637. */
  22638. protected _markAllSubMeshesAsLightsDirty(): void;
  22639. /**
  22640. * Indicates that attributes need to be re-calculated for all submeshes
  22641. */
  22642. protected _markAllSubMeshesAsAttributesDirty(): void;
  22643. /**
  22644. * Indicates that misc needs to be re-calculated for all submeshes
  22645. */
  22646. protected _markAllSubMeshesAsMiscDirty(): void;
  22647. /**
  22648. * Indicates that textures and misc need to be re-calculated for all submeshes
  22649. */
  22650. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22651. /**
  22652. * Disposes the material
  22653. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22654. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22655. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22656. */
  22657. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22658. /** @hidden */
  22659. private releaseVertexArrayObject;
  22660. /**
  22661. * Serializes this material
  22662. * @returns the serialized material object
  22663. */
  22664. serialize(): any;
  22665. /**
  22666. * Creates a material from parsed material data
  22667. * @param parsedMaterial defines parsed material data
  22668. * @param scene defines the hosting scene
  22669. * @param rootUrl defines the root URL to use to load textures
  22670. * @returns a new material
  22671. */
  22672. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22673. }
  22674. }
  22675. declare module "babylonjs/Meshes/subMesh" {
  22676. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22677. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22678. import { Engine } from "babylonjs/Engines/engine";
  22679. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22680. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22681. import { Effect } from "babylonjs/Materials/effect";
  22682. import { Collider } from "babylonjs/Collisions/collider";
  22683. import { Material } from "babylonjs/Materials/material";
  22684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22686. import { Mesh } from "babylonjs/Meshes/mesh";
  22687. import { Ray } from "babylonjs/Culling/ray";
  22688. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22689. /**
  22690. * Base class for submeshes
  22691. */
  22692. export class BaseSubMesh {
  22693. /** @hidden */
  22694. _materialDefines: Nullable<MaterialDefines>;
  22695. /** @hidden */
  22696. _materialEffect: Nullable<Effect>;
  22697. /**
  22698. * Gets associated effect
  22699. */
  22700. readonly effect: Nullable<Effect>;
  22701. /**
  22702. * Sets associated effect (effect used to render this submesh)
  22703. * @param effect defines the effect to associate with
  22704. * @param defines defines the set of defines used to compile this effect
  22705. */
  22706. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22707. }
  22708. /**
  22709. * Defines a subdivision inside a mesh
  22710. */
  22711. export class SubMesh extends BaseSubMesh implements ICullable {
  22712. /** the material index to use */
  22713. materialIndex: number;
  22714. /** vertex index start */
  22715. verticesStart: number;
  22716. /** vertices count */
  22717. verticesCount: number;
  22718. /** index start */
  22719. indexStart: number;
  22720. /** indices count */
  22721. indexCount: number;
  22722. /** @hidden */
  22723. _linesIndexCount: number;
  22724. private _mesh;
  22725. private _renderingMesh;
  22726. private _boundingInfo;
  22727. private _linesIndexBuffer;
  22728. /** @hidden */
  22729. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22730. /** @hidden */
  22731. _trianglePlanes: Plane[];
  22732. /** @hidden */
  22733. _lastColliderTransformMatrix: Matrix;
  22734. /** @hidden */
  22735. _renderId: number;
  22736. /** @hidden */
  22737. _alphaIndex: number;
  22738. /** @hidden */
  22739. _distanceToCamera: number;
  22740. /** @hidden */
  22741. _id: number;
  22742. private _currentMaterial;
  22743. /**
  22744. * Add a new submesh to a mesh
  22745. * @param materialIndex defines the material index to use
  22746. * @param verticesStart defines vertex index start
  22747. * @param verticesCount defines vertices count
  22748. * @param indexStart defines index start
  22749. * @param indexCount defines indices count
  22750. * @param mesh defines the parent mesh
  22751. * @param renderingMesh defines an optional rendering mesh
  22752. * @param createBoundingBox defines if bounding box should be created for this submesh
  22753. * @returns the new submesh
  22754. */
  22755. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22756. /**
  22757. * Creates a new submesh
  22758. * @param materialIndex defines the material index to use
  22759. * @param verticesStart defines vertex index start
  22760. * @param verticesCount defines vertices count
  22761. * @param indexStart defines index start
  22762. * @param indexCount defines indices count
  22763. * @param mesh defines the parent mesh
  22764. * @param renderingMesh defines an optional rendering mesh
  22765. * @param createBoundingBox defines if bounding box should be created for this submesh
  22766. */
  22767. constructor(
  22768. /** the material index to use */
  22769. materialIndex: number,
  22770. /** vertex index start */
  22771. verticesStart: number,
  22772. /** vertices count */
  22773. verticesCount: number,
  22774. /** index start */
  22775. indexStart: number,
  22776. /** indices count */
  22777. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22778. /**
  22779. * Returns true if this submesh covers the entire parent mesh
  22780. * @ignorenaming
  22781. */
  22782. readonly IsGlobal: boolean;
  22783. /**
  22784. * Returns the submesh BoudingInfo object
  22785. * @returns current bounding info (or mesh's one if the submesh is global)
  22786. */
  22787. getBoundingInfo(): BoundingInfo;
  22788. /**
  22789. * Sets the submesh BoundingInfo
  22790. * @param boundingInfo defines the new bounding info to use
  22791. * @returns the SubMesh
  22792. */
  22793. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22794. /**
  22795. * Returns the mesh of the current submesh
  22796. * @return the parent mesh
  22797. */
  22798. getMesh(): AbstractMesh;
  22799. /**
  22800. * Returns the rendering mesh of the submesh
  22801. * @returns the rendering mesh (could be different from parent mesh)
  22802. */
  22803. getRenderingMesh(): Mesh;
  22804. /**
  22805. * Returns the submesh material
  22806. * @returns null or the current material
  22807. */
  22808. getMaterial(): Nullable<Material>;
  22809. /**
  22810. * Sets a new updated BoundingInfo object to the submesh
  22811. * @returns the SubMesh
  22812. */
  22813. refreshBoundingInfo(): SubMesh;
  22814. /** @hidden */
  22815. _checkCollision(collider: Collider): boolean;
  22816. /**
  22817. * Updates the submesh BoundingInfo
  22818. * @param world defines the world matrix to use to update the bounding info
  22819. * @returns the submesh
  22820. */
  22821. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22822. /**
  22823. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22824. * @param frustumPlanes defines the frustum planes
  22825. * @returns true if the submesh is intersecting with the frustum
  22826. */
  22827. isInFrustum(frustumPlanes: Plane[]): boolean;
  22828. /**
  22829. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22830. * @param frustumPlanes defines the frustum planes
  22831. * @returns true if the submesh is inside the frustum
  22832. */
  22833. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22834. /**
  22835. * Renders the submesh
  22836. * @param enableAlphaMode defines if alpha needs to be used
  22837. * @returns the submesh
  22838. */
  22839. render(enableAlphaMode: boolean): SubMesh;
  22840. /**
  22841. * @hidden
  22842. */
  22843. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22844. /**
  22845. * Checks if the submesh intersects with a ray
  22846. * @param ray defines the ray to test
  22847. * @returns true is the passed ray intersects the submesh bounding box
  22848. */
  22849. canIntersects(ray: Ray): boolean;
  22850. /**
  22851. * Intersects current submesh with a ray
  22852. * @param ray defines the ray to test
  22853. * @param positions defines mesh's positions array
  22854. * @param indices defines mesh's indices array
  22855. * @param fastCheck defines if only bounding info should be used
  22856. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22857. * @returns intersection info or null if no intersection
  22858. */
  22859. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22860. /** @hidden */
  22861. private _intersectLines;
  22862. /** @hidden */
  22863. private _intersectTriangles;
  22864. /** @hidden */
  22865. _rebuild(): void;
  22866. /**
  22867. * Creates a new submesh from the passed mesh
  22868. * @param newMesh defines the new hosting mesh
  22869. * @param newRenderingMesh defines an optional rendering mesh
  22870. * @returns the new submesh
  22871. */
  22872. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22873. /**
  22874. * Release associated resources
  22875. */
  22876. dispose(): void;
  22877. /**
  22878. * Gets the class name
  22879. * @returns the string "SubMesh".
  22880. */
  22881. getClassName(): string;
  22882. /**
  22883. * Creates a new submesh from indices data
  22884. * @param materialIndex the index of the main mesh material
  22885. * @param startIndex the index where to start the copy in the mesh indices array
  22886. * @param indexCount the number of indices to copy then from the startIndex
  22887. * @param mesh the main mesh to create the submesh from
  22888. * @param renderingMesh the optional rendering mesh
  22889. * @returns a new submesh
  22890. */
  22891. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22892. }
  22893. }
  22894. declare module "babylonjs/Meshes/geometry" {
  22895. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22896. import { Scene } from "babylonjs/scene";
  22897. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22898. import { Engine } from "babylonjs/Engines/engine";
  22899. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22900. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22901. import { Effect } from "babylonjs/Materials/effect";
  22902. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22903. import { Mesh } from "babylonjs/Meshes/mesh";
  22904. /**
  22905. * Class used to store geometry data (vertex buffers + index buffer)
  22906. */
  22907. export class Geometry implements IGetSetVerticesData {
  22908. /**
  22909. * Gets or sets the ID of the geometry
  22910. */
  22911. id: string;
  22912. /**
  22913. * Gets or sets the unique ID of the geometry
  22914. */
  22915. uniqueId: number;
  22916. /**
  22917. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22918. */
  22919. delayLoadState: number;
  22920. /**
  22921. * Gets the file containing the data to load when running in delay load state
  22922. */
  22923. delayLoadingFile: Nullable<string>;
  22924. /**
  22925. * Callback called when the geometry is updated
  22926. */
  22927. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22928. private _scene;
  22929. private _engine;
  22930. private _meshes;
  22931. private _totalVertices;
  22932. /** @hidden */
  22933. _indices: IndicesArray;
  22934. /** @hidden */
  22935. _vertexBuffers: {
  22936. [key: string]: VertexBuffer;
  22937. };
  22938. private _isDisposed;
  22939. private _extend;
  22940. private _boundingBias;
  22941. /** @hidden */
  22942. _delayInfo: Array<string>;
  22943. private _indexBuffer;
  22944. private _indexBufferIsUpdatable;
  22945. /** @hidden */
  22946. _boundingInfo: Nullable<BoundingInfo>;
  22947. /** @hidden */
  22948. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22949. /** @hidden */
  22950. _softwareSkinningFrameId: number;
  22951. private _vertexArrayObjects;
  22952. private _updatable;
  22953. /** @hidden */
  22954. _positions: Nullable<Vector3[]>;
  22955. /**
  22956. * 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
  22957. */
  22958. /**
  22959. * 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
  22960. */
  22961. boundingBias: Vector2;
  22962. /**
  22963. * Static function used to attach a new empty geometry to a mesh
  22964. * @param mesh defines the mesh to attach the geometry to
  22965. * @returns the new Geometry
  22966. */
  22967. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22968. /**
  22969. * Creates a new geometry
  22970. * @param id defines the unique ID
  22971. * @param scene defines the hosting scene
  22972. * @param vertexData defines the VertexData used to get geometry data
  22973. * @param updatable defines if geometry must be updatable (false by default)
  22974. * @param mesh defines the mesh that will be associated with the geometry
  22975. */
  22976. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22977. /**
  22978. * Gets the current extend of the geometry
  22979. */
  22980. readonly extend: {
  22981. minimum: Vector3;
  22982. maximum: Vector3;
  22983. };
  22984. /**
  22985. * Gets the hosting scene
  22986. * @returns the hosting Scene
  22987. */
  22988. getScene(): Scene;
  22989. /**
  22990. * Gets the hosting engine
  22991. * @returns the hosting Engine
  22992. */
  22993. getEngine(): Engine;
  22994. /**
  22995. * Defines if the geometry is ready to use
  22996. * @returns true if the geometry is ready to be used
  22997. */
  22998. isReady(): boolean;
  22999. /**
  23000. * Gets a value indicating that the geometry should not be serialized
  23001. */
  23002. readonly doNotSerialize: boolean;
  23003. /** @hidden */
  23004. _rebuild(): void;
  23005. /**
  23006. * Affects all geometry data in one call
  23007. * @param vertexData defines the geometry data
  23008. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23009. */
  23010. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23011. /**
  23012. * Set specific vertex data
  23013. * @param kind defines the data kind (Position, normal, etc...)
  23014. * @param data defines the vertex data to use
  23015. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23016. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23017. */
  23018. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23019. /**
  23020. * Removes a specific vertex data
  23021. * @param kind defines the data kind (Position, normal, etc...)
  23022. */
  23023. removeVerticesData(kind: string): void;
  23024. /**
  23025. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23026. * @param buffer defines the vertex buffer to use
  23027. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23028. */
  23029. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23030. /**
  23031. * Update a specific vertex buffer
  23032. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23033. * It will do nothing if the buffer is not updatable
  23034. * @param kind defines the data kind (Position, normal, etc...)
  23035. * @param data defines the data to use
  23036. * @param offset defines the offset in the target buffer where to store the data
  23037. * @param useBytes set to true if the offset is in bytes
  23038. */
  23039. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23040. /**
  23041. * Update a specific vertex buffer
  23042. * This function will create a new buffer if the current one is not updatable
  23043. * @param kind defines the data kind (Position, normal, etc...)
  23044. * @param data defines the data to use
  23045. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23046. */
  23047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23048. private _updateBoundingInfo;
  23049. /** @hidden */
  23050. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23051. /**
  23052. * Gets total number of vertices
  23053. * @returns the total number of vertices
  23054. */
  23055. getTotalVertices(): number;
  23056. /**
  23057. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23058. * @param kind defines the data kind (Position, normal, etc...)
  23059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23061. * @returns a float array containing vertex data
  23062. */
  23063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23064. /**
  23065. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23066. * @param kind defines the data kind (Position, normal, etc...)
  23067. * @returns true if the vertex buffer with the specified kind is updatable
  23068. */
  23069. isVertexBufferUpdatable(kind: string): boolean;
  23070. /**
  23071. * Gets a specific vertex buffer
  23072. * @param kind defines the data kind (Position, normal, etc...)
  23073. * @returns a VertexBuffer
  23074. */
  23075. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23076. /**
  23077. * Returns all vertex buffers
  23078. * @return an object holding all vertex buffers indexed by kind
  23079. */
  23080. getVertexBuffers(): Nullable<{
  23081. [key: string]: VertexBuffer;
  23082. }>;
  23083. /**
  23084. * Gets a boolean indicating if specific vertex buffer is present
  23085. * @param kind defines the data kind (Position, normal, etc...)
  23086. * @returns true if data is present
  23087. */
  23088. isVerticesDataPresent(kind: string): boolean;
  23089. /**
  23090. * Gets a list of all attached data kinds (Position, normal, etc...)
  23091. * @returns a list of string containing all kinds
  23092. */
  23093. getVerticesDataKinds(): string[];
  23094. /**
  23095. * Update index buffer
  23096. * @param indices defines the indices to store in the index buffer
  23097. * @param offset defines the offset in the target buffer where to store the data
  23098. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  23099. */
  23100. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23101. /**
  23102. * Creates a new index buffer
  23103. * @param indices defines the indices to store in the index buffer
  23104. * @param totalVertices defines the total number of vertices (could be null)
  23105. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23106. */
  23107. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23108. /**
  23109. * Return the total number of indices
  23110. * @returns the total number of indices
  23111. */
  23112. getTotalIndices(): number;
  23113. /**
  23114. * Gets the index buffer array
  23115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23117. * @returns the index buffer array
  23118. */
  23119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23120. /**
  23121. * Gets the index buffer
  23122. * @return the index buffer
  23123. */
  23124. getIndexBuffer(): Nullable<WebGLBuffer>;
  23125. /** @hidden */
  23126. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23127. /**
  23128. * Release the associated resources for a specific mesh
  23129. * @param mesh defines the source mesh
  23130. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23131. */
  23132. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23133. /**
  23134. * Apply current geometry to a given mesh
  23135. * @param mesh defines the mesh to apply geometry to
  23136. */
  23137. applyToMesh(mesh: Mesh): void;
  23138. private _updateExtend;
  23139. private _applyToMesh;
  23140. private notifyUpdate;
  23141. /**
  23142. * Load the geometry if it was flagged as delay loaded
  23143. * @param scene defines the hosting scene
  23144. * @param onLoaded defines a callback called when the geometry is loaded
  23145. */
  23146. load(scene: Scene, onLoaded?: () => void): void;
  23147. private _queueLoad;
  23148. /**
  23149. * Invert the geometry to move from a right handed system to a left handed one.
  23150. */
  23151. toLeftHanded(): void;
  23152. /** @hidden */
  23153. _resetPointsArrayCache(): void;
  23154. /** @hidden */
  23155. _generatePointsArray(): boolean;
  23156. /**
  23157. * Gets a value indicating if the geometry is disposed
  23158. * @returns true if the geometry was disposed
  23159. */
  23160. isDisposed(): boolean;
  23161. private _disposeVertexArrayObjects;
  23162. /**
  23163. * Free all associated resources
  23164. */
  23165. dispose(): void;
  23166. /**
  23167. * Clone the current geometry into a new geometry
  23168. * @param id defines the unique ID of the new geometry
  23169. * @returns a new geometry object
  23170. */
  23171. copy(id: string): Geometry;
  23172. /**
  23173. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23174. * @return a JSON representation of the current geometry data (without the vertices data)
  23175. */
  23176. serialize(): any;
  23177. private toNumberArray;
  23178. /**
  23179. * Serialize all vertices data into a JSON oject
  23180. * @returns a JSON representation of the current geometry data
  23181. */
  23182. serializeVerticeData(): any;
  23183. /**
  23184. * Extracts a clone of a mesh geometry
  23185. * @param mesh defines the source mesh
  23186. * @param id defines the unique ID of the new geometry object
  23187. * @returns the new geometry object
  23188. */
  23189. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23190. /**
  23191. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23192. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23193. * Be aware Math.random() could cause collisions, but:
  23194. * "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"
  23195. * @returns a string containing a new GUID
  23196. */
  23197. static RandomId(): string;
  23198. /** @hidden */
  23199. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23200. private static _CleanMatricesWeights;
  23201. /**
  23202. * Create a new geometry from persisted data (Using .babylon file format)
  23203. * @param parsedVertexData defines the persisted data
  23204. * @param scene defines the hosting scene
  23205. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23206. * @returns the new geometry object
  23207. */
  23208. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23209. }
  23210. }
  23211. declare module "babylonjs/Meshes/mesh.vertexData" {
  23212. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23213. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23214. import { Geometry } from "babylonjs/Meshes/geometry";
  23215. import { Mesh } from "babylonjs/Meshes/mesh";
  23216. /**
  23217. * Define an interface for all classes that will get and set the data on vertices
  23218. */
  23219. export interface IGetSetVerticesData {
  23220. /**
  23221. * Gets a boolean indicating if specific vertex data is present
  23222. * @param kind defines the vertex data kind to use
  23223. * @returns true is data kind is present
  23224. */
  23225. isVerticesDataPresent(kind: string): boolean;
  23226. /**
  23227. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23228. * @param kind defines the data kind (Position, normal, etc...)
  23229. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23231. * @returns a float array containing vertex data
  23232. */
  23233. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23234. /**
  23235. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23236. * @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.
  23237. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23238. * @returns the indices array or an empty array if the mesh has no geometry
  23239. */
  23240. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23241. /**
  23242. * Set specific vertex data
  23243. * @param kind defines the data kind (Position, normal, etc...)
  23244. * @param data defines the vertex data to use
  23245. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23246. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23247. */
  23248. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23249. /**
  23250. * Update a specific associated vertex buffer
  23251. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23252. * - VertexBuffer.PositionKind
  23253. * - VertexBuffer.UVKind
  23254. * - VertexBuffer.UV2Kind
  23255. * - VertexBuffer.UV3Kind
  23256. * - VertexBuffer.UV4Kind
  23257. * - VertexBuffer.UV5Kind
  23258. * - VertexBuffer.UV6Kind
  23259. * - VertexBuffer.ColorKind
  23260. * - VertexBuffer.MatricesIndicesKind
  23261. * - VertexBuffer.MatricesIndicesExtraKind
  23262. * - VertexBuffer.MatricesWeightsKind
  23263. * - VertexBuffer.MatricesWeightsExtraKind
  23264. * @param data defines the data source
  23265. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23266. * @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)
  23267. */
  23268. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23269. /**
  23270. * Creates a new index buffer
  23271. * @param indices defines the indices to store in the index buffer
  23272. * @param totalVertices defines the total number of vertices (could be null)
  23273. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23274. */
  23275. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23276. }
  23277. /**
  23278. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23279. */
  23280. export class VertexData {
  23281. /**
  23282. * Mesh side orientation : usually the external or front surface
  23283. */
  23284. static readonly FRONTSIDE: number;
  23285. /**
  23286. * Mesh side orientation : usually the internal or back surface
  23287. */
  23288. static readonly BACKSIDE: number;
  23289. /**
  23290. * Mesh side orientation : both internal and external or front and back surfaces
  23291. */
  23292. static readonly DOUBLESIDE: number;
  23293. /**
  23294. * Mesh side orientation : by default, `FRONTSIDE`
  23295. */
  23296. static readonly DEFAULTSIDE: number;
  23297. /**
  23298. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23299. */
  23300. positions: Nullable<FloatArray>;
  23301. /**
  23302. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23303. */
  23304. normals: Nullable<FloatArray>;
  23305. /**
  23306. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23307. */
  23308. tangents: Nullable<FloatArray>;
  23309. /**
  23310. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23311. */
  23312. uvs: Nullable<FloatArray>;
  23313. /**
  23314. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23315. */
  23316. uvs2: Nullable<FloatArray>;
  23317. /**
  23318. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23319. */
  23320. uvs3: Nullable<FloatArray>;
  23321. /**
  23322. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23323. */
  23324. uvs4: Nullable<FloatArray>;
  23325. /**
  23326. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23327. */
  23328. uvs5: Nullable<FloatArray>;
  23329. /**
  23330. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23331. */
  23332. uvs6: Nullable<FloatArray>;
  23333. /**
  23334. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23335. */
  23336. colors: Nullable<FloatArray>;
  23337. /**
  23338. * 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).
  23339. */
  23340. matricesIndices: Nullable<FloatArray>;
  23341. /**
  23342. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23343. */
  23344. matricesWeights: Nullable<FloatArray>;
  23345. /**
  23346. * An array extending the number of possible indices
  23347. */
  23348. matricesIndicesExtra: Nullable<FloatArray>;
  23349. /**
  23350. * An array extending the number of possible weights when the number of indices is extended
  23351. */
  23352. matricesWeightsExtra: Nullable<FloatArray>;
  23353. /**
  23354. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23355. */
  23356. indices: Nullable<IndicesArray>;
  23357. /**
  23358. * Uses the passed data array to set the set the values for the specified kind of data
  23359. * @param data a linear array of floating numbers
  23360. * @param kind the type of data that is being set, eg positions, colors etc
  23361. */
  23362. set(data: FloatArray, kind: string): void;
  23363. /**
  23364. * Associates the vertexData to the passed Mesh.
  23365. * Sets it as updatable or not (default `false`)
  23366. * @param mesh the mesh the vertexData is applied to
  23367. * @param updatable when used and having the value true allows new data to update the vertexData
  23368. * @returns the VertexData
  23369. */
  23370. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23371. /**
  23372. * Associates the vertexData to the passed Geometry.
  23373. * Sets it as updatable or not (default `false`)
  23374. * @param geometry the geometry the vertexData is applied to
  23375. * @param updatable when used and having the value true allows new data to update the vertexData
  23376. * @returns VertexData
  23377. */
  23378. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23379. /**
  23380. * Updates the associated mesh
  23381. * @param mesh the mesh to be updated
  23382. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23383. * @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
  23384. * @returns VertexData
  23385. */
  23386. updateMesh(mesh: Mesh): VertexData;
  23387. /**
  23388. * Updates the associated geometry
  23389. * @param geometry the geometry to be updated
  23390. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23391. * @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
  23392. * @returns VertexData.
  23393. */
  23394. updateGeometry(geometry: Geometry): VertexData;
  23395. private _applyTo;
  23396. private _update;
  23397. /**
  23398. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23399. * @param matrix the transforming matrix
  23400. * @returns the VertexData
  23401. */
  23402. transform(matrix: Matrix): VertexData;
  23403. /**
  23404. * Merges the passed VertexData into the current one
  23405. * @param other the VertexData to be merged into the current one
  23406. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23407. * @returns the modified VertexData
  23408. */
  23409. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23410. private _mergeElement;
  23411. private _validate;
  23412. /**
  23413. * Serializes the VertexData
  23414. * @returns a serialized object
  23415. */
  23416. serialize(): any;
  23417. /**
  23418. * Extracts the vertexData from a mesh
  23419. * @param mesh the mesh from which to extract the VertexData
  23420. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23421. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23422. * @returns the object VertexData associated to the passed mesh
  23423. */
  23424. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23425. /**
  23426. * Extracts the vertexData from the geometry
  23427. * @param geometry the geometry from which to extract the VertexData
  23428. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23429. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23430. * @returns the object VertexData associated to the passed mesh
  23431. */
  23432. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23433. private static _ExtractFrom;
  23434. /**
  23435. * Creates the VertexData for a Ribbon
  23436. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23437. * * pathArray array of paths, each of which an array of successive Vector3
  23438. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23439. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23440. * * 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
  23441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23442. * * 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)
  23443. * * 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)
  23444. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23445. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23446. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23447. * @returns the VertexData of the ribbon
  23448. */
  23449. static CreateRibbon(options: {
  23450. pathArray: Vector3[][];
  23451. closeArray?: boolean;
  23452. closePath?: boolean;
  23453. offset?: number;
  23454. sideOrientation?: number;
  23455. frontUVs?: Vector4;
  23456. backUVs?: Vector4;
  23457. invertUV?: boolean;
  23458. uvs?: Vector2[];
  23459. colors?: Color4[];
  23460. }): VertexData;
  23461. /**
  23462. * Creates the VertexData for a box
  23463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23464. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23465. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23466. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23467. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23468. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23469. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23471. * * 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)
  23472. * * 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)
  23473. * @returns the VertexData of the box
  23474. */
  23475. static CreateBox(options: {
  23476. size?: number;
  23477. width?: number;
  23478. height?: number;
  23479. depth?: number;
  23480. faceUV?: Vector4[];
  23481. faceColors?: Color4[];
  23482. sideOrientation?: number;
  23483. frontUVs?: Vector4;
  23484. backUVs?: Vector4;
  23485. }): VertexData;
  23486. /**
  23487. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23489. * * segments sets the number of horizontal strips optional, default 32
  23490. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23491. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23492. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23493. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23494. * * 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
  23495. * * 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
  23496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23497. * * 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)
  23498. * * 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)
  23499. * @returns the VertexData of the ellipsoid
  23500. */
  23501. static CreateSphere(options: {
  23502. segments?: number;
  23503. diameter?: number;
  23504. diameterX?: number;
  23505. diameterY?: number;
  23506. diameterZ?: number;
  23507. arc?: number;
  23508. slice?: number;
  23509. sideOrientation?: number;
  23510. frontUVs?: Vector4;
  23511. backUVs?: Vector4;
  23512. }): VertexData;
  23513. /**
  23514. * Creates the VertexData for a cylinder, cone or prism
  23515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23516. * * height sets the height (y direction) of the cylinder, optional, default 2
  23517. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23518. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23519. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23520. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23521. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23522. * * 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
  23523. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23524. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23525. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23526. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23528. * * 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)
  23529. * * 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)
  23530. * @returns the VertexData of the cylinder, cone or prism
  23531. */
  23532. static CreateCylinder(options: {
  23533. height?: number;
  23534. diameterTop?: number;
  23535. diameterBottom?: number;
  23536. diameter?: number;
  23537. tessellation?: number;
  23538. subdivisions?: number;
  23539. arc?: number;
  23540. faceColors?: Color4[];
  23541. faceUV?: Vector4[];
  23542. hasRings?: boolean;
  23543. enclose?: boolean;
  23544. sideOrientation?: number;
  23545. frontUVs?: Vector4;
  23546. backUVs?: Vector4;
  23547. }): VertexData;
  23548. /**
  23549. * Creates the VertexData for a torus
  23550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23551. * * diameter the diameter of the torus, optional default 1
  23552. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23553. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23555. * * 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)
  23556. * * 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)
  23557. * @returns the VertexData of the torus
  23558. */
  23559. static CreateTorus(options: {
  23560. diameter?: number;
  23561. thickness?: number;
  23562. tessellation?: number;
  23563. sideOrientation?: number;
  23564. frontUVs?: Vector4;
  23565. backUVs?: Vector4;
  23566. }): VertexData;
  23567. /**
  23568. * Creates the VertexData of the LineSystem
  23569. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23570. * - lines an array of lines, each line being an array of successive Vector3
  23571. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23572. * @returns the VertexData of the LineSystem
  23573. */
  23574. static CreateLineSystem(options: {
  23575. lines: Vector3[][];
  23576. colors?: Nullable<Color4[][]>;
  23577. }): VertexData;
  23578. /**
  23579. * Create the VertexData for a DashedLines
  23580. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23581. * - points an array successive Vector3
  23582. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23583. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23584. * - dashNb the intended total number of dashes, optional, default 200
  23585. * @returns the VertexData for the DashedLines
  23586. */
  23587. static CreateDashedLines(options: {
  23588. points: Vector3[];
  23589. dashSize?: number;
  23590. gapSize?: number;
  23591. dashNb?: number;
  23592. }): VertexData;
  23593. /**
  23594. * Creates the VertexData for a Ground
  23595. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23596. * - width the width (x direction) of the ground, optional, default 1
  23597. * - height the height (z direction) of the ground, optional, default 1
  23598. * - subdivisions the number of subdivisions per side, optional, default 1
  23599. * @returns the VertexData of the Ground
  23600. */
  23601. static CreateGround(options: {
  23602. width?: number;
  23603. height?: number;
  23604. subdivisions?: number;
  23605. subdivisionsX?: number;
  23606. subdivisionsY?: number;
  23607. }): VertexData;
  23608. /**
  23609. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23610. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23611. * * xmin the ground minimum X coordinate, optional, default -1
  23612. * * zmin the ground minimum Z coordinate, optional, default -1
  23613. * * xmax the ground maximum X coordinate, optional, default 1
  23614. * * zmax the ground maximum Z coordinate, optional, default 1
  23615. * * 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}
  23616. * * 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}
  23617. * @returns the VertexData of the TiledGround
  23618. */
  23619. static CreateTiledGround(options: {
  23620. xmin: number;
  23621. zmin: number;
  23622. xmax: number;
  23623. zmax: number;
  23624. subdivisions?: {
  23625. w: number;
  23626. h: number;
  23627. };
  23628. precision?: {
  23629. w: number;
  23630. h: number;
  23631. };
  23632. }): VertexData;
  23633. /**
  23634. * Creates the VertexData of the Ground designed from a heightmap
  23635. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23636. * * width the width (x direction) of the ground
  23637. * * height the height (z direction) of the ground
  23638. * * subdivisions the number of subdivisions per side
  23639. * * minHeight the minimum altitude on the ground, optional, default 0
  23640. * * maxHeight the maximum altitude on the ground, optional default 1
  23641. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23642. * * buffer the array holding the image color data
  23643. * * bufferWidth the width of image
  23644. * * bufferHeight the height of image
  23645. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23646. * @returns the VertexData of the Ground designed from a heightmap
  23647. */
  23648. static CreateGroundFromHeightMap(options: {
  23649. width: number;
  23650. height: number;
  23651. subdivisions: number;
  23652. minHeight: number;
  23653. maxHeight: number;
  23654. colorFilter: Color3;
  23655. buffer: Uint8Array;
  23656. bufferWidth: number;
  23657. bufferHeight: number;
  23658. alphaFilter: number;
  23659. }): VertexData;
  23660. /**
  23661. * Creates the VertexData for a Plane
  23662. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23663. * * size sets the width and height of the plane to the value of size, optional default 1
  23664. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23665. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23667. * * 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)
  23668. * * 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)
  23669. * @returns the VertexData of the box
  23670. */
  23671. static CreatePlane(options: {
  23672. size?: number;
  23673. width?: number;
  23674. height?: number;
  23675. sideOrientation?: number;
  23676. frontUVs?: Vector4;
  23677. backUVs?: Vector4;
  23678. }): VertexData;
  23679. /**
  23680. * Creates the VertexData of the Disc or regular Polygon
  23681. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23682. * * radius the radius of the disc, optional default 0.5
  23683. * * tessellation the number of polygon sides, optional, default 64
  23684. * * 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
  23685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23686. * * 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)
  23687. * * 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)
  23688. * @returns the VertexData of the box
  23689. */
  23690. static CreateDisc(options: {
  23691. radius?: number;
  23692. tessellation?: number;
  23693. arc?: number;
  23694. sideOrientation?: number;
  23695. frontUVs?: Vector4;
  23696. backUVs?: Vector4;
  23697. }): VertexData;
  23698. /**
  23699. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23700. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23701. * @param polygon a mesh built from polygonTriangulation.build()
  23702. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23703. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23704. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23705. * @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)
  23706. * @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)
  23707. * @returns the VertexData of the Polygon
  23708. */
  23709. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23710. /**
  23711. * Creates the VertexData of the IcoSphere
  23712. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23713. * * radius the radius of the IcoSphere, optional default 1
  23714. * * radiusX allows stretching in the x direction, optional, default radius
  23715. * * radiusY allows stretching in the y direction, optional, default radius
  23716. * * radiusZ allows stretching in the z direction, optional, default radius
  23717. * * flat when true creates a flat shaded mesh, optional, default true
  23718. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23720. * * 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)
  23721. * * 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)
  23722. * @returns the VertexData of the IcoSphere
  23723. */
  23724. static CreateIcoSphere(options: {
  23725. radius?: number;
  23726. radiusX?: number;
  23727. radiusY?: number;
  23728. radiusZ?: number;
  23729. flat?: boolean;
  23730. subdivisions?: number;
  23731. sideOrientation?: number;
  23732. frontUVs?: Vector4;
  23733. backUVs?: Vector4;
  23734. }): VertexData;
  23735. /**
  23736. * Creates the VertexData for a Polyhedron
  23737. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23738. * * type provided types are:
  23739. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23740. * * 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)
  23741. * * size the size of the IcoSphere, optional default 1
  23742. * * sizeX allows stretching in the x direction, optional, default size
  23743. * * sizeY allows stretching in the y direction, optional, default size
  23744. * * sizeZ allows stretching in the z direction, optional, default size
  23745. * * 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
  23746. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23747. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23748. * * flat when true creates a flat shaded mesh, optional, default true
  23749. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23750. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23751. * * 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)
  23752. * * 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)
  23753. * @returns the VertexData of the Polyhedron
  23754. */
  23755. static CreatePolyhedron(options: {
  23756. type?: number;
  23757. size?: number;
  23758. sizeX?: number;
  23759. sizeY?: number;
  23760. sizeZ?: number;
  23761. custom?: any;
  23762. faceUV?: Vector4[];
  23763. faceColors?: Color4[];
  23764. flat?: boolean;
  23765. sideOrientation?: number;
  23766. frontUVs?: Vector4;
  23767. backUVs?: Vector4;
  23768. }): VertexData;
  23769. /**
  23770. * Creates the VertexData for a TorusKnot
  23771. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23772. * * radius the radius of the torus knot, optional, default 2
  23773. * * tube the thickness of the tube, optional, default 0.5
  23774. * * radialSegments the number of sides on each tube segments, optional, default 32
  23775. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23776. * * p the number of windings around the z axis, optional, default 2
  23777. * * q the number of windings around the x axis, optional, default 3
  23778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23779. * * 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)
  23780. * * 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)
  23781. * @returns the VertexData of the Torus Knot
  23782. */
  23783. static CreateTorusKnot(options: {
  23784. radius?: number;
  23785. tube?: number;
  23786. radialSegments?: number;
  23787. tubularSegments?: number;
  23788. p?: number;
  23789. q?: number;
  23790. sideOrientation?: number;
  23791. frontUVs?: Vector4;
  23792. backUVs?: Vector4;
  23793. }): VertexData;
  23794. /**
  23795. * Compute normals for given positions and indices
  23796. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23797. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23798. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23799. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23800. * * facetNormals : optional array of facet normals (vector3)
  23801. * * facetPositions : optional array of facet positions (vector3)
  23802. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23803. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23804. * * bInfo : optional bounding info, required for facetPartitioning computation
  23805. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23806. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23807. * * useRightHandedSystem: optional boolean to for right handed system computation
  23808. * * depthSort : optional boolean to enable the facet depth sort computation
  23809. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23810. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23811. */
  23812. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23813. facetNormals?: any;
  23814. facetPositions?: any;
  23815. facetPartitioning?: any;
  23816. ratio?: number;
  23817. bInfo?: any;
  23818. bbSize?: Vector3;
  23819. subDiv?: any;
  23820. useRightHandedSystem?: boolean;
  23821. depthSort?: boolean;
  23822. distanceTo?: Vector3;
  23823. depthSortedFacets?: any;
  23824. }): void;
  23825. /** @hidden */
  23826. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23827. /**
  23828. * Applies VertexData created from the imported parameters to the geometry
  23829. * @param parsedVertexData the parsed data from an imported file
  23830. * @param geometry the geometry to apply the VertexData to
  23831. */
  23832. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23833. }
  23834. }
  23835. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23836. import { Nullable } from "babylonjs/types";
  23837. import { Scene } from "babylonjs/scene";
  23838. import { Vector4 } from "babylonjs/Maths/math";
  23839. import { Mesh } from "babylonjs/Meshes/mesh";
  23840. /**
  23841. * Class containing static functions to help procedurally build meshes
  23842. */
  23843. export class DiscBuilder {
  23844. /**
  23845. * Creates a plane polygonal mesh. By default, this is a disc
  23846. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23847. * * 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
  23848. * * 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
  23849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23852. * @param name defines the name of the mesh
  23853. * @param options defines the options used to create the mesh
  23854. * @param scene defines the hosting scene
  23855. * @returns the plane polygonal mesh
  23856. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23857. */
  23858. static CreateDisc(name: string, options: {
  23859. radius?: number;
  23860. tessellation?: number;
  23861. arc?: number;
  23862. updatable?: boolean;
  23863. sideOrientation?: number;
  23864. frontUVs?: Vector4;
  23865. backUVs?: Vector4;
  23866. }, scene?: Nullable<Scene>): Mesh;
  23867. }
  23868. }
  23869. declare module "babylonjs/Particles/solidParticleSystem" {
  23870. import { Vector3 } from "babylonjs/Maths/math";
  23871. import { Mesh } from "babylonjs/Meshes/mesh";
  23872. import { Scene, IDisposable } from "babylonjs/scene";
  23873. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23874. /**
  23875. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23876. *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.
  23877. * The SPS is also a particle system. It provides some methods to manage the particles.
  23878. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23879. *
  23880. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23881. */
  23882. export class SolidParticleSystem implements IDisposable {
  23883. /**
  23884. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23885. * Example : var p = SPS.particles[i];
  23886. */
  23887. particles: SolidParticle[];
  23888. /**
  23889. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23890. */
  23891. nbParticles: number;
  23892. /**
  23893. * If the particles must ever face the camera (default false). Useful for planar particles.
  23894. */
  23895. billboard: boolean;
  23896. /**
  23897. * Recompute normals when adding a shape
  23898. */
  23899. recomputeNormals: boolean;
  23900. /**
  23901. * This a counter ofr your own usage. It's not set by any SPS functions.
  23902. */
  23903. counter: number;
  23904. /**
  23905. * The SPS name. This name is also given to the underlying mesh.
  23906. */
  23907. name: string;
  23908. /**
  23909. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23910. */
  23911. mesh: Mesh;
  23912. /**
  23913. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23914. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23915. */
  23916. vars: any;
  23917. /**
  23918. * This array is populated when the SPS is set as 'pickable'.
  23919. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23920. * Each element of this array is an object `{idx: int, faceId: int}`.
  23921. * `idx` is the picked particle index in the `SPS.particles` array
  23922. * `faceId` is the picked face index counted within this particle.
  23923. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23924. */
  23925. pickedParticles: {
  23926. idx: number;
  23927. faceId: number;
  23928. }[];
  23929. /**
  23930. * This array is populated when `enableDepthSort` is set to true.
  23931. * Each element of this array is an instance of the class DepthSortedParticle.
  23932. */
  23933. depthSortedParticles: DepthSortedParticle[];
  23934. /**
  23935. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23936. * @hidden
  23937. */
  23938. _bSphereOnly: boolean;
  23939. /**
  23940. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23941. * @hidden
  23942. */
  23943. _bSphereRadiusFactor: number;
  23944. private _scene;
  23945. private _positions;
  23946. private _indices;
  23947. private _normals;
  23948. private _colors;
  23949. private _uvs;
  23950. private _indices32;
  23951. private _positions32;
  23952. private _normals32;
  23953. private _fixedNormal32;
  23954. private _colors32;
  23955. private _uvs32;
  23956. private _index;
  23957. private _updatable;
  23958. private _pickable;
  23959. private _isVisibilityBoxLocked;
  23960. private _alwaysVisible;
  23961. private _depthSort;
  23962. private _shapeCounter;
  23963. private _copy;
  23964. private _color;
  23965. private _computeParticleColor;
  23966. private _computeParticleTexture;
  23967. private _computeParticleRotation;
  23968. private _computeParticleVertex;
  23969. private _computeBoundingBox;
  23970. private _depthSortParticles;
  23971. private _camera;
  23972. private _mustUnrotateFixedNormals;
  23973. private _particlesIntersect;
  23974. private _needs32Bits;
  23975. /**
  23976. * Creates a SPS (Solid Particle System) object.
  23977. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23978. * @param scene (Scene) is the scene in which the SPS is added.
  23979. * @param options defines the options of the sps e.g.
  23980. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23981. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23982. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23983. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23984. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23985. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23986. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23987. */
  23988. constructor(name: string, scene: Scene, options?: {
  23989. updatable?: boolean;
  23990. isPickable?: boolean;
  23991. enableDepthSort?: boolean;
  23992. particleIntersection?: boolean;
  23993. boundingSphereOnly?: boolean;
  23994. bSphereRadiusFactor?: number;
  23995. });
  23996. /**
  23997. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23998. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23999. * @returns the created mesh
  24000. */
  24001. buildMesh(): Mesh;
  24002. /**
  24003. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24004. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24005. * Thus the particles generated from `digest()` have their property `position` set yet.
  24006. * @param mesh ( Mesh ) is the mesh to be digested
  24007. * @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
  24008. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24009. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24010. * @returns the current SPS
  24011. */
  24012. digest(mesh: Mesh, options?: {
  24013. facetNb?: number;
  24014. number?: number;
  24015. delta?: number;
  24016. }): SolidParticleSystem;
  24017. private _unrotateFixedNormals;
  24018. private _resetCopy;
  24019. private _meshBuilder;
  24020. private _posToShape;
  24021. private _uvsToShapeUV;
  24022. private _addParticle;
  24023. /**
  24024. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24025. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24026. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24027. * @param nb (positive integer) the number of particles to be created from this model
  24028. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24029. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24030. * @returns the number of shapes in the system
  24031. */
  24032. addShape(mesh: Mesh, nb: number, options?: {
  24033. positionFunction?: any;
  24034. vertexFunction?: any;
  24035. }): number;
  24036. private _rebuildParticle;
  24037. /**
  24038. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24039. * @returns the SPS.
  24040. */
  24041. rebuildMesh(): SolidParticleSystem;
  24042. /**
  24043. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24044. * This method calls `updateParticle()` for each particle of the SPS.
  24045. * For an animated SPS, it is usually called within the render loop.
  24046. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24047. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24048. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24049. * @returns the SPS.
  24050. */
  24051. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24052. /**
  24053. * Disposes the SPS.
  24054. */
  24055. dispose(): void;
  24056. /**
  24057. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24058. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24059. * @returns the SPS.
  24060. */
  24061. refreshVisibleSize(): SolidParticleSystem;
  24062. /**
  24063. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24064. * @param size the size (float) of the visibility box
  24065. * note : this doesn't lock the SPS mesh bounding box.
  24066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24067. */
  24068. setVisibilityBox(size: number): void;
  24069. /**
  24070. * Gets whether the SPS as always visible or not
  24071. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24072. */
  24073. /**
  24074. * Sets the SPS as always visible or not
  24075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24076. */
  24077. isAlwaysVisible: boolean;
  24078. /**
  24079. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24081. */
  24082. /**
  24083. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24084. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24085. */
  24086. isVisibilityBoxLocked: boolean;
  24087. /**
  24088. * Tells to `setParticles()` to compute the particle rotations or not.
  24089. * Default value : true. The SPS is faster when it's set to false.
  24090. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24091. */
  24092. /**
  24093. * Gets if `setParticles()` computes the particle rotations or not.
  24094. * Default value : true. The SPS is faster when it's set to false.
  24095. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24096. */
  24097. computeParticleRotation: boolean;
  24098. /**
  24099. * Tells to `setParticles()` to compute the particle colors or not.
  24100. * Default value : true. The SPS is faster when it's set to false.
  24101. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24102. */
  24103. /**
  24104. * Gets if `setParticles()` computes the particle colors or not.
  24105. * Default value : true. The SPS is faster when it's set to false.
  24106. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24107. */
  24108. computeParticleColor: boolean;
  24109. /**
  24110. * Gets if `setParticles()` computes the particle textures or not.
  24111. * Default value : true. The SPS is faster when it's set to false.
  24112. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24113. */
  24114. computeParticleTexture: boolean;
  24115. /**
  24116. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24117. * Default value : false. The SPS is faster when it's set to false.
  24118. * Note : the particle custom vertex positions aren't stored values.
  24119. */
  24120. /**
  24121. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24122. * Default value : false. The SPS is faster when it's set to false.
  24123. * Note : the particle custom vertex positions aren't stored values.
  24124. */
  24125. computeParticleVertex: boolean;
  24126. /**
  24127. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24128. */
  24129. /**
  24130. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24131. */
  24132. computeBoundingBox: boolean;
  24133. /**
  24134. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24135. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24136. * Default : `true`
  24137. */
  24138. /**
  24139. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24140. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24141. * Default : `true`
  24142. */
  24143. depthSortParticles: boolean;
  24144. /**
  24145. * This function does nothing. It may be overwritten to set all the particle first values.
  24146. * The SPS doesn't call this function, you may have to call it by your own.
  24147. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24148. */
  24149. initParticles(): void;
  24150. /**
  24151. * This function does nothing. It may be overwritten to recycle a particle.
  24152. * The SPS doesn't call this function, you may have to call it by your own.
  24153. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24154. * @param particle The particle to recycle
  24155. * @returns the recycled particle
  24156. */
  24157. recycleParticle(particle: SolidParticle): SolidParticle;
  24158. /**
  24159. * Updates a particle : this function should be overwritten by the user.
  24160. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24161. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24162. * @example : just set a particle position or velocity and recycle conditions
  24163. * @param particle The particle to update
  24164. * @returns the updated particle
  24165. */
  24166. updateParticle(particle: SolidParticle): SolidParticle;
  24167. /**
  24168. * Updates a vertex of a particle : it can be overwritten by the user.
  24169. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24170. * @param particle the current particle
  24171. * @param vertex the current index of the current particle
  24172. * @param pt the index of the current vertex in the particle shape
  24173. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24174. * @example : just set a vertex particle position
  24175. * @returns the updated vertex
  24176. */
  24177. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24178. /**
  24179. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24180. * This does nothing and may be overwritten by the user.
  24181. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24182. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24183. * @param update the boolean update value actually passed to setParticles()
  24184. */
  24185. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24186. /**
  24187. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24188. * This will be passed three parameters.
  24189. * This does nothing and may be overwritten by the user.
  24190. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24191. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24192. * @param update the boolean update value actually passed to setParticles()
  24193. */
  24194. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24195. }
  24196. }
  24197. declare module "babylonjs/Particles/solidParticle" {
  24198. import { Nullable } from "babylonjs/types";
  24199. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24200. import { Mesh } from "babylonjs/Meshes/mesh";
  24201. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24202. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24203. /**
  24204. * Represents one particle of a solid particle system.
  24205. */
  24206. export class SolidParticle {
  24207. /**
  24208. * particle global index
  24209. */
  24210. idx: number;
  24211. /**
  24212. * The color of the particle
  24213. */
  24214. color: Nullable<Color4>;
  24215. /**
  24216. * The world space position of the particle.
  24217. */
  24218. position: Vector3;
  24219. /**
  24220. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24221. */
  24222. rotation: Vector3;
  24223. /**
  24224. * The world space rotation quaternion of the particle.
  24225. */
  24226. rotationQuaternion: Nullable<Quaternion>;
  24227. /**
  24228. * The scaling of the particle.
  24229. */
  24230. scaling: Vector3;
  24231. /**
  24232. * The uvs of the particle.
  24233. */
  24234. uvs: Vector4;
  24235. /**
  24236. * The current speed of the particle.
  24237. */
  24238. velocity: Vector3;
  24239. /**
  24240. * The pivot point in the particle local space.
  24241. */
  24242. pivot: Vector3;
  24243. /**
  24244. * Must the particle be translated from its pivot point in its local space ?
  24245. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24246. * Default : false
  24247. */
  24248. translateFromPivot: boolean;
  24249. /**
  24250. * Is the particle active or not ?
  24251. */
  24252. alive: boolean;
  24253. /**
  24254. * Is the particle visible or not ?
  24255. */
  24256. isVisible: boolean;
  24257. /**
  24258. * Index of this particle in the global "positions" array (Internal use)
  24259. * @hidden
  24260. */
  24261. _pos: number;
  24262. /**
  24263. * @hidden Index of this particle in the global "indices" array (Internal use)
  24264. */
  24265. _ind: number;
  24266. /**
  24267. * @hidden ModelShape of this particle (Internal use)
  24268. */
  24269. _model: ModelShape;
  24270. /**
  24271. * ModelShape id of this particle
  24272. */
  24273. shapeId: number;
  24274. /**
  24275. * Index of the particle in its shape id (Internal use)
  24276. */
  24277. idxInShape: number;
  24278. /**
  24279. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24280. */
  24281. _modelBoundingInfo: BoundingInfo;
  24282. /**
  24283. * @hidden Particle BoundingInfo object (Internal use)
  24284. */
  24285. _boundingInfo: BoundingInfo;
  24286. /**
  24287. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24288. */
  24289. _sps: SolidParticleSystem;
  24290. /**
  24291. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24292. */
  24293. _stillInvisible: boolean;
  24294. /**
  24295. * @hidden Last computed particle rotation matrix
  24296. */
  24297. _rotationMatrix: number[];
  24298. /**
  24299. * Parent particle Id, if any.
  24300. * Default null.
  24301. */
  24302. parentId: Nullable<number>;
  24303. /**
  24304. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24305. * The possible values are :
  24306. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24307. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24308. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24310. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24311. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24312. * */
  24313. cullingStrategy: number;
  24314. /**
  24315. * @hidden Internal global position in the SPS.
  24316. */
  24317. _globalPosition: Vector3;
  24318. /**
  24319. * Creates a Solid Particle object.
  24320. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24321. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24322. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24323. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24324. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24325. * @param shapeId (integer) is the model shape identifier in the SPS.
  24326. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24327. * @param sps defines the sps it is associated to
  24328. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24329. */
  24330. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24331. /**
  24332. * Legacy support, changed scale to scaling
  24333. */
  24334. /**
  24335. * Legacy support, changed scale to scaling
  24336. */
  24337. scale: Vector3;
  24338. /**
  24339. * Legacy support, changed quaternion to rotationQuaternion
  24340. */
  24341. /**
  24342. * Legacy support, changed quaternion to rotationQuaternion
  24343. */
  24344. quaternion: Nullable<Quaternion>;
  24345. /**
  24346. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24347. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24348. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24349. * @returns true if it intersects
  24350. */
  24351. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24352. /**
  24353. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24354. * A particle is in the frustum if its bounding box intersects the frustum
  24355. * @param frustumPlanes defines the frustum to test
  24356. * @returns true if the particle is in the frustum planes
  24357. */
  24358. isInFrustum(frustumPlanes: Plane[]): boolean;
  24359. /**
  24360. * get the rotation matrix of the particle
  24361. * @hidden
  24362. */
  24363. getRotationMatrix(m: Matrix): void;
  24364. }
  24365. /**
  24366. * Represents the shape of the model used by one particle of a solid particle system.
  24367. * SPS internal tool, don't use it manually.
  24368. */
  24369. export class ModelShape {
  24370. /**
  24371. * The shape id
  24372. * @hidden
  24373. */
  24374. shapeID: number;
  24375. /**
  24376. * flat array of model positions (internal use)
  24377. * @hidden
  24378. */
  24379. _shape: Vector3[];
  24380. /**
  24381. * flat array of model UVs (internal use)
  24382. * @hidden
  24383. */
  24384. _shapeUV: number[];
  24385. /**
  24386. * length of the shape in the model indices array (internal use)
  24387. * @hidden
  24388. */
  24389. _indicesLength: number;
  24390. /**
  24391. * Custom position function (internal use)
  24392. * @hidden
  24393. */
  24394. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24395. /**
  24396. * Custom vertex function (internal use)
  24397. * @hidden
  24398. */
  24399. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24400. /**
  24401. * 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.
  24402. * SPS internal tool, don't use it manually.
  24403. * @hidden
  24404. */
  24405. 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>);
  24406. }
  24407. /**
  24408. * Represents a Depth Sorted Particle in the solid particle system.
  24409. */
  24410. export class DepthSortedParticle {
  24411. /**
  24412. * Index of the particle in the "indices" array
  24413. */
  24414. ind: number;
  24415. /**
  24416. * Length of the particle shape in the "indices" array
  24417. */
  24418. indicesLength: number;
  24419. /**
  24420. * Squared distance from the particle to the camera
  24421. */
  24422. sqDistance: number;
  24423. }
  24424. }
  24425. declare module "babylonjs/Meshes/abstractMesh" {
  24426. import { Observable } from "babylonjs/Misc/observable";
  24427. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24428. import { Camera } from "babylonjs/Cameras/camera";
  24429. import { Scene, IDisposable } from "babylonjs/scene";
  24430. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24431. import { Node } from "babylonjs/node";
  24432. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24435. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24436. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24437. import { Material } from "babylonjs/Materials/material";
  24438. import { Light } from "babylonjs/Lights/light";
  24439. import { Skeleton } from "babylonjs/Bones/skeleton";
  24440. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24441. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24442. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24443. import { Ray } from "babylonjs/Culling/ray";
  24444. import { Collider } from "babylonjs/Collisions/collider";
  24445. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24446. /**
  24447. * Class used to store all common mesh properties
  24448. */
  24449. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24450. /** No occlusion */
  24451. static OCCLUSION_TYPE_NONE: number;
  24452. /** Occlusion set to optimisitic */
  24453. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24454. /** Occlusion set to strict */
  24455. static OCCLUSION_TYPE_STRICT: number;
  24456. /** Use an accurante occlusion algorithm */
  24457. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24458. /** Use a conservative occlusion algorithm */
  24459. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24461. * Test order :
  24462. * Is the bounding sphere outside the frustum ?
  24463. * If not, are the bounding box vertices outside the frustum ?
  24464. * It not, then the cullable object is in the frustum.
  24465. */
  24466. static readonly CULLINGSTRATEGY_STANDARD: number;
  24467. /** Culling strategy : Bounding Sphere Only.
  24468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24469. * It's also less accurate than the standard because some not visible objects can still be selected.
  24470. * Test : is the bounding sphere outside the frustum ?
  24471. * If not, then the cullable object is in the frustum.
  24472. */
  24473. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24474. /** Culling strategy : Optimistic Inclusion.
  24475. * This in an inclusion test first, then the standard exclusion test.
  24476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24477. * 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.
  24478. * Anyway, it's as accurate as the standard strategy.
  24479. * Test :
  24480. * Is the cullable object bounding sphere center in the frustum ?
  24481. * If not, apply the default culling strategy.
  24482. */
  24483. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24487. * 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.
  24488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24489. * Test :
  24490. * Is the cullable object bounding sphere center in the frustum ?
  24491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24492. */
  24493. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24494. /**
  24495. * No billboard
  24496. */
  24497. static readonly BILLBOARDMODE_NONE: number;
  24498. /** Billboard on X axis */
  24499. static readonly BILLBOARDMODE_X: number;
  24500. /** Billboard on Y axis */
  24501. static readonly BILLBOARDMODE_Y: number;
  24502. /** Billboard on Z axis */
  24503. static readonly BILLBOARDMODE_Z: number;
  24504. /** Billboard on all axes */
  24505. static readonly BILLBOARDMODE_ALL: number;
  24506. private _facetData;
  24507. /**
  24508. * The culling strategy to use to check whether the mesh must be rendered or not.
  24509. * This value can be changed at any time and will be used on the next render mesh selection.
  24510. * The possible values are :
  24511. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24512. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24513. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24514. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24515. * Please read each static variable documentation to get details about the culling process.
  24516. * */
  24517. cullingStrategy: number;
  24518. /**
  24519. * Gets the number of facets in the mesh
  24520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24521. */
  24522. readonly facetNb: number;
  24523. /**
  24524. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24526. */
  24527. partitioningSubdivisions: number;
  24528. /**
  24529. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24530. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24532. */
  24533. partitioningBBoxRatio: number;
  24534. /**
  24535. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24536. * Works only for updatable meshes.
  24537. * Doesn't work with multi-materials
  24538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24539. */
  24540. mustDepthSortFacets: boolean;
  24541. /**
  24542. * The location (Vector3) where the facet depth sort must be computed from.
  24543. * By default, the active camera position.
  24544. * Used only when facet depth sort is enabled
  24545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24546. */
  24547. facetDepthSortFrom: Vector3;
  24548. /**
  24549. * gets a boolean indicating if facetData is enabled
  24550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24551. */
  24552. readonly isFacetDataEnabled: boolean;
  24553. /** @hidden */
  24554. _updateNonUniformScalingState(value: boolean): boolean;
  24555. /**
  24556. * An event triggered when this mesh collides with another one
  24557. */
  24558. onCollideObservable: Observable<AbstractMesh>;
  24559. private _onCollideObserver;
  24560. /** Set a function to call when this mesh collides with another one */
  24561. onCollide: () => void;
  24562. /**
  24563. * An event triggered when the collision's position changes
  24564. */
  24565. onCollisionPositionChangeObservable: Observable<Vector3>;
  24566. private _onCollisionPositionChangeObserver;
  24567. /** Set a function to call when the collision's position changes */
  24568. onCollisionPositionChange: () => void;
  24569. /**
  24570. * An event triggered when material is changed
  24571. */
  24572. onMaterialChangedObservable: Observable<AbstractMesh>;
  24573. /**
  24574. * Gets or sets the orientation for POV movement & rotation
  24575. */
  24576. definedFacingForward: boolean;
  24577. /** @hidden */
  24578. _occlusionQuery: Nullable<WebGLQuery>;
  24579. private _visibility;
  24580. /**
  24581. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24582. */
  24583. /**
  24584. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24585. */
  24586. visibility: number;
  24587. /** Gets or sets the alpha index used to sort transparent meshes
  24588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24589. */
  24590. alphaIndex: number;
  24591. /**
  24592. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24593. */
  24594. isVisible: boolean;
  24595. /**
  24596. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24597. */
  24598. isPickable: boolean;
  24599. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24600. showSubMeshesBoundingBox: boolean;
  24601. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24602. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24603. */
  24604. isBlocker: boolean;
  24605. /**
  24606. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24607. */
  24608. enablePointerMoveEvents: boolean;
  24609. /**
  24610. * Specifies the rendering group id for this mesh (0 by default)
  24611. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24612. */
  24613. renderingGroupId: number;
  24614. private _material;
  24615. /** Gets or sets current material */
  24616. material: Nullable<Material>;
  24617. private _receiveShadows;
  24618. /**
  24619. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24620. * @see http://doc.babylonjs.com/babylon101/shadows
  24621. */
  24622. receiveShadows: boolean;
  24623. /** Defines color to use when rendering outline */
  24624. outlineColor: Color3;
  24625. /** Define width to use when rendering outline */
  24626. outlineWidth: number;
  24627. /** Defines color to use when rendering overlay */
  24628. overlayColor: Color3;
  24629. /** Defines alpha to use when rendering overlay */
  24630. overlayAlpha: number;
  24631. private _hasVertexAlpha;
  24632. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24633. hasVertexAlpha: boolean;
  24634. private _useVertexColors;
  24635. /** 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) */
  24636. useVertexColors: boolean;
  24637. private _computeBonesUsingShaders;
  24638. /**
  24639. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24640. */
  24641. computeBonesUsingShaders: boolean;
  24642. private _numBoneInfluencers;
  24643. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24644. numBoneInfluencers: number;
  24645. private _applyFog;
  24646. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24647. applyFog: boolean;
  24648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24649. useOctreeForRenderingSelection: boolean;
  24650. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24651. useOctreeForPicking: boolean;
  24652. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24653. useOctreeForCollisions: boolean;
  24654. private _layerMask;
  24655. /**
  24656. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24657. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24658. */
  24659. layerMask: number;
  24660. /**
  24661. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24662. */
  24663. alwaysSelectAsActiveMesh: boolean;
  24664. /**
  24665. * Gets or sets the current action manager
  24666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24667. */
  24668. actionManager: Nullable<AbstractActionManager>;
  24669. private _checkCollisions;
  24670. private _collisionMask;
  24671. private _collisionGroup;
  24672. /**
  24673. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24675. */
  24676. ellipsoid: Vector3;
  24677. /**
  24678. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24680. */
  24681. ellipsoidOffset: Vector3;
  24682. private _collider;
  24683. private _oldPositionForCollisions;
  24684. private _diffPositionForCollisions;
  24685. /**
  24686. * Gets or sets a collision mask used to mask collisions (default is -1).
  24687. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24688. */
  24689. collisionMask: number;
  24690. /**
  24691. * Gets or sets the current collision group mask (-1 by default).
  24692. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24693. */
  24694. collisionGroup: number;
  24695. /**
  24696. * Defines edge width used when edgesRenderer is enabled
  24697. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24698. */
  24699. edgesWidth: number;
  24700. /**
  24701. * Defines edge color used when edgesRenderer is enabled
  24702. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24703. */
  24704. edgesColor: Color4;
  24705. /** @hidden */
  24706. _edgesRenderer: Nullable<IEdgesRenderer>;
  24707. /** @hidden */
  24708. _masterMesh: Nullable<AbstractMesh>;
  24709. /** @hidden */
  24710. _boundingInfo: Nullable<BoundingInfo>;
  24711. /** @hidden */
  24712. _renderId: number;
  24713. /**
  24714. * Gets or sets the list of subMeshes
  24715. * @see http://doc.babylonjs.com/how_to/multi_materials
  24716. */
  24717. subMeshes: SubMesh[];
  24718. /** @hidden */
  24719. _intersectionsInProgress: AbstractMesh[];
  24720. /** @hidden */
  24721. _unIndexed: boolean;
  24722. /** @hidden */
  24723. _lightSources: Light[];
  24724. /** @hidden */
  24725. readonly _positions: Nullable<Vector3[]>;
  24726. /** @hidden */
  24727. _waitingActions: any;
  24728. /** @hidden */
  24729. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24730. private _skeleton;
  24731. /** @hidden */
  24732. _bonesTransformMatrices: Nullable<Float32Array>;
  24733. /**
  24734. * Gets or sets a skeleton to apply skining transformations
  24735. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24736. */
  24737. skeleton: Nullable<Skeleton>;
  24738. /**
  24739. * An event triggered when the mesh is rebuilt.
  24740. */
  24741. onRebuildObservable: Observable<AbstractMesh>;
  24742. /**
  24743. * Creates a new AbstractMesh
  24744. * @param name defines the name of the mesh
  24745. * @param scene defines the hosting scene
  24746. */
  24747. constructor(name: string, scene?: Nullable<Scene>);
  24748. /**
  24749. * Returns the string "AbstractMesh"
  24750. * @returns "AbstractMesh"
  24751. */
  24752. getClassName(): string;
  24753. /**
  24754. * Gets a string representation of the current mesh
  24755. * @param fullDetails defines a boolean indicating if full details must be included
  24756. * @returns a string representation of the current mesh
  24757. */
  24758. toString(fullDetails?: boolean): string;
  24759. /** @hidden */
  24760. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24761. /** @hidden */
  24762. _rebuild(): void;
  24763. /** @hidden */
  24764. _resyncLightSources(): void;
  24765. /** @hidden */
  24766. _resyncLighSource(light: Light): void;
  24767. /** @hidden */
  24768. _unBindEffect(): void;
  24769. /** @hidden */
  24770. _removeLightSource(light: Light): void;
  24771. private _markSubMeshesAsDirty;
  24772. /** @hidden */
  24773. _markSubMeshesAsLightDirty(): void;
  24774. /** @hidden */
  24775. _markSubMeshesAsAttributesDirty(): void;
  24776. /** @hidden */
  24777. _markSubMeshesAsMiscDirty(): void;
  24778. /**
  24779. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24780. */
  24781. scaling: Vector3;
  24782. /**
  24783. * Returns true if the mesh is blocked. Implemented by child classes
  24784. */
  24785. readonly isBlocked: boolean;
  24786. /**
  24787. * Returns the mesh itself by default. Implemented by child classes
  24788. * @param camera defines the camera to use to pick the right LOD level
  24789. * @returns the currentAbstractMesh
  24790. */
  24791. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24792. /**
  24793. * Returns 0 by default. Implemented by child classes
  24794. * @returns an integer
  24795. */
  24796. getTotalVertices(): number;
  24797. /**
  24798. * Returns a positive integer : the total number of indices in this mesh geometry.
  24799. * @returns the numner of indices or zero if the mesh has no geometry.
  24800. */
  24801. getTotalIndices(): number;
  24802. /**
  24803. * Returns null by default. Implemented by child classes
  24804. * @returns null
  24805. */
  24806. getIndices(): Nullable<IndicesArray>;
  24807. /**
  24808. * Returns the array of the requested vertex data kind. Implemented by child classes
  24809. * @param kind defines the vertex data kind to use
  24810. * @returns null
  24811. */
  24812. getVerticesData(kind: string): Nullable<FloatArray>;
  24813. /**
  24814. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24815. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24816. * Note that a new underlying VertexBuffer object is created each call.
  24817. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24818. * @param kind defines vertex data kind:
  24819. * * VertexBuffer.PositionKind
  24820. * * VertexBuffer.UVKind
  24821. * * VertexBuffer.UV2Kind
  24822. * * VertexBuffer.UV3Kind
  24823. * * VertexBuffer.UV4Kind
  24824. * * VertexBuffer.UV5Kind
  24825. * * VertexBuffer.UV6Kind
  24826. * * VertexBuffer.ColorKind
  24827. * * VertexBuffer.MatricesIndicesKind
  24828. * * VertexBuffer.MatricesIndicesExtraKind
  24829. * * VertexBuffer.MatricesWeightsKind
  24830. * * VertexBuffer.MatricesWeightsExtraKind
  24831. * @param data defines the data source
  24832. * @param updatable defines if the data must be flagged as updatable (or static)
  24833. * @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
  24834. * @returns the current mesh
  24835. */
  24836. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24837. /**
  24838. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24839. * If the mesh has no geometry, it is simply returned as it is.
  24840. * @param kind defines vertex data kind:
  24841. * * VertexBuffer.PositionKind
  24842. * * VertexBuffer.UVKind
  24843. * * VertexBuffer.UV2Kind
  24844. * * VertexBuffer.UV3Kind
  24845. * * VertexBuffer.UV4Kind
  24846. * * VertexBuffer.UV5Kind
  24847. * * VertexBuffer.UV6Kind
  24848. * * VertexBuffer.ColorKind
  24849. * * VertexBuffer.MatricesIndicesKind
  24850. * * VertexBuffer.MatricesIndicesExtraKind
  24851. * * VertexBuffer.MatricesWeightsKind
  24852. * * VertexBuffer.MatricesWeightsExtraKind
  24853. * @param data defines the data source
  24854. * @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
  24855. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24856. * @returns the current mesh
  24857. */
  24858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24859. /**
  24860. * Sets the mesh indices,
  24861. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24862. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24863. * @param totalVertices Defines the total number of vertices
  24864. * @returns the current mesh
  24865. */
  24866. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24867. /**
  24868. * Gets a boolean indicating if specific vertex data is present
  24869. * @param kind defines the vertex data kind to use
  24870. * @returns true is data kind is present
  24871. */
  24872. isVerticesDataPresent(kind: string): boolean;
  24873. /**
  24874. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24875. * @returns a BoundingInfo
  24876. */
  24877. getBoundingInfo(): BoundingInfo;
  24878. /**
  24879. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24880. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24881. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24882. * @returns the current mesh
  24883. */
  24884. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24885. /**
  24886. * Overwrite the current bounding info
  24887. * @param boundingInfo defines the new bounding info
  24888. * @returns the current mesh
  24889. */
  24890. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24891. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24892. readonly useBones: boolean;
  24893. /** @hidden */
  24894. _preActivate(): void;
  24895. /** @hidden */
  24896. _preActivateForIntermediateRendering(renderId: number): void;
  24897. /** @hidden */
  24898. _activate(renderId: number): void;
  24899. /**
  24900. * Gets the current world matrix
  24901. * @returns a Matrix
  24902. */
  24903. getWorldMatrix(): Matrix;
  24904. /** @hidden */
  24905. _getWorldMatrixDeterminant(): number;
  24906. /**
  24907. * Perform relative position change from the point of view of behind the front of the mesh.
  24908. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24909. * Supports definition of mesh facing forward or backward
  24910. * @param amountRight defines the distance on the right axis
  24911. * @param amountUp defines the distance on the up axis
  24912. * @param amountForward defines the distance on the forward axis
  24913. * @returns the current mesh
  24914. */
  24915. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24916. /**
  24917. * Calculate relative position change from the point of view of behind the front of the mesh.
  24918. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24919. * Supports definition of mesh facing forward or backward
  24920. * @param amountRight defines the distance on the right axis
  24921. * @param amountUp defines the distance on the up axis
  24922. * @param amountForward defines the distance on the forward axis
  24923. * @returns the new displacement vector
  24924. */
  24925. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24926. /**
  24927. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24928. * Supports definition of mesh facing forward or backward
  24929. * @param flipBack defines the flip
  24930. * @param twirlClockwise defines the twirl
  24931. * @param tiltRight defines the tilt
  24932. * @returns the current mesh
  24933. */
  24934. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24935. /**
  24936. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24937. * Supports definition of mesh facing forward or backward.
  24938. * @param flipBack defines the flip
  24939. * @param twirlClockwise defines the twirl
  24940. * @param tiltRight defines the tilt
  24941. * @returns the new rotation vector
  24942. */
  24943. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24944. /**
  24945. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24946. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24947. * @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
  24948. * @returns the new bounding vectors
  24949. */
  24950. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24951. min: Vector3;
  24952. max: Vector3;
  24953. };
  24954. /**
  24955. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24956. * This means the mesh underlying bounding box and sphere are recomputed.
  24957. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24958. * @returns the current mesh
  24959. */
  24960. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24961. /** @hidden */
  24962. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24963. /** @hidden */
  24964. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24965. /** @hidden */
  24966. _updateBoundingInfo(): AbstractMesh;
  24967. /** @hidden */
  24968. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24969. /** @hidden */
  24970. protected _afterComputeWorldMatrix(): void;
  24971. /** @hidden */
  24972. readonly _effectiveMesh: AbstractMesh;
  24973. /**
  24974. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24975. * A mesh is in the frustum if its bounding box intersects the frustum
  24976. * @param frustumPlanes defines the frustum to test
  24977. * @returns true if the mesh is in the frustum planes
  24978. */
  24979. isInFrustum(frustumPlanes: Plane[]): boolean;
  24980. /**
  24981. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24982. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24983. * @param frustumPlanes defines the frustum to test
  24984. * @returns true if the mesh is completely in the frustum planes
  24985. */
  24986. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24987. /**
  24988. * True if the mesh intersects another mesh or a SolidParticle object
  24989. * @param mesh defines a target mesh or SolidParticle to test
  24990. * @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)
  24991. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24992. * @returns true if there is an intersection
  24993. */
  24994. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24995. /**
  24996. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24997. * @param point defines the point to test
  24998. * @returns true if there is an intersection
  24999. */
  25000. intersectsPoint(point: Vector3): boolean;
  25001. /**
  25002. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25003. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25004. */
  25005. checkCollisions: boolean;
  25006. /**
  25007. * Gets Collider object used to compute collisions (not physics)
  25008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25009. */
  25010. readonly collider: Collider;
  25011. /**
  25012. * Move the mesh using collision engine
  25013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25014. * @param displacement defines the requested displacement vector
  25015. * @returns the current mesh
  25016. */
  25017. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25018. private _onCollisionPositionChange;
  25019. /** @hidden */
  25020. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25021. /** @hidden */
  25022. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25023. /** @hidden */
  25024. _checkCollision(collider: Collider): AbstractMesh;
  25025. /** @hidden */
  25026. _generatePointsArray(): boolean;
  25027. /**
  25028. * Checks if the passed Ray intersects with the mesh
  25029. * @param ray defines the ray to use
  25030. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25031. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25032. * @returns the picking info
  25033. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25034. */
  25035. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25036. /**
  25037. * Clones the current mesh
  25038. * @param name defines the mesh name
  25039. * @param newParent defines the new mesh parent
  25040. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25041. * @returns the new mesh
  25042. */
  25043. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25044. /**
  25045. * Disposes all the submeshes of the current meshnp
  25046. * @returns the current mesh
  25047. */
  25048. releaseSubMeshes(): AbstractMesh;
  25049. /**
  25050. * Releases resources associated with this abstract mesh.
  25051. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25052. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25053. */
  25054. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25055. /**
  25056. * Adds the passed mesh as a child to the current mesh
  25057. * @param mesh defines the child mesh
  25058. * @returns the current mesh
  25059. */
  25060. addChild(mesh: AbstractMesh): AbstractMesh;
  25061. /**
  25062. * Removes the passed mesh from the current mesh children list
  25063. * @param mesh defines the child mesh
  25064. * @returns the current mesh
  25065. */
  25066. removeChild(mesh: AbstractMesh): AbstractMesh;
  25067. /** @hidden */
  25068. private _initFacetData;
  25069. /**
  25070. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25071. * This method can be called within the render loop.
  25072. * 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
  25073. * @returns the current mesh
  25074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25075. */
  25076. updateFacetData(): AbstractMesh;
  25077. /**
  25078. * Returns the facetLocalNormals array.
  25079. * The normals are expressed in the mesh local spac
  25080. * @returns an array of Vector3
  25081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25082. */
  25083. getFacetLocalNormals(): Vector3[];
  25084. /**
  25085. * Returns the facetLocalPositions array.
  25086. * The facet positions are expressed in the mesh local space
  25087. * @returns an array of Vector3
  25088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25089. */
  25090. getFacetLocalPositions(): Vector3[];
  25091. /**
  25092. * Returns the facetLocalPartioning array
  25093. * @returns an array of array of numbers
  25094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25095. */
  25096. getFacetLocalPartitioning(): number[][];
  25097. /**
  25098. * Returns the i-th facet position in the world system.
  25099. * This method allocates a new Vector3 per call
  25100. * @param i defines the facet index
  25101. * @returns a new Vector3
  25102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25103. */
  25104. getFacetPosition(i: number): Vector3;
  25105. /**
  25106. * Sets the reference Vector3 with the i-th facet position in the world system
  25107. * @param i defines the facet index
  25108. * @param ref defines the target vector
  25109. * @returns the current mesh
  25110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25111. */
  25112. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25113. /**
  25114. * Returns the i-th facet normal in the world system.
  25115. * This method allocates a new Vector3 per call
  25116. * @param i defines the facet index
  25117. * @returns a new Vector3
  25118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25119. */
  25120. getFacetNormal(i: number): Vector3;
  25121. /**
  25122. * Sets the reference Vector3 with the i-th facet normal in the world system
  25123. * @param i defines the facet index
  25124. * @param ref defines the target vector
  25125. * @returns the current mesh
  25126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25127. */
  25128. getFacetNormalToRef(i: number, ref: Vector3): this;
  25129. /**
  25130. * 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)
  25131. * @param x defines x coordinate
  25132. * @param y defines y coordinate
  25133. * @param z defines z coordinate
  25134. * @returns the array of facet indexes
  25135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25136. */
  25137. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25138. /**
  25139. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25140. * @param projected sets as the (x,y,z) world projection on the facet
  25141. * @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
  25142. * @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
  25143. * @param x defines x coordinate
  25144. * @param y defines y coordinate
  25145. * @param z defines z coordinate
  25146. * @returns the face index if found (or null instead)
  25147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25148. */
  25149. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25150. /**
  25151. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25152. * @param projected sets as the (x,y,z) local projection on the facet
  25153. * @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
  25154. * @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
  25155. * @param x defines x coordinate
  25156. * @param y defines y coordinate
  25157. * @param z defines z coordinate
  25158. * @returns the face index if found (or null instead)
  25159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25160. */
  25161. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25162. /**
  25163. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25164. * @returns the parameters
  25165. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25166. */
  25167. getFacetDataParameters(): any;
  25168. /**
  25169. * Disables the feature FacetData and frees the related memory
  25170. * @returns the current mesh
  25171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25172. */
  25173. disableFacetData(): AbstractMesh;
  25174. /**
  25175. * Updates the AbstractMesh indices array
  25176. * @param indices defines the data source
  25177. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25178. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25179. * @returns the current mesh
  25180. */
  25181. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25182. /**
  25183. * Creates new normals data for the mesh
  25184. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25185. * @returns the current mesh
  25186. */
  25187. createNormals(updatable: boolean): AbstractMesh;
  25188. /**
  25189. * Align the mesh with a normal
  25190. * @param normal defines the normal to use
  25191. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25192. * @returns the current mesh
  25193. */
  25194. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25195. /** @hidden */
  25196. _checkOcclusionQuery(): boolean;
  25197. }
  25198. }
  25199. declare module "babylonjs/Actions/actionEvent" {
  25200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25201. import { Nullable } from "babylonjs/types";
  25202. import { Sprite } from "babylonjs/Sprites/sprite";
  25203. import { Scene } from "babylonjs/scene";
  25204. import { Vector2 } from "babylonjs/Maths/math";
  25205. /**
  25206. * Interface used to define ActionEvent
  25207. */
  25208. export interface IActionEvent {
  25209. /** The mesh or sprite that triggered the action */
  25210. source: any;
  25211. /** The X mouse cursor position at the time of the event */
  25212. pointerX: number;
  25213. /** The Y mouse cursor position at the time of the event */
  25214. pointerY: number;
  25215. /** The mesh that is currently pointed at (can be null) */
  25216. meshUnderPointer: Nullable<AbstractMesh>;
  25217. /** the original (browser) event that triggered the ActionEvent */
  25218. sourceEvent?: any;
  25219. /** additional data for the event */
  25220. additionalData?: any;
  25221. }
  25222. /**
  25223. * ActionEvent is the event being sent when an action is triggered.
  25224. */
  25225. export class ActionEvent implements IActionEvent {
  25226. /** The mesh or sprite that triggered the action */
  25227. source: any;
  25228. /** The X mouse cursor position at the time of the event */
  25229. pointerX: number;
  25230. /** The Y mouse cursor position at the time of the event */
  25231. pointerY: number;
  25232. /** The mesh that is currently pointed at (can be null) */
  25233. meshUnderPointer: Nullable<AbstractMesh>;
  25234. /** the original (browser) event that triggered the ActionEvent */
  25235. sourceEvent?: any;
  25236. /** additional data for the event */
  25237. additionalData?: any;
  25238. /**
  25239. * Creates a new ActionEvent
  25240. * @param source The mesh or sprite that triggered the action
  25241. * @param pointerX The X mouse cursor position at the time of the event
  25242. * @param pointerY The Y mouse cursor position at the time of the event
  25243. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25244. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25245. * @param additionalData additional data for the event
  25246. */
  25247. constructor(
  25248. /** The mesh or sprite that triggered the action */
  25249. source: any,
  25250. /** The X mouse cursor position at the time of the event */
  25251. pointerX: number,
  25252. /** The Y mouse cursor position at the time of the event */
  25253. pointerY: number,
  25254. /** The mesh that is currently pointed at (can be null) */
  25255. meshUnderPointer: Nullable<AbstractMesh>,
  25256. /** the original (browser) event that triggered the ActionEvent */
  25257. sourceEvent?: any,
  25258. /** additional data for the event */
  25259. additionalData?: any);
  25260. /**
  25261. * Helper function to auto-create an ActionEvent from a source mesh.
  25262. * @param source The source mesh that triggered the event
  25263. * @param evt The original (browser) event
  25264. * @param additionalData additional data for the event
  25265. * @returns the new ActionEvent
  25266. */
  25267. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25268. /**
  25269. * Helper function to auto-create an ActionEvent from a source sprite
  25270. * @param source The source sprite that triggered the event
  25271. * @param scene Scene associated with the sprite
  25272. * @param evt The original (browser) event
  25273. * @param additionalData additional data for the event
  25274. * @returns the new ActionEvent
  25275. */
  25276. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25277. /**
  25278. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25279. * @param scene the scene where the event occurred
  25280. * @param evt The original (browser) event
  25281. * @returns the new ActionEvent
  25282. */
  25283. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25284. /**
  25285. * Helper function to auto-create an ActionEvent from a primitive
  25286. * @param prim defines the target primitive
  25287. * @param pointerPos defines the pointer position
  25288. * @param evt The original (browser) event
  25289. * @param additionalData additional data for the event
  25290. * @returns the new ActionEvent
  25291. */
  25292. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25293. }
  25294. }
  25295. declare module "babylonjs/Actions/abstractActionManager" {
  25296. import { IDisposable } from "babylonjs/scene";
  25297. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25298. import { IAction } from "babylonjs/Actions/action";
  25299. import { Nullable } from "babylonjs/types";
  25300. /**
  25301. * Abstract class used to decouple action Manager from scene and meshes.
  25302. * Do not instantiate.
  25303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25304. */
  25305. export abstract class AbstractActionManager implements IDisposable {
  25306. /** Gets the list of active triggers */
  25307. static Triggers: {
  25308. [key: string]: number;
  25309. };
  25310. /** Gets the cursor to use when hovering items */
  25311. hoverCursor: string;
  25312. /** Gets the list of actions */
  25313. actions: IAction[];
  25314. /**
  25315. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25316. */
  25317. isRecursive: boolean;
  25318. /**
  25319. * Releases all associated resources
  25320. */
  25321. abstract dispose(): void;
  25322. /**
  25323. * Does this action manager has pointer triggers
  25324. */
  25325. abstract readonly hasPointerTriggers: boolean;
  25326. /**
  25327. * Does this action manager has pick triggers
  25328. */
  25329. abstract readonly hasPickTriggers: boolean;
  25330. /**
  25331. * Process a specific trigger
  25332. * @param trigger defines the trigger to process
  25333. * @param evt defines the event details to be processed
  25334. */
  25335. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25336. /**
  25337. * Does this action manager handles actions of any of the given triggers
  25338. * @param triggers defines the triggers to be tested
  25339. * @return a boolean indicating whether one (or more) of the triggers is handled
  25340. */
  25341. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25342. /**
  25343. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25344. * speed.
  25345. * @param triggerA defines the trigger to be tested
  25346. * @param triggerB defines the trigger to be tested
  25347. * @return a boolean indicating whether one (or more) of the triggers is handled
  25348. */
  25349. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25350. /**
  25351. * Does this action manager handles actions of a given trigger
  25352. * @param trigger defines the trigger to be tested
  25353. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25354. * @return whether the trigger is handled
  25355. */
  25356. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25357. /**
  25358. * Serialize this manager to a JSON object
  25359. * @param name defines the property name to store this manager
  25360. * @returns a JSON representation of this manager
  25361. */
  25362. abstract serialize(name: string): any;
  25363. /**
  25364. * Registers an action to this action manager
  25365. * @param action defines the action to be registered
  25366. * @return the action amended (prepared) after registration
  25367. */
  25368. abstract registerAction(action: IAction): Nullable<IAction>;
  25369. /**
  25370. * Unregisters an action to this action manager
  25371. * @param action defines the action to be unregistered
  25372. * @return a boolean indicating whether the action has been unregistered
  25373. */
  25374. abstract unregisterAction(action: IAction): Boolean;
  25375. /**
  25376. * Does exist one action manager with at least one trigger
  25377. **/
  25378. static readonly HasTriggers: boolean;
  25379. /**
  25380. * Does exist one action manager with at least one pick trigger
  25381. **/
  25382. static readonly HasPickTriggers: boolean;
  25383. /**
  25384. * Does exist one action manager that handles actions of a given trigger
  25385. * @param trigger defines the trigger to be tested
  25386. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25387. **/
  25388. static HasSpecificTrigger(trigger: number): boolean;
  25389. }
  25390. }
  25391. declare module "babylonjs/node" {
  25392. import { Scene } from "babylonjs/scene";
  25393. import { Nullable } from "babylonjs/types";
  25394. import { Matrix } from "babylonjs/Maths/math";
  25395. import { Engine } from "babylonjs/Engines/engine";
  25396. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25397. import { Observable } from "babylonjs/Misc/observable";
  25398. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25399. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25400. import { Animatable } from "babylonjs/Animations/animatable";
  25401. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25402. import { Animation } from "babylonjs/Animations/animation";
  25403. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25405. /**
  25406. * Defines how a node can be built from a string name.
  25407. */
  25408. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25409. /**
  25410. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25411. */
  25412. export class Node implements IBehaviorAware<Node> {
  25413. /** @hidden */
  25414. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25415. private static _NodeConstructors;
  25416. /**
  25417. * Add a new node constructor
  25418. * @param type defines the type name of the node to construct
  25419. * @param constructorFunc defines the constructor function
  25420. */
  25421. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25422. /**
  25423. * Returns a node constructor based on type name
  25424. * @param type defines the type name
  25425. * @param name defines the new node name
  25426. * @param scene defines the hosting scene
  25427. * @param options defines optional options to transmit to constructors
  25428. * @returns the new constructor or null
  25429. */
  25430. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25431. /**
  25432. * Gets or sets the name of the node
  25433. */
  25434. name: string;
  25435. /**
  25436. * Gets or sets the id of the node
  25437. */
  25438. id: string;
  25439. /**
  25440. * Gets or sets the unique id of the node
  25441. */
  25442. uniqueId: number;
  25443. /**
  25444. * Gets or sets a string used to store user defined state for the node
  25445. */
  25446. state: string;
  25447. /**
  25448. * Gets or sets an object used to store user defined information for the node
  25449. */
  25450. metadata: any;
  25451. /**
  25452. * For internal use only. Please do not use.
  25453. */
  25454. reservedDataStore: any;
  25455. /**
  25456. * List of inspectable custom properties (used by the Inspector)
  25457. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25458. */
  25459. inspectableCustomProperties: IInspectable[];
  25460. /**
  25461. * Gets or sets a boolean used to define if the node must be serialized
  25462. */
  25463. doNotSerialize: boolean;
  25464. /** @hidden */
  25465. _isDisposed: boolean;
  25466. /**
  25467. * Gets a list of Animations associated with the node
  25468. */
  25469. animations: import("babylonjs/Animations/animation").Animation[];
  25470. protected _ranges: {
  25471. [name: string]: Nullable<AnimationRange>;
  25472. };
  25473. /**
  25474. * Callback raised when the node is ready to be used
  25475. */
  25476. onReady: (node: Node) => void;
  25477. private _isEnabled;
  25478. private _isParentEnabled;
  25479. private _isReady;
  25480. /** @hidden */
  25481. _currentRenderId: number;
  25482. private _parentRenderId;
  25483. protected _childRenderId: number;
  25484. /** @hidden */
  25485. _waitingParentId: Nullable<string>;
  25486. /** @hidden */
  25487. _scene: Scene;
  25488. /** @hidden */
  25489. _cache: any;
  25490. private _parentNode;
  25491. private _children;
  25492. /** @hidden */
  25493. _worldMatrix: Matrix;
  25494. /** @hidden */
  25495. _worldMatrixDeterminant: number;
  25496. /** @hidden */
  25497. private _sceneRootNodesIndex;
  25498. /**
  25499. * Gets a boolean indicating if the node has been disposed
  25500. * @returns true if the node was disposed
  25501. */
  25502. isDisposed(): boolean;
  25503. /**
  25504. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25505. * @see https://doc.babylonjs.com/how_to/parenting
  25506. */
  25507. parent: Nullable<Node>;
  25508. private addToSceneRootNodes;
  25509. private removeFromSceneRootNodes;
  25510. private _animationPropertiesOverride;
  25511. /**
  25512. * Gets or sets the animation properties override
  25513. */
  25514. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25515. /**
  25516. * Gets a string idenfifying the name of the class
  25517. * @returns "Node" string
  25518. */
  25519. getClassName(): string;
  25520. /** @hidden */
  25521. readonly _isNode: boolean;
  25522. /**
  25523. * An event triggered when the mesh is disposed
  25524. */
  25525. onDisposeObservable: Observable<Node>;
  25526. private _onDisposeObserver;
  25527. /**
  25528. * Sets a callback that will be raised when the node will be disposed
  25529. */
  25530. onDispose: () => void;
  25531. /**
  25532. * Creates a new Node
  25533. * @param name the name and id to be given to this node
  25534. * @param scene the scene this node will be added to
  25535. * @param addToRootNodes the node will be added to scene.rootNodes
  25536. */
  25537. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25538. /**
  25539. * Gets the scene of the node
  25540. * @returns a scene
  25541. */
  25542. getScene(): Scene;
  25543. /**
  25544. * Gets the engine of the node
  25545. * @returns a Engine
  25546. */
  25547. getEngine(): Engine;
  25548. private _behaviors;
  25549. /**
  25550. * Attach a behavior to the node
  25551. * @see http://doc.babylonjs.com/features/behaviour
  25552. * @param behavior defines the behavior to attach
  25553. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25554. * @returns the current Node
  25555. */
  25556. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25557. /**
  25558. * Remove an attached behavior
  25559. * @see http://doc.babylonjs.com/features/behaviour
  25560. * @param behavior defines the behavior to attach
  25561. * @returns the current Node
  25562. */
  25563. removeBehavior(behavior: Behavior<Node>): Node;
  25564. /**
  25565. * Gets the list of attached behaviors
  25566. * @see http://doc.babylonjs.com/features/behaviour
  25567. */
  25568. readonly behaviors: Behavior<Node>[];
  25569. /**
  25570. * Gets an attached behavior by name
  25571. * @param name defines the name of the behavior to look for
  25572. * @see http://doc.babylonjs.com/features/behaviour
  25573. * @returns null if behavior was not found else the requested behavior
  25574. */
  25575. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25576. /**
  25577. * Returns the latest update of the World matrix
  25578. * @returns a Matrix
  25579. */
  25580. getWorldMatrix(): Matrix;
  25581. /** @hidden */
  25582. _getWorldMatrixDeterminant(): number;
  25583. /**
  25584. * Returns directly the latest state of the mesh World matrix.
  25585. * A Matrix is returned.
  25586. */
  25587. readonly worldMatrixFromCache: Matrix;
  25588. /** @hidden */
  25589. _initCache(): void;
  25590. /** @hidden */
  25591. updateCache(force?: boolean): void;
  25592. /** @hidden */
  25593. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25594. /** @hidden */
  25595. _updateCache(ignoreParentClass?: boolean): void;
  25596. /** @hidden */
  25597. _isSynchronized(): boolean;
  25598. /** @hidden */
  25599. _markSyncedWithParent(): void;
  25600. /** @hidden */
  25601. isSynchronizedWithParent(): boolean;
  25602. /** @hidden */
  25603. isSynchronized(): boolean;
  25604. /**
  25605. * Is this node ready to be used/rendered
  25606. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25607. * @return true if the node is ready
  25608. */
  25609. isReady(completeCheck?: boolean): boolean;
  25610. /**
  25611. * Is this node enabled?
  25612. * 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
  25613. * @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
  25614. * @return whether this node (and its parent) is enabled
  25615. */
  25616. isEnabled(checkAncestors?: boolean): boolean;
  25617. /** @hidden */
  25618. protected _syncParentEnabledState(): void;
  25619. /**
  25620. * Set the enabled state of this node
  25621. * @param value defines the new enabled state
  25622. */
  25623. setEnabled(value: boolean): void;
  25624. /**
  25625. * Is this node a descendant of the given node?
  25626. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25627. * @param ancestor defines the parent node to inspect
  25628. * @returns a boolean indicating if this node is a descendant of the given node
  25629. */
  25630. isDescendantOf(ancestor: Node): boolean;
  25631. /** @hidden */
  25632. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25633. /**
  25634. * Will return all nodes that have this node as ascendant
  25635. * @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
  25636. * @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
  25637. * @return all children nodes of all types
  25638. */
  25639. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25640. /**
  25641. * Get all child-meshes of this node
  25642. * @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)
  25643. * @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
  25644. * @returns an array of AbstractMesh
  25645. */
  25646. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25647. /**
  25648. * Get all direct children of this node
  25649. * @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
  25650. * @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)
  25651. * @returns an array of Node
  25652. */
  25653. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25654. /** @hidden */
  25655. _setReady(state: boolean): void;
  25656. /**
  25657. * Get an animation by name
  25658. * @param name defines the name of the animation to look for
  25659. * @returns null if not found else the requested animation
  25660. */
  25661. getAnimationByName(name: string): Nullable<Animation>;
  25662. /**
  25663. * Creates an animation range for this node
  25664. * @param name defines the name of the range
  25665. * @param from defines the starting key
  25666. * @param to defines the end key
  25667. */
  25668. createAnimationRange(name: string, from: number, to: number): void;
  25669. /**
  25670. * Delete a specific animation range
  25671. * @param name defines the name of the range to delete
  25672. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25673. */
  25674. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25675. /**
  25676. * Get an animation range by name
  25677. * @param name defines the name of the animation range to look for
  25678. * @returns null if not found else the requested animation range
  25679. */
  25680. getAnimationRange(name: string): Nullable<AnimationRange>;
  25681. /**
  25682. * Gets the list of all animation ranges defined on this node
  25683. * @returns an array
  25684. */
  25685. getAnimationRanges(): Nullable<AnimationRange>[];
  25686. /**
  25687. * Will start the animation sequence
  25688. * @param name defines the range frames for animation sequence
  25689. * @param loop defines if the animation should loop (false by default)
  25690. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25691. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25692. * @returns the object created for this animation. If range does not exist, it will return null
  25693. */
  25694. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25695. /**
  25696. * Serialize animation ranges into a JSON compatible object
  25697. * @returns serialization object
  25698. */
  25699. serializeAnimationRanges(): any;
  25700. /**
  25701. * Computes the world matrix of the node
  25702. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25703. * @returns the world matrix
  25704. */
  25705. computeWorldMatrix(force?: boolean): Matrix;
  25706. /**
  25707. * Releases resources associated with this node.
  25708. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25709. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25710. */
  25711. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25712. /**
  25713. * Parse animation range data from a serialization object and store them into a given node
  25714. * @param node defines where to store the animation ranges
  25715. * @param parsedNode defines the serialization object to read data from
  25716. * @param scene defines the hosting scene
  25717. */
  25718. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25719. }
  25720. }
  25721. declare module "babylonjs/Animations/animation" {
  25722. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25723. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25724. import { Nullable } from "babylonjs/types";
  25725. import { Scene } from "babylonjs/scene";
  25726. import { IAnimatable } from "babylonjs/Misc/tools";
  25727. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25728. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25729. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25730. import { Node } from "babylonjs/node";
  25731. import { Animatable } from "babylonjs/Animations/animatable";
  25732. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25733. /**
  25734. * Class used to store any kind of animation
  25735. */
  25736. export class Animation {
  25737. /**Name of the animation */
  25738. name: string;
  25739. /**Property to animate */
  25740. targetProperty: string;
  25741. /**The frames per second of the animation */
  25742. framePerSecond: number;
  25743. /**The data type of the animation */
  25744. dataType: number;
  25745. /**The loop mode of the animation */
  25746. loopMode?: number | undefined;
  25747. /**Specifies if blending should be enabled */
  25748. enableBlending?: boolean | undefined;
  25749. /**
  25750. * Use matrix interpolation instead of using direct key value when animating matrices
  25751. */
  25752. static AllowMatricesInterpolation: boolean;
  25753. /**
  25754. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25755. */
  25756. static AllowMatrixDecomposeForInterpolation: boolean;
  25757. /**
  25758. * Stores the key frames of the animation
  25759. */
  25760. private _keys;
  25761. /**
  25762. * Stores the easing function of the animation
  25763. */
  25764. private _easingFunction;
  25765. /**
  25766. * @hidden Internal use only
  25767. */
  25768. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25769. /**
  25770. * The set of event that will be linked to this animation
  25771. */
  25772. private _events;
  25773. /**
  25774. * Stores an array of target property paths
  25775. */
  25776. targetPropertyPath: string[];
  25777. /**
  25778. * Stores the blending speed of the animation
  25779. */
  25780. blendingSpeed: number;
  25781. /**
  25782. * Stores the animation ranges for the animation
  25783. */
  25784. private _ranges;
  25785. /**
  25786. * @hidden Internal use
  25787. */
  25788. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25789. /**
  25790. * Sets up an animation
  25791. * @param property The property to animate
  25792. * @param animationType The animation type to apply
  25793. * @param framePerSecond The frames per second of the animation
  25794. * @param easingFunction The easing function used in the animation
  25795. * @returns The created animation
  25796. */
  25797. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25798. /**
  25799. * Create and start an animation on a node
  25800. * @param name defines the name of the global animation that will be run on all nodes
  25801. * @param node defines the root node where the animation will take place
  25802. * @param targetProperty defines property to animate
  25803. * @param framePerSecond defines the number of frame per second yo use
  25804. * @param totalFrame defines the number of frames in total
  25805. * @param from defines the initial value
  25806. * @param to defines the final value
  25807. * @param loopMode defines which loop mode you want to use (off by default)
  25808. * @param easingFunction defines the easing function to use (linear by default)
  25809. * @param onAnimationEnd defines the callback to call when animation end
  25810. * @returns the animatable created for this animation
  25811. */
  25812. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25813. /**
  25814. * Create and start an animation on a node and its descendants
  25815. * @param name defines the name of the global animation that will be run on all nodes
  25816. * @param node defines the root node where the animation will take place
  25817. * @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
  25818. * @param targetProperty defines property to animate
  25819. * @param framePerSecond defines the number of frame per second to use
  25820. * @param totalFrame defines the number of frames in total
  25821. * @param from defines the initial value
  25822. * @param to defines the final value
  25823. * @param loopMode defines which loop mode you want to use (off by default)
  25824. * @param easingFunction defines the easing function to use (linear by default)
  25825. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25826. * @returns the list of animatables created for all nodes
  25827. * @example https://www.babylonjs-playground.com/#MH0VLI
  25828. */
  25829. 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[]>;
  25830. /**
  25831. * Creates a new animation, merges it with the existing animations and starts it
  25832. * @param name Name of the animation
  25833. * @param node Node which contains the scene that begins the animations
  25834. * @param targetProperty Specifies which property to animate
  25835. * @param framePerSecond The frames per second of the animation
  25836. * @param totalFrame The total number of frames
  25837. * @param from The frame at the beginning of the animation
  25838. * @param to The frame at the end of the animation
  25839. * @param loopMode Specifies the loop mode of the animation
  25840. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25841. * @param onAnimationEnd Callback to run once the animation is complete
  25842. * @returns Nullable animation
  25843. */
  25844. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25845. /**
  25846. * Transition property of an host to the target Value
  25847. * @param property The property to transition
  25848. * @param targetValue The target Value of the property
  25849. * @param host The object where the property to animate belongs
  25850. * @param scene Scene used to run the animation
  25851. * @param frameRate Framerate (in frame/s) to use
  25852. * @param transition The transition type we want to use
  25853. * @param duration The duration of the animation, in milliseconds
  25854. * @param onAnimationEnd Callback trigger at the end of the animation
  25855. * @returns Nullable animation
  25856. */
  25857. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25858. /**
  25859. * Return the array of runtime animations currently using this animation
  25860. */
  25861. readonly runtimeAnimations: RuntimeAnimation[];
  25862. /**
  25863. * Specifies if any of the runtime animations are currently running
  25864. */
  25865. readonly hasRunningRuntimeAnimations: boolean;
  25866. /**
  25867. * Initializes the animation
  25868. * @param name Name of the animation
  25869. * @param targetProperty Property to animate
  25870. * @param framePerSecond The frames per second of the animation
  25871. * @param dataType The data type of the animation
  25872. * @param loopMode The loop mode of the animation
  25873. * @param enableBlending Specifies if blending should be enabled
  25874. */
  25875. constructor(
  25876. /**Name of the animation */
  25877. name: string,
  25878. /**Property to animate */
  25879. targetProperty: string,
  25880. /**The frames per second of the animation */
  25881. framePerSecond: number,
  25882. /**The data type of the animation */
  25883. dataType: number,
  25884. /**The loop mode of the animation */
  25885. loopMode?: number | undefined,
  25886. /**Specifies if blending should be enabled */
  25887. enableBlending?: boolean | undefined);
  25888. /**
  25889. * Converts the animation to a string
  25890. * @param fullDetails support for multiple levels of logging within scene loading
  25891. * @returns String form of the animation
  25892. */
  25893. toString(fullDetails?: boolean): string;
  25894. /**
  25895. * Add an event to this animation
  25896. * @param event Event to add
  25897. */
  25898. addEvent(event: AnimationEvent): void;
  25899. /**
  25900. * Remove all events found at the given frame
  25901. * @param frame The frame to remove events from
  25902. */
  25903. removeEvents(frame: number): void;
  25904. /**
  25905. * Retrieves all the events from the animation
  25906. * @returns Events from the animation
  25907. */
  25908. getEvents(): AnimationEvent[];
  25909. /**
  25910. * Creates an animation range
  25911. * @param name Name of the animation range
  25912. * @param from Starting frame of the animation range
  25913. * @param to Ending frame of the animation
  25914. */
  25915. createRange(name: string, from: number, to: number): void;
  25916. /**
  25917. * Deletes an animation range by name
  25918. * @param name Name of the animation range to delete
  25919. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25920. */
  25921. deleteRange(name: string, deleteFrames?: boolean): void;
  25922. /**
  25923. * Gets the animation range by name, or null if not defined
  25924. * @param name Name of the animation range
  25925. * @returns Nullable animation range
  25926. */
  25927. getRange(name: string): Nullable<AnimationRange>;
  25928. /**
  25929. * Gets the key frames from the animation
  25930. * @returns The key frames of the animation
  25931. */
  25932. getKeys(): Array<IAnimationKey>;
  25933. /**
  25934. * Gets the highest frame rate of the animation
  25935. * @returns Highest frame rate of the animation
  25936. */
  25937. getHighestFrame(): number;
  25938. /**
  25939. * Gets the easing function of the animation
  25940. * @returns Easing function of the animation
  25941. */
  25942. getEasingFunction(): IEasingFunction;
  25943. /**
  25944. * Sets the easing function of the animation
  25945. * @param easingFunction A custom mathematical formula for animation
  25946. */
  25947. setEasingFunction(easingFunction: EasingFunction): void;
  25948. /**
  25949. * Interpolates a scalar linearly
  25950. * @param startValue Start value of the animation curve
  25951. * @param endValue End value of the animation curve
  25952. * @param gradient Scalar amount to interpolate
  25953. * @returns Interpolated scalar value
  25954. */
  25955. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25956. /**
  25957. * Interpolates a scalar cubically
  25958. * @param startValue Start value of the animation curve
  25959. * @param outTangent End tangent of the animation
  25960. * @param endValue End value of the animation curve
  25961. * @param inTangent Start tangent of the animation curve
  25962. * @param gradient Scalar amount to interpolate
  25963. * @returns Interpolated scalar value
  25964. */
  25965. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25966. /**
  25967. * Interpolates a quaternion using a spherical linear interpolation
  25968. * @param startValue Start value of the animation curve
  25969. * @param endValue End value of the animation curve
  25970. * @param gradient Scalar amount to interpolate
  25971. * @returns Interpolated quaternion value
  25972. */
  25973. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25974. /**
  25975. * Interpolates a quaternion cubically
  25976. * @param startValue Start value of the animation curve
  25977. * @param outTangent End tangent of the animation curve
  25978. * @param endValue End value of the animation curve
  25979. * @param inTangent Start tangent of the animation curve
  25980. * @param gradient Scalar amount to interpolate
  25981. * @returns Interpolated quaternion value
  25982. */
  25983. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25984. /**
  25985. * Interpolates a Vector3 linearl
  25986. * @param startValue Start value of the animation curve
  25987. * @param endValue End value of the animation curve
  25988. * @param gradient Scalar amount to interpolate
  25989. * @returns Interpolated scalar value
  25990. */
  25991. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25992. /**
  25993. * Interpolates a Vector3 cubically
  25994. * @param startValue Start value of the animation curve
  25995. * @param outTangent End tangent of the animation
  25996. * @param endValue End value of the animation curve
  25997. * @param inTangent Start tangent of the animation curve
  25998. * @param gradient Scalar amount to interpolate
  25999. * @returns InterpolatedVector3 value
  26000. */
  26001. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26002. /**
  26003. * Interpolates a Vector2 linearly
  26004. * @param startValue Start value of the animation curve
  26005. * @param endValue End value of the animation curve
  26006. * @param gradient Scalar amount to interpolate
  26007. * @returns Interpolated Vector2 value
  26008. */
  26009. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26010. /**
  26011. * Interpolates a Vector2 cubically
  26012. * @param startValue Start value of the animation curve
  26013. * @param outTangent End tangent of the animation
  26014. * @param endValue End value of the animation curve
  26015. * @param inTangent Start tangent of the animation curve
  26016. * @param gradient Scalar amount to interpolate
  26017. * @returns Interpolated Vector2 value
  26018. */
  26019. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26020. /**
  26021. * Interpolates a size linearly
  26022. * @param startValue Start value of the animation curve
  26023. * @param endValue End value of the animation curve
  26024. * @param gradient Scalar amount to interpolate
  26025. * @returns Interpolated Size value
  26026. */
  26027. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26028. /**
  26029. * Interpolates a Color3 linearly
  26030. * @param startValue Start value of the animation curve
  26031. * @param endValue End value of the animation curve
  26032. * @param gradient Scalar amount to interpolate
  26033. * @returns Interpolated Color3 value
  26034. */
  26035. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26036. /**
  26037. * @hidden Internal use only
  26038. */
  26039. _getKeyValue(value: any): any;
  26040. /**
  26041. * @hidden Internal use only
  26042. */
  26043. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26044. /**
  26045. * Defines the function to use to interpolate matrices
  26046. * @param startValue defines the start matrix
  26047. * @param endValue defines the end matrix
  26048. * @param gradient defines the gradient between both matrices
  26049. * @param result defines an optional target matrix where to store the interpolation
  26050. * @returns the interpolated matrix
  26051. */
  26052. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26053. /**
  26054. * Makes a copy of the animation
  26055. * @returns Cloned animation
  26056. */
  26057. clone(): Animation;
  26058. /**
  26059. * Sets the key frames of the animation
  26060. * @param values The animation key frames to set
  26061. */
  26062. setKeys(values: Array<IAnimationKey>): void;
  26063. /**
  26064. * Serializes the animation to an object
  26065. * @returns Serialized object
  26066. */
  26067. serialize(): any;
  26068. /**
  26069. * Float animation type
  26070. */
  26071. private static _ANIMATIONTYPE_FLOAT;
  26072. /**
  26073. * Vector3 animation type
  26074. */
  26075. private static _ANIMATIONTYPE_VECTOR3;
  26076. /**
  26077. * Quaternion animation type
  26078. */
  26079. private static _ANIMATIONTYPE_QUATERNION;
  26080. /**
  26081. * Matrix animation type
  26082. */
  26083. private static _ANIMATIONTYPE_MATRIX;
  26084. /**
  26085. * Color3 animation type
  26086. */
  26087. private static _ANIMATIONTYPE_COLOR3;
  26088. /**
  26089. * Vector2 animation type
  26090. */
  26091. private static _ANIMATIONTYPE_VECTOR2;
  26092. /**
  26093. * Size animation type
  26094. */
  26095. private static _ANIMATIONTYPE_SIZE;
  26096. /**
  26097. * Relative Loop Mode
  26098. */
  26099. private static _ANIMATIONLOOPMODE_RELATIVE;
  26100. /**
  26101. * Cycle Loop Mode
  26102. */
  26103. private static _ANIMATIONLOOPMODE_CYCLE;
  26104. /**
  26105. * Constant Loop Mode
  26106. */
  26107. private static _ANIMATIONLOOPMODE_CONSTANT;
  26108. /**
  26109. * Get the float animation type
  26110. */
  26111. static readonly ANIMATIONTYPE_FLOAT: number;
  26112. /**
  26113. * Get the Vector3 animation type
  26114. */
  26115. static readonly ANIMATIONTYPE_VECTOR3: number;
  26116. /**
  26117. * Get the Vector2 animation type
  26118. */
  26119. static readonly ANIMATIONTYPE_VECTOR2: number;
  26120. /**
  26121. * Get the Size animation type
  26122. */
  26123. static readonly ANIMATIONTYPE_SIZE: number;
  26124. /**
  26125. * Get the Quaternion animation type
  26126. */
  26127. static readonly ANIMATIONTYPE_QUATERNION: number;
  26128. /**
  26129. * Get the Matrix animation type
  26130. */
  26131. static readonly ANIMATIONTYPE_MATRIX: number;
  26132. /**
  26133. * Get the Color3 animation type
  26134. */
  26135. static readonly ANIMATIONTYPE_COLOR3: number;
  26136. /**
  26137. * Get the Relative Loop Mode
  26138. */
  26139. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26140. /**
  26141. * Get the Cycle Loop Mode
  26142. */
  26143. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26144. /**
  26145. * Get the Constant Loop Mode
  26146. */
  26147. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26148. /** @hidden */
  26149. static _UniversalLerp(left: any, right: any, amount: number): any;
  26150. /**
  26151. * Parses an animation object and creates an animation
  26152. * @param parsedAnimation Parsed animation object
  26153. * @returns Animation object
  26154. */
  26155. static Parse(parsedAnimation: any): Animation;
  26156. /**
  26157. * Appends the serialized animations from the source animations
  26158. * @param source Source containing the animations
  26159. * @param destination Target to store the animations
  26160. */
  26161. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26162. }
  26163. }
  26164. declare module "babylonjs/Materials/Textures/baseTexture" {
  26165. import { Observable } from "babylonjs/Misc/observable";
  26166. import { IAnimatable } from "babylonjs/Misc/tools";
  26167. import { Nullable } from "babylonjs/types";
  26168. import { Scene } from "babylonjs/scene";
  26169. import { Matrix, ISize } from "babylonjs/Maths/math";
  26170. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26172. /**
  26173. * Base class of all the textures in babylon.
  26174. * It groups all the common properties the materials, post process, lights... might need
  26175. * in order to make a correct use of the texture.
  26176. */
  26177. export class BaseTexture implements IAnimatable {
  26178. /**
  26179. * Default anisotropic filtering level for the application.
  26180. * It is set to 4 as a good tradeoff between perf and quality.
  26181. */
  26182. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26183. /**
  26184. * Gets or sets the unique id of the texture
  26185. */
  26186. uniqueId: number;
  26187. /**
  26188. * Define the name of the texture.
  26189. */
  26190. name: string;
  26191. /**
  26192. * Gets or sets an object used to store user defined information.
  26193. */
  26194. metadata: any;
  26195. /**
  26196. * For internal use only. Please do not use.
  26197. */
  26198. reservedDataStore: any;
  26199. private _hasAlpha;
  26200. /**
  26201. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26202. */
  26203. hasAlpha: boolean;
  26204. /**
  26205. * Defines if the alpha value should be determined via the rgb values.
  26206. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26207. */
  26208. getAlphaFromRGB: boolean;
  26209. /**
  26210. * Intensity or strength of the texture.
  26211. * It is commonly used by materials to fine tune the intensity of the texture
  26212. */
  26213. level: number;
  26214. /**
  26215. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26216. * This is part of the texture as textures usually maps to one uv set.
  26217. */
  26218. coordinatesIndex: number;
  26219. private _coordinatesMode;
  26220. /**
  26221. * How a texture is mapped.
  26222. *
  26223. * | Value | Type | Description |
  26224. * | ----- | ----------------------------------- | ----------- |
  26225. * | 0 | EXPLICIT_MODE | |
  26226. * | 1 | SPHERICAL_MODE | |
  26227. * | 2 | PLANAR_MODE | |
  26228. * | 3 | CUBIC_MODE | |
  26229. * | 4 | PROJECTION_MODE | |
  26230. * | 5 | SKYBOX_MODE | |
  26231. * | 6 | INVCUBIC_MODE | |
  26232. * | 7 | EQUIRECTANGULAR_MODE | |
  26233. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26234. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26235. */
  26236. coordinatesMode: number;
  26237. /**
  26238. * | Value | Type | Description |
  26239. * | ----- | ------------------ | ----------- |
  26240. * | 0 | CLAMP_ADDRESSMODE | |
  26241. * | 1 | WRAP_ADDRESSMODE | |
  26242. * | 2 | MIRROR_ADDRESSMODE | |
  26243. */
  26244. wrapU: number;
  26245. /**
  26246. * | Value | Type | Description |
  26247. * | ----- | ------------------ | ----------- |
  26248. * | 0 | CLAMP_ADDRESSMODE | |
  26249. * | 1 | WRAP_ADDRESSMODE | |
  26250. * | 2 | MIRROR_ADDRESSMODE | |
  26251. */
  26252. wrapV: number;
  26253. /**
  26254. * | Value | Type | Description |
  26255. * | ----- | ------------------ | ----------- |
  26256. * | 0 | CLAMP_ADDRESSMODE | |
  26257. * | 1 | WRAP_ADDRESSMODE | |
  26258. * | 2 | MIRROR_ADDRESSMODE | |
  26259. */
  26260. wrapR: number;
  26261. /**
  26262. * With compliant hardware and browser (supporting anisotropic filtering)
  26263. * this defines the level of anisotropic filtering in the texture.
  26264. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26265. */
  26266. anisotropicFilteringLevel: number;
  26267. /**
  26268. * Define if the texture is a cube texture or if false a 2d texture.
  26269. */
  26270. isCube: boolean;
  26271. /**
  26272. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26273. */
  26274. is3D: boolean;
  26275. /**
  26276. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26277. * HDR texture are usually stored in linear space.
  26278. * This only impacts the PBR and Background materials
  26279. */
  26280. gammaSpace: boolean;
  26281. /**
  26282. * Gets whether or not the texture contains RGBD data.
  26283. */
  26284. readonly isRGBD: boolean;
  26285. /**
  26286. * Is Z inverted in the texture (useful in a cube texture).
  26287. */
  26288. invertZ: boolean;
  26289. /**
  26290. * Are mip maps generated for this texture or not.
  26291. */
  26292. readonly noMipmap: boolean;
  26293. /**
  26294. * @hidden
  26295. */
  26296. lodLevelInAlpha: boolean;
  26297. /**
  26298. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26299. */
  26300. lodGenerationOffset: number;
  26301. /**
  26302. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26303. */
  26304. lodGenerationScale: number;
  26305. /**
  26306. * Define if the texture is a render target.
  26307. */
  26308. isRenderTarget: boolean;
  26309. /**
  26310. * Define the unique id of the texture in the scene.
  26311. */
  26312. readonly uid: string;
  26313. /**
  26314. * Return a string representation of the texture.
  26315. * @returns the texture as a string
  26316. */
  26317. toString(): string;
  26318. /**
  26319. * Get the class name of the texture.
  26320. * @returns "BaseTexture"
  26321. */
  26322. getClassName(): string;
  26323. /**
  26324. * Define the list of animation attached to the texture.
  26325. */
  26326. animations: import("babylonjs/Animations/animation").Animation[];
  26327. /**
  26328. * An event triggered when the texture is disposed.
  26329. */
  26330. onDisposeObservable: Observable<BaseTexture>;
  26331. private _onDisposeObserver;
  26332. /**
  26333. * Callback triggered when the texture has been disposed.
  26334. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26335. */
  26336. onDispose: () => void;
  26337. /**
  26338. * Define the current state of the loading sequence when in delayed load mode.
  26339. */
  26340. delayLoadState: number;
  26341. private _scene;
  26342. /** @hidden */
  26343. _texture: Nullable<InternalTexture>;
  26344. private _uid;
  26345. /**
  26346. * Define if the texture is preventinga material to render or not.
  26347. * If not and the texture is not ready, the engine will use a default black texture instead.
  26348. */
  26349. readonly isBlocking: boolean;
  26350. /**
  26351. * Instantiates a new BaseTexture.
  26352. * Base class of all the textures in babylon.
  26353. * It groups all the common properties the materials, post process, lights... might need
  26354. * in order to make a correct use of the texture.
  26355. * @param scene Define the scene the texture blongs to
  26356. */
  26357. constructor(scene: Nullable<Scene>);
  26358. /**
  26359. * Get the scene the texture belongs to.
  26360. * @returns the scene or null if undefined
  26361. */
  26362. getScene(): Nullable<Scene>;
  26363. /**
  26364. * Get the texture transform matrix used to offset tile the texture for istance.
  26365. * @returns the transformation matrix
  26366. */
  26367. getTextureMatrix(): Matrix;
  26368. /**
  26369. * Get the texture reflection matrix used to rotate/transform the reflection.
  26370. * @returns the reflection matrix
  26371. */
  26372. getReflectionTextureMatrix(): Matrix;
  26373. /**
  26374. * Get the underlying lower level texture from Babylon.
  26375. * @returns the insternal texture
  26376. */
  26377. getInternalTexture(): Nullable<InternalTexture>;
  26378. /**
  26379. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26380. * @returns true if ready or not blocking
  26381. */
  26382. isReadyOrNotBlocking(): boolean;
  26383. /**
  26384. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26385. * @returns true if fully ready
  26386. */
  26387. isReady(): boolean;
  26388. private _cachedSize;
  26389. /**
  26390. * Get the size of the texture.
  26391. * @returns the texture size.
  26392. */
  26393. getSize(): ISize;
  26394. /**
  26395. * Get the base size of the texture.
  26396. * It can be different from the size if the texture has been resized for POT for instance
  26397. * @returns the base size
  26398. */
  26399. getBaseSize(): ISize;
  26400. /**
  26401. * Update the sampling mode of the texture.
  26402. * Default is Trilinear mode.
  26403. *
  26404. * | Value | Type | Description |
  26405. * | ----- | ------------------ | ----------- |
  26406. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26407. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26408. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26409. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26410. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26411. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26412. * | 7 | NEAREST_LINEAR | |
  26413. * | 8 | NEAREST_NEAREST | |
  26414. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26415. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26416. * | 11 | LINEAR_LINEAR | |
  26417. * | 12 | LINEAR_NEAREST | |
  26418. *
  26419. * > _mag_: magnification filter (close to the viewer)
  26420. * > _min_: minification filter (far from the viewer)
  26421. * > _mip_: filter used between mip map levels
  26422. *@param samplingMode Define the new sampling mode of the texture
  26423. */
  26424. updateSamplingMode(samplingMode: number): void;
  26425. /**
  26426. * Scales the texture if is `canRescale()`
  26427. * @param ratio the resize factor we want to use to rescale
  26428. */
  26429. scale(ratio: number): void;
  26430. /**
  26431. * Get if the texture can rescale.
  26432. */
  26433. readonly canRescale: boolean;
  26434. /** @hidden */
  26435. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26436. /** @hidden */
  26437. _rebuild(): void;
  26438. /**
  26439. * Triggers the load sequence in delayed load mode.
  26440. */
  26441. delayLoad(): void;
  26442. /**
  26443. * Clones the texture.
  26444. * @returns the cloned texture
  26445. */
  26446. clone(): Nullable<BaseTexture>;
  26447. /**
  26448. * Get the texture underlying type (INT, FLOAT...)
  26449. */
  26450. readonly textureType: number;
  26451. /**
  26452. * Get the texture underlying format (RGB, RGBA...)
  26453. */
  26454. readonly textureFormat: number;
  26455. /**
  26456. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26457. * This will returns an RGBA array buffer containing either in values (0-255) or
  26458. * float values (0-1) depending of the underlying buffer type.
  26459. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26460. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26461. * @param buffer defines a user defined buffer to fill with data (can be null)
  26462. * @returns The Array buffer containing the pixels data.
  26463. */
  26464. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26465. /**
  26466. * Release and destroy the underlying lower level texture aka internalTexture.
  26467. */
  26468. releaseInternalTexture(): void;
  26469. /**
  26470. * Get the polynomial representation of the texture data.
  26471. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26472. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26473. */
  26474. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26475. /** @hidden */
  26476. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26477. /** @hidden */
  26478. readonly _lodTextureMid: Nullable<BaseTexture>;
  26479. /** @hidden */
  26480. readonly _lodTextureLow: Nullable<BaseTexture>;
  26481. /**
  26482. * Dispose the texture and release its associated resources.
  26483. */
  26484. dispose(): void;
  26485. /**
  26486. * Serialize the texture into a JSON representation that can be parsed later on.
  26487. * @returns the JSON representation of the texture
  26488. */
  26489. serialize(): any;
  26490. /**
  26491. * Helper function to be called back once a list of texture contains only ready textures.
  26492. * @param textures Define the list of textures to wait for
  26493. * @param callback Define the callback triggered once the entire list will be ready
  26494. */
  26495. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26496. }
  26497. }
  26498. declare module "babylonjs/Materials/uniformBuffer" {
  26499. import { Nullable, FloatArray } from "babylonjs/types";
  26500. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26501. import { Engine } from "babylonjs/Engines/engine";
  26502. import { Effect } from "babylonjs/Materials/effect";
  26503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26504. /**
  26505. * Uniform buffer objects.
  26506. *
  26507. * Handles blocks of uniform on the GPU.
  26508. *
  26509. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26510. *
  26511. * For more information, please refer to :
  26512. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26513. */
  26514. export class UniformBuffer {
  26515. private _engine;
  26516. private _buffer;
  26517. private _data;
  26518. private _bufferData;
  26519. private _dynamic?;
  26520. private _uniformLocations;
  26521. private _uniformSizes;
  26522. private _uniformLocationPointer;
  26523. private _needSync;
  26524. private _noUBO;
  26525. private _currentEffect;
  26526. private static _MAX_UNIFORM_SIZE;
  26527. private static _tempBuffer;
  26528. /**
  26529. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26530. * This is dynamic to allow compat with webgl 1 and 2.
  26531. * You will need to pass the name of the uniform as well as the value.
  26532. */
  26533. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26534. /**
  26535. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26536. * This is dynamic to allow compat with webgl 1 and 2.
  26537. * You will need to pass the name of the uniform as well as the value.
  26538. */
  26539. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26540. /**
  26541. * Lambda to Update a single float in a uniform buffer.
  26542. * This is dynamic to allow compat with webgl 1 and 2.
  26543. * You will need to pass the name of the uniform as well as the value.
  26544. */
  26545. updateFloat: (name: string, x: number) => void;
  26546. /**
  26547. * Lambda to Update a vec2 of float in a uniform buffer.
  26548. * This is dynamic to allow compat with webgl 1 and 2.
  26549. * You will need to pass the name of the uniform as well as the value.
  26550. */
  26551. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26552. /**
  26553. * Lambda to Update a vec3 of float in a uniform buffer.
  26554. * This is dynamic to allow compat with webgl 1 and 2.
  26555. * You will need to pass the name of the uniform as well as the value.
  26556. */
  26557. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26558. /**
  26559. * Lambda to Update a vec4 of float in a uniform buffer.
  26560. * This is dynamic to allow compat with webgl 1 and 2.
  26561. * You will need to pass the name of the uniform as well as the value.
  26562. */
  26563. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26564. /**
  26565. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26566. * This is dynamic to allow compat with webgl 1 and 2.
  26567. * You will need to pass the name of the uniform as well as the value.
  26568. */
  26569. updateMatrix: (name: string, mat: Matrix) => void;
  26570. /**
  26571. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26572. * This is dynamic to allow compat with webgl 1 and 2.
  26573. * You will need to pass the name of the uniform as well as the value.
  26574. */
  26575. updateVector3: (name: string, vector: Vector3) => void;
  26576. /**
  26577. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26578. * This is dynamic to allow compat with webgl 1 and 2.
  26579. * You will need to pass the name of the uniform as well as the value.
  26580. */
  26581. updateVector4: (name: string, vector: Vector4) => void;
  26582. /**
  26583. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26584. * This is dynamic to allow compat with webgl 1 and 2.
  26585. * You will need to pass the name of the uniform as well as the value.
  26586. */
  26587. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26588. /**
  26589. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26590. * This is dynamic to allow compat with webgl 1 and 2.
  26591. * You will need to pass the name of the uniform as well as the value.
  26592. */
  26593. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26594. /**
  26595. * Instantiates a new Uniform buffer objects.
  26596. *
  26597. * Handles blocks of uniform on the GPU.
  26598. *
  26599. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26600. *
  26601. * For more information, please refer to :
  26602. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26603. * @param engine Define the engine the buffer is associated with
  26604. * @param data Define the data contained in the buffer
  26605. * @param dynamic Define if the buffer is updatable
  26606. */
  26607. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26608. /**
  26609. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26610. * or just falling back on setUniformXXX calls.
  26611. */
  26612. readonly useUbo: boolean;
  26613. /**
  26614. * Indicates if the WebGL underlying uniform buffer is in sync
  26615. * with the javascript cache data.
  26616. */
  26617. readonly isSync: boolean;
  26618. /**
  26619. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26620. * Also, a dynamic UniformBuffer will disable cache verification and always
  26621. * update the underlying WebGL uniform buffer to the GPU.
  26622. * @returns if Dynamic, otherwise false
  26623. */
  26624. isDynamic(): boolean;
  26625. /**
  26626. * The data cache on JS side.
  26627. * @returns the underlying data as a float array
  26628. */
  26629. getData(): Float32Array;
  26630. /**
  26631. * The underlying WebGL Uniform buffer.
  26632. * @returns the webgl buffer
  26633. */
  26634. getBuffer(): Nullable<WebGLBuffer>;
  26635. /**
  26636. * std140 layout specifies how to align data within an UBO structure.
  26637. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26638. * for specs.
  26639. */
  26640. private _fillAlignment;
  26641. /**
  26642. * Adds an uniform in the buffer.
  26643. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26644. * for the layout to be correct !
  26645. * @param name Name of the uniform, as used in the uniform block in the shader.
  26646. * @param size Data size, or data directly.
  26647. */
  26648. addUniform(name: string, size: number | number[]): void;
  26649. /**
  26650. * Adds a Matrix 4x4 to the uniform buffer.
  26651. * @param name Name of the uniform, as used in the uniform block in the shader.
  26652. * @param mat A 4x4 matrix.
  26653. */
  26654. addMatrix(name: string, mat: Matrix): void;
  26655. /**
  26656. * Adds a vec2 to the uniform buffer.
  26657. * @param name Name of the uniform, as used in the uniform block in the shader.
  26658. * @param x Define the x component value of the vec2
  26659. * @param y Define the y component value of the vec2
  26660. */
  26661. addFloat2(name: string, x: number, y: number): void;
  26662. /**
  26663. * Adds a vec3 to the uniform buffer.
  26664. * @param name Name of the uniform, as used in the uniform block in the shader.
  26665. * @param x Define the x component value of the vec3
  26666. * @param y Define the y component value of the vec3
  26667. * @param z Define the z component value of the vec3
  26668. */
  26669. addFloat3(name: string, x: number, y: number, z: number): void;
  26670. /**
  26671. * Adds a vec3 to the uniform buffer.
  26672. * @param name Name of the uniform, as used in the uniform block in the shader.
  26673. * @param color Define the vec3 from a Color
  26674. */
  26675. addColor3(name: string, color: Color3): void;
  26676. /**
  26677. * Adds a vec4 to the uniform buffer.
  26678. * @param name Name of the uniform, as used in the uniform block in the shader.
  26679. * @param color Define the rgb components from a Color
  26680. * @param alpha Define the a component of the vec4
  26681. */
  26682. addColor4(name: string, color: Color3, alpha: number): void;
  26683. /**
  26684. * Adds a vec3 to the uniform buffer.
  26685. * @param name Name of the uniform, as used in the uniform block in the shader.
  26686. * @param vector Define the vec3 components from a Vector
  26687. */
  26688. addVector3(name: string, vector: Vector3): void;
  26689. /**
  26690. * Adds a Matrix 3x3 to the uniform buffer.
  26691. * @param name Name of the uniform, as used in the uniform block in the shader.
  26692. */
  26693. addMatrix3x3(name: string): void;
  26694. /**
  26695. * Adds a Matrix 2x2 to the uniform buffer.
  26696. * @param name Name of the uniform, as used in the uniform block in the shader.
  26697. */
  26698. addMatrix2x2(name: string): void;
  26699. /**
  26700. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26701. */
  26702. create(): void;
  26703. /** @hidden */
  26704. _rebuild(): void;
  26705. /**
  26706. * Updates the WebGL Uniform Buffer on the GPU.
  26707. * If the `dynamic` flag is set to true, no cache comparison is done.
  26708. * Otherwise, the buffer will be updated only if the cache differs.
  26709. */
  26710. update(): void;
  26711. /**
  26712. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26713. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26714. * @param data Define the flattened data
  26715. * @param size Define the size of the data.
  26716. */
  26717. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26718. private _updateMatrix3x3ForUniform;
  26719. private _updateMatrix3x3ForEffect;
  26720. private _updateMatrix2x2ForEffect;
  26721. private _updateMatrix2x2ForUniform;
  26722. private _updateFloatForEffect;
  26723. private _updateFloatForUniform;
  26724. private _updateFloat2ForEffect;
  26725. private _updateFloat2ForUniform;
  26726. private _updateFloat3ForEffect;
  26727. private _updateFloat3ForUniform;
  26728. private _updateFloat4ForEffect;
  26729. private _updateFloat4ForUniform;
  26730. private _updateMatrixForEffect;
  26731. private _updateMatrixForUniform;
  26732. private _updateVector3ForEffect;
  26733. private _updateVector3ForUniform;
  26734. private _updateVector4ForEffect;
  26735. private _updateVector4ForUniform;
  26736. private _updateColor3ForEffect;
  26737. private _updateColor3ForUniform;
  26738. private _updateColor4ForEffect;
  26739. private _updateColor4ForUniform;
  26740. /**
  26741. * Sets a sampler uniform on the effect.
  26742. * @param name Define the name of the sampler.
  26743. * @param texture Define the texture to set in the sampler
  26744. */
  26745. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26746. /**
  26747. * Directly updates the value of the uniform in the cache AND on the GPU.
  26748. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26749. * @param data Define the flattened data
  26750. */
  26751. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26752. /**
  26753. * Binds this uniform buffer to an effect.
  26754. * @param effect Define the effect to bind the buffer to
  26755. * @param name Name of the uniform block in the shader.
  26756. */
  26757. bindToEffect(effect: Effect, name: string): void;
  26758. /**
  26759. * Disposes the uniform buffer.
  26760. */
  26761. dispose(): void;
  26762. }
  26763. }
  26764. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26765. import { Nullable } from "babylonjs/types";
  26766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26767. /**
  26768. * This represents the required contract to create a new type of texture loader.
  26769. */
  26770. export interface IInternalTextureLoader {
  26771. /**
  26772. * Defines wether the loader supports cascade loading the different faces.
  26773. */
  26774. supportCascades: boolean;
  26775. /**
  26776. * This returns if the loader support the current file information.
  26777. * @param extension defines the file extension of the file being loaded
  26778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26779. * @param fallback defines the fallback internal texture if any
  26780. * @param isBase64 defines whether the texture is encoded as a base64
  26781. * @param isBuffer defines whether the texture data are stored as a buffer
  26782. * @returns true if the loader can load the specified file
  26783. */
  26784. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26785. /**
  26786. * Transform the url before loading if required.
  26787. * @param rootUrl the url of the texture
  26788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26789. * @returns the transformed texture
  26790. */
  26791. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26792. /**
  26793. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26794. * @param rootUrl the url of the texture
  26795. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26796. * @returns the fallback texture
  26797. */
  26798. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26799. /**
  26800. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26801. * @param data contains the texture data
  26802. * @param texture defines the BabylonJS internal texture
  26803. * @param createPolynomials will be true if polynomials have been requested
  26804. * @param onLoad defines the callback to trigger once the texture is ready
  26805. * @param onError defines the callback to trigger in case of error
  26806. */
  26807. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26808. /**
  26809. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26810. * @param data contains the texture data
  26811. * @param texture defines the BabylonJS internal texture
  26812. * @param callback defines the method to call once ready to upload
  26813. */
  26814. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26815. }
  26816. }
  26817. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26818. import { Scene } from "babylonjs/scene";
  26819. import { Engine } from "babylonjs/Engines/engine";
  26820. import { Texture } from "babylonjs/Materials/Textures/texture";
  26821. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26822. /**
  26823. * Creation options of the multi render target texture.
  26824. */
  26825. export interface IMultiRenderTargetOptions {
  26826. /**
  26827. * Define if the texture needs to create mip maps after render.
  26828. */
  26829. generateMipMaps?: boolean;
  26830. /**
  26831. * Define the types of all the draw buffers we want to create
  26832. */
  26833. types?: number[];
  26834. /**
  26835. * Define the sampling modes of all the draw buffers we want to create
  26836. */
  26837. samplingModes?: number[];
  26838. /**
  26839. * Define if a depth buffer is required
  26840. */
  26841. generateDepthBuffer?: boolean;
  26842. /**
  26843. * Define if a stencil buffer is required
  26844. */
  26845. generateStencilBuffer?: boolean;
  26846. /**
  26847. * Define if a depth texture is required instead of a depth buffer
  26848. */
  26849. generateDepthTexture?: boolean;
  26850. /**
  26851. * Define the number of desired draw buffers
  26852. */
  26853. textureCount?: number;
  26854. /**
  26855. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26856. */
  26857. doNotChangeAspectRatio?: boolean;
  26858. /**
  26859. * Define the default type of the buffers we are creating
  26860. */
  26861. defaultType?: number;
  26862. }
  26863. /**
  26864. * A multi render target, like a render target provides the ability to render to a texture.
  26865. * Unlike the render target, it can render to several draw buffers in one draw.
  26866. * This is specially interesting in deferred rendering or for any effects requiring more than
  26867. * just one color from a single pass.
  26868. */
  26869. export class MultiRenderTarget extends RenderTargetTexture {
  26870. private _internalTextures;
  26871. private _textures;
  26872. private _multiRenderTargetOptions;
  26873. /**
  26874. * Get if draw buffers are currently supported by the used hardware and browser.
  26875. */
  26876. readonly isSupported: boolean;
  26877. /**
  26878. * Get the list of textures generated by the multi render target.
  26879. */
  26880. readonly textures: Texture[];
  26881. /**
  26882. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26883. */
  26884. readonly depthTexture: Texture;
  26885. /**
  26886. * Set the wrapping mode on U of all the textures we are rendering to.
  26887. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26888. */
  26889. wrapU: number;
  26890. /**
  26891. * Set the wrapping mode on V of all the textures we are rendering to.
  26892. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26893. */
  26894. wrapV: number;
  26895. /**
  26896. * Instantiate a new multi render target texture.
  26897. * A multi render target, like a render target provides the ability to render to a texture.
  26898. * Unlike the render target, it can render to several draw buffers in one draw.
  26899. * This is specially interesting in deferred rendering or for any effects requiring more than
  26900. * just one color from a single pass.
  26901. * @param name Define the name of the texture
  26902. * @param size Define the size of the buffers to render to
  26903. * @param count Define the number of target we are rendering into
  26904. * @param scene Define the scene the texture belongs to
  26905. * @param options Define the options used to create the multi render target
  26906. */
  26907. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26908. /** @hidden */
  26909. _rebuild(): void;
  26910. private _createInternalTextures;
  26911. private _createTextures;
  26912. /**
  26913. * Define the number of samples used if MSAA is enabled.
  26914. */
  26915. samples: number;
  26916. /**
  26917. * Resize all the textures in the multi render target.
  26918. * Be carrefull as it will recreate all the data in the new texture.
  26919. * @param size Define the new size
  26920. */
  26921. resize(size: any): void;
  26922. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26923. /**
  26924. * Dispose the render targets and their associated resources
  26925. */
  26926. dispose(): void;
  26927. /**
  26928. * Release all the underlying texture used as draw buffers.
  26929. */
  26930. releaseInternalTextures(): void;
  26931. }
  26932. }
  26933. declare module "babylonjs/Audio/analyser" {
  26934. import { Scene } from "babylonjs/scene";
  26935. /**
  26936. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26938. */
  26939. export class Analyser {
  26940. /**
  26941. * Gets or sets the smoothing
  26942. * @ignorenaming
  26943. */
  26944. SMOOTHING: number;
  26945. /**
  26946. * Gets or sets the FFT table size
  26947. * @ignorenaming
  26948. */
  26949. FFT_SIZE: number;
  26950. /**
  26951. * Gets or sets the bar graph amplitude
  26952. * @ignorenaming
  26953. */
  26954. BARGRAPHAMPLITUDE: number;
  26955. /**
  26956. * Gets or sets the position of the debug canvas
  26957. * @ignorenaming
  26958. */
  26959. DEBUGCANVASPOS: {
  26960. x: number;
  26961. y: number;
  26962. };
  26963. /**
  26964. * Gets or sets the debug canvas size
  26965. * @ignorenaming
  26966. */
  26967. DEBUGCANVASSIZE: {
  26968. width: number;
  26969. height: number;
  26970. };
  26971. private _byteFreqs;
  26972. private _byteTime;
  26973. private _floatFreqs;
  26974. private _webAudioAnalyser;
  26975. private _debugCanvas;
  26976. private _debugCanvasContext;
  26977. private _scene;
  26978. private _registerFunc;
  26979. private _audioEngine;
  26980. /**
  26981. * Creates a new analyser
  26982. * @param scene defines hosting scene
  26983. */
  26984. constructor(scene: Scene);
  26985. /**
  26986. * Get the number of data values you will have to play with for the visualization
  26987. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26988. * @returns a number
  26989. */
  26990. getFrequencyBinCount(): number;
  26991. /**
  26992. * Gets the current frequency data as a byte array
  26993. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26994. * @returns a Uint8Array
  26995. */
  26996. getByteFrequencyData(): Uint8Array;
  26997. /**
  26998. * Gets the current waveform as a byte array
  26999. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27000. * @returns a Uint8Array
  27001. */
  27002. getByteTimeDomainData(): Uint8Array;
  27003. /**
  27004. * Gets the current frequency data as a float array
  27005. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27006. * @returns a Float32Array
  27007. */
  27008. getFloatFrequencyData(): Float32Array;
  27009. /**
  27010. * Renders the debug canvas
  27011. */
  27012. drawDebugCanvas(): void;
  27013. /**
  27014. * Stops rendering the debug canvas and removes it
  27015. */
  27016. stopDebugCanvas(): void;
  27017. /**
  27018. * Connects two audio nodes
  27019. * @param inputAudioNode defines first node to connect
  27020. * @param outputAudioNode defines second node to connect
  27021. */
  27022. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27023. /**
  27024. * Releases all associated resources
  27025. */
  27026. dispose(): void;
  27027. }
  27028. }
  27029. declare module "babylonjs/Audio/audioEngine" {
  27030. import { IDisposable } from "babylonjs/scene";
  27031. import { Analyser } from "babylonjs/Audio/analyser";
  27032. import { Nullable } from "babylonjs/types";
  27033. import { Observable } from "babylonjs/Misc/observable";
  27034. /**
  27035. * This represents an audio engine and it is responsible
  27036. * to play, synchronize and analyse sounds throughout the application.
  27037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27038. */
  27039. export interface IAudioEngine extends IDisposable {
  27040. /**
  27041. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27042. */
  27043. readonly canUseWebAudio: boolean;
  27044. /**
  27045. * Gets the current AudioContext if available.
  27046. */
  27047. readonly audioContext: Nullable<AudioContext>;
  27048. /**
  27049. * The master gain node defines the global audio volume of your audio engine.
  27050. */
  27051. readonly masterGain: GainNode;
  27052. /**
  27053. * Gets whether or not mp3 are supported by your browser.
  27054. */
  27055. readonly isMP3supported: boolean;
  27056. /**
  27057. * Gets whether or not ogg are supported by your browser.
  27058. */
  27059. readonly isOGGsupported: boolean;
  27060. /**
  27061. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27062. * @ignoreNaming
  27063. */
  27064. WarnedWebAudioUnsupported: boolean;
  27065. /**
  27066. * Defines if the audio engine relies on a custom unlocked button.
  27067. * In this case, the embedded button will not be displayed.
  27068. */
  27069. useCustomUnlockedButton: boolean;
  27070. /**
  27071. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27072. */
  27073. readonly unlocked: boolean;
  27074. /**
  27075. * Event raised when audio has been unlocked on the browser.
  27076. */
  27077. onAudioUnlockedObservable: Observable<AudioEngine>;
  27078. /**
  27079. * Event raised when audio has been locked on the browser.
  27080. */
  27081. onAudioLockedObservable: Observable<AudioEngine>;
  27082. /**
  27083. * Flags the audio engine in Locked state.
  27084. * This happens due to new browser policies preventing audio to autoplay.
  27085. */
  27086. lock(): void;
  27087. /**
  27088. * Unlocks the audio engine once a user action has been done on the dom.
  27089. * This is helpful to resume play once browser policies have been satisfied.
  27090. */
  27091. unlock(): void;
  27092. }
  27093. /**
  27094. * This represents the default audio engine used in babylon.
  27095. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27097. */
  27098. export class AudioEngine implements IAudioEngine {
  27099. private _audioContext;
  27100. private _audioContextInitialized;
  27101. private _muteButton;
  27102. private _hostElement;
  27103. /**
  27104. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27105. */
  27106. canUseWebAudio: boolean;
  27107. /**
  27108. * The master gain node defines the global audio volume of your audio engine.
  27109. */
  27110. masterGain: GainNode;
  27111. /**
  27112. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27113. * @ignoreNaming
  27114. */
  27115. WarnedWebAudioUnsupported: boolean;
  27116. /**
  27117. * Gets whether or not mp3 are supported by your browser.
  27118. */
  27119. isMP3supported: boolean;
  27120. /**
  27121. * Gets whether or not ogg are supported by your browser.
  27122. */
  27123. isOGGsupported: boolean;
  27124. /**
  27125. * Gets whether audio has been unlocked on the device.
  27126. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27127. * a user interaction has happened.
  27128. */
  27129. unlocked: boolean;
  27130. /**
  27131. * Defines if the audio engine relies on a custom unlocked button.
  27132. * In this case, the embedded button will not be displayed.
  27133. */
  27134. useCustomUnlockedButton: boolean;
  27135. /**
  27136. * Event raised when audio has been unlocked on the browser.
  27137. */
  27138. onAudioUnlockedObservable: Observable<AudioEngine>;
  27139. /**
  27140. * Event raised when audio has been locked on the browser.
  27141. */
  27142. onAudioLockedObservable: Observable<AudioEngine>;
  27143. /**
  27144. * Gets the current AudioContext if available.
  27145. */
  27146. readonly audioContext: Nullable<AudioContext>;
  27147. private _connectedAnalyser;
  27148. /**
  27149. * Instantiates a new audio engine.
  27150. *
  27151. * There should be only one per page as some browsers restrict the number
  27152. * of audio contexts you can create.
  27153. * @param hostElement defines the host element where to display the mute icon if necessary
  27154. */
  27155. constructor(hostElement?: Nullable<HTMLElement>);
  27156. /**
  27157. * Flags the audio engine in Locked state.
  27158. * This happens due to new browser policies preventing audio to autoplay.
  27159. */
  27160. lock(): void;
  27161. /**
  27162. * Unlocks the audio engine once a user action has been done on the dom.
  27163. * This is helpful to resume play once browser policies have been satisfied.
  27164. */
  27165. unlock(): void;
  27166. private _resumeAudioContext;
  27167. private _initializeAudioContext;
  27168. private _tryToRun;
  27169. private _triggerRunningState;
  27170. private _triggerSuspendedState;
  27171. private _displayMuteButton;
  27172. private _moveButtonToTopLeft;
  27173. private _onResize;
  27174. private _hideMuteButton;
  27175. /**
  27176. * Destroy and release the resources associated with the audio ccontext.
  27177. */
  27178. dispose(): void;
  27179. /**
  27180. * Gets the global volume sets on the master gain.
  27181. * @returns the global volume if set or -1 otherwise
  27182. */
  27183. getGlobalVolume(): number;
  27184. /**
  27185. * Sets the global volume of your experience (sets on the master gain).
  27186. * @param newVolume Defines the new global volume of the application
  27187. */
  27188. setGlobalVolume(newVolume: number): void;
  27189. /**
  27190. * Connect the audio engine to an audio analyser allowing some amazing
  27191. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27193. * @param analyser The analyser to connect to the engine
  27194. */
  27195. connectToAnalyser(analyser: Analyser): void;
  27196. }
  27197. }
  27198. declare module "babylonjs/Loading/loadingScreen" {
  27199. /**
  27200. * Interface used to present a loading screen while loading a scene
  27201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27202. */
  27203. export interface ILoadingScreen {
  27204. /**
  27205. * Function called to display the loading screen
  27206. */
  27207. displayLoadingUI: () => void;
  27208. /**
  27209. * Function called to hide the loading screen
  27210. */
  27211. hideLoadingUI: () => void;
  27212. /**
  27213. * Gets or sets the color to use for the background
  27214. */
  27215. loadingUIBackgroundColor: string;
  27216. /**
  27217. * Gets or sets the text to display while loading
  27218. */
  27219. loadingUIText: string;
  27220. }
  27221. /**
  27222. * Class used for the default loading screen
  27223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27224. */
  27225. export class DefaultLoadingScreen implements ILoadingScreen {
  27226. private _renderingCanvas;
  27227. private _loadingText;
  27228. private _loadingDivBackgroundColor;
  27229. private _loadingDiv;
  27230. private _loadingTextDiv;
  27231. /**
  27232. * Creates a new default loading screen
  27233. * @param _renderingCanvas defines the canvas used to render the scene
  27234. * @param _loadingText defines the default text to display
  27235. * @param _loadingDivBackgroundColor defines the default background color
  27236. */
  27237. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27238. /**
  27239. * Function called to display the loading screen
  27240. */
  27241. displayLoadingUI(): void;
  27242. /**
  27243. * Function called to hide the loading screen
  27244. */
  27245. hideLoadingUI(): void;
  27246. /**
  27247. * Gets or sets the text to display while loading
  27248. */
  27249. loadingUIText: string;
  27250. /**
  27251. * Gets or sets the color to use for the background
  27252. */
  27253. loadingUIBackgroundColor: string;
  27254. private _resizeLoadingUI;
  27255. }
  27256. }
  27257. declare module "babylonjs/Materials/Textures/videoTexture" {
  27258. import { Observable } from "babylonjs/Misc/observable";
  27259. import { Nullable } from "babylonjs/types";
  27260. import { Scene } from "babylonjs/scene";
  27261. import { Texture } from "babylonjs/Materials/Textures/texture";
  27262. /**
  27263. * Settings for finer control over video usage
  27264. */
  27265. export interface VideoTextureSettings {
  27266. /**
  27267. * Applies `autoplay` to video, if specified
  27268. */
  27269. autoPlay?: boolean;
  27270. /**
  27271. * Applies `loop` to video, if specified
  27272. */
  27273. loop?: boolean;
  27274. /**
  27275. * Automatically updates internal texture from video at every frame in the render loop
  27276. */
  27277. autoUpdateTexture: boolean;
  27278. /**
  27279. * Image src displayed during the video loading or until the user interacts with the video.
  27280. */
  27281. poster?: string;
  27282. }
  27283. /**
  27284. * If you want to display a video in your scene, this is the special texture for that.
  27285. * This special texture works similar to other textures, with the exception of a few parameters.
  27286. * @see https://doc.babylonjs.com/how_to/video_texture
  27287. */
  27288. export class VideoTexture extends Texture {
  27289. /**
  27290. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27291. */
  27292. readonly autoUpdateTexture: boolean;
  27293. /**
  27294. * The video instance used by the texture internally
  27295. */
  27296. readonly video: HTMLVideoElement;
  27297. private _onUserActionRequestedObservable;
  27298. /**
  27299. * Event triggerd when a dom action is required by the user to play the video.
  27300. * This happens due to recent changes in browser policies preventing video to auto start.
  27301. */
  27302. readonly onUserActionRequestedObservable: Observable<Texture>;
  27303. private _generateMipMaps;
  27304. private _engine;
  27305. private _stillImageCaptured;
  27306. private _displayingPosterTexture;
  27307. private _settings;
  27308. private _createInternalTextureOnEvent;
  27309. /**
  27310. * Creates a video texture.
  27311. * If you want to display a video in your scene, this is the special texture for that.
  27312. * This special texture works similar to other textures, with the exception of a few parameters.
  27313. * @see https://doc.babylonjs.com/how_to/video_texture
  27314. * @param name optional name, will detect from video source, if not defined
  27315. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27316. * @param scene is obviously the current scene.
  27317. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27318. * @param invertY is false by default but can be used to invert video on Y axis
  27319. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27320. * @param settings allows finer control over video usage
  27321. */
  27322. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27323. private _getName;
  27324. private _getVideo;
  27325. private _createInternalTexture;
  27326. private reset;
  27327. /**
  27328. * @hidden Internal method to initiate `update`.
  27329. */
  27330. _rebuild(): void;
  27331. /**
  27332. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27333. */
  27334. update(): void;
  27335. /**
  27336. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27337. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27338. */
  27339. updateTexture(isVisible: boolean): void;
  27340. protected _updateInternalTexture: () => void;
  27341. /**
  27342. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27343. * @param url New url.
  27344. */
  27345. updateURL(url: string): void;
  27346. /**
  27347. * Dispose the texture and release its associated resources.
  27348. */
  27349. dispose(): void;
  27350. /**
  27351. * Creates a video texture straight from a stream.
  27352. * @param scene Define the scene the texture should be created in
  27353. * @param stream Define the stream the texture should be created from
  27354. * @returns The created video texture as a promise
  27355. */
  27356. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27357. /**
  27358. * Creates a video texture straight from your WebCam video feed.
  27359. * @param scene Define the scene the texture should be created in
  27360. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27361. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27362. * @returns The created video texture as a promise
  27363. */
  27364. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27365. minWidth: number;
  27366. maxWidth: number;
  27367. minHeight: number;
  27368. maxHeight: number;
  27369. deviceId: string;
  27370. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27371. /**
  27372. * Creates a video texture straight from your WebCam video feed.
  27373. * @param scene Define the scene the texture should be created in
  27374. * @param onReady Define a callback to triggered once the texture will be ready
  27375. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27376. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27377. */
  27378. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27379. minWidth: number;
  27380. maxWidth: number;
  27381. minHeight: number;
  27382. maxHeight: number;
  27383. deviceId: string;
  27384. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27385. }
  27386. }
  27387. declare module "babylonjs/Engines/engine" {
  27388. import { Observable } from "babylonjs/Misc/observable";
  27389. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27390. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27391. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27392. import { Camera } from "babylonjs/Cameras/camera";
  27393. import { Scene } from "babylonjs/scene";
  27394. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27395. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27396. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27397. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27398. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27399. import { Material } from "babylonjs/Materials/material";
  27400. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27401. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27403. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27404. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27405. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27406. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27407. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27408. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27409. import { WebRequest } from "babylonjs/Misc/webRequest";
  27410. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27411. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27412. /**
  27413. * Interface for attribute information associated with buffer instanciation
  27414. */
  27415. export class InstancingAttributeInfo {
  27416. /**
  27417. * Index/offset of the attribute in the vertex shader
  27418. */
  27419. index: number;
  27420. /**
  27421. * size of the attribute, 1, 2, 3 or 4
  27422. */
  27423. attributeSize: number;
  27424. /**
  27425. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27426. * default is FLOAT
  27427. */
  27428. attribyteType: number;
  27429. /**
  27430. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27431. */
  27432. normalized: boolean;
  27433. /**
  27434. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27435. */
  27436. offset: number;
  27437. /**
  27438. * Name of the GLSL attribute, for debugging purpose only
  27439. */
  27440. attributeName: string;
  27441. }
  27442. /**
  27443. * Define options used to create a depth texture
  27444. */
  27445. export class DepthTextureCreationOptions {
  27446. /** Specifies whether or not a stencil should be allocated in the texture */
  27447. generateStencil?: boolean;
  27448. /** Specifies whether or not bilinear filtering is enable on the texture */
  27449. bilinearFiltering?: boolean;
  27450. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27451. comparisonFunction?: number;
  27452. /** Specifies if the created texture is a cube texture */
  27453. isCube?: boolean;
  27454. }
  27455. /**
  27456. * Class used to describe the capabilities of the engine relatively to the current browser
  27457. */
  27458. export class EngineCapabilities {
  27459. /** Maximum textures units per fragment shader */
  27460. maxTexturesImageUnits: number;
  27461. /** Maximum texture units per vertex shader */
  27462. maxVertexTextureImageUnits: number;
  27463. /** Maximum textures units in the entire pipeline */
  27464. maxCombinedTexturesImageUnits: number;
  27465. /** Maximum texture size */
  27466. maxTextureSize: number;
  27467. /** Maximum cube texture size */
  27468. maxCubemapTextureSize: number;
  27469. /** Maximum render texture size */
  27470. maxRenderTextureSize: number;
  27471. /** Maximum number of vertex attributes */
  27472. maxVertexAttribs: number;
  27473. /** Maximum number of varyings */
  27474. maxVaryingVectors: number;
  27475. /** Maximum number of uniforms per vertex shader */
  27476. maxVertexUniformVectors: number;
  27477. /** Maximum number of uniforms per fragment shader */
  27478. maxFragmentUniformVectors: number;
  27479. /** Defines if standard derivates (dx/dy) are supported */
  27480. standardDerivatives: boolean;
  27481. /** Defines if s3tc texture compression is supported */
  27482. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27483. /** Defines if pvrtc texture compression is supported */
  27484. pvrtc: any;
  27485. /** Defines if etc1 texture compression is supported */
  27486. etc1: any;
  27487. /** Defines if etc2 texture compression is supported */
  27488. etc2: any;
  27489. /** Defines if astc texture compression is supported */
  27490. astc: any;
  27491. /** Defines if float textures are supported */
  27492. textureFloat: boolean;
  27493. /** Defines if vertex array objects are supported */
  27494. vertexArrayObject: boolean;
  27495. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27496. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27497. /** Gets the maximum level of anisotropy supported */
  27498. maxAnisotropy: number;
  27499. /** Defines if instancing is supported */
  27500. instancedArrays: boolean;
  27501. /** Defines if 32 bits indices are supported */
  27502. uintIndices: boolean;
  27503. /** Defines if high precision shaders are supported */
  27504. highPrecisionShaderSupported: boolean;
  27505. /** Defines if depth reading in the fragment shader is supported */
  27506. fragmentDepthSupported: boolean;
  27507. /** Defines if float texture linear filtering is supported*/
  27508. textureFloatLinearFiltering: boolean;
  27509. /** Defines if rendering to float textures is supported */
  27510. textureFloatRender: boolean;
  27511. /** Defines if half float textures are supported*/
  27512. textureHalfFloat: boolean;
  27513. /** Defines if half float texture linear filtering is supported*/
  27514. textureHalfFloatLinearFiltering: boolean;
  27515. /** Defines if rendering to half float textures is supported */
  27516. textureHalfFloatRender: boolean;
  27517. /** Defines if textureLOD shader command is supported */
  27518. textureLOD: boolean;
  27519. /** Defines if draw buffers extension is supported */
  27520. drawBuffersExtension: boolean;
  27521. /** Defines if depth textures are supported */
  27522. depthTextureExtension: boolean;
  27523. /** Defines if float color buffer are supported */
  27524. colorBufferFloat: boolean;
  27525. /** Gets disjoint timer query extension (null if not supported) */
  27526. timerQuery: EXT_disjoint_timer_query;
  27527. /** Defines if timestamp can be used with timer query */
  27528. canUseTimestampForTimerQuery: boolean;
  27529. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27530. multiview: any;
  27531. /** Function used to let the system compiles shaders in background */
  27532. parallelShaderCompile: {
  27533. COMPLETION_STATUS_KHR: number;
  27534. };
  27535. }
  27536. /** Interface defining initialization parameters for Engine class */
  27537. export interface EngineOptions extends WebGLContextAttributes {
  27538. /**
  27539. * Defines if the engine should no exceed a specified device ratio
  27540. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27541. */
  27542. limitDeviceRatio?: number;
  27543. /**
  27544. * Defines if webvr should be enabled automatically
  27545. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27546. */
  27547. autoEnableWebVR?: boolean;
  27548. /**
  27549. * Defines if webgl2 should be turned off even if supported
  27550. * @see http://doc.babylonjs.com/features/webgl2
  27551. */
  27552. disableWebGL2Support?: boolean;
  27553. /**
  27554. * Defines if webaudio should be initialized as well
  27555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27556. */
  27557. audioEngine?: boolean;
  27558. /**
  27559. * Defines if animations should run using a deterministic lock step
  27560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27561. */
  27562. deterministicLockstep?: boolean;
  27563. /** Defines the maximum steps to use with deterministic lock step mode */
  27564. lockstepMaxSteps?: number;
  27565. /**
  27566. * Defines that engine should ignore context lost events
  27567. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27568. */
  27569. doNotHandleContextLost?: boolean;
  27570. /**
  27571. * Defines that engine should ignore modifying touch action attribute and style
  27572. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27573. */
  27574. doNotHandleTouchAction?: boolean;
  27575. /**
  27576. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27577. */
  27578. useHighPrecisionFloats?: boolean;
  27579. }
  27580. /**
  27581. * Defines the interface used by display changed events
  27582. */
  27583. export interface IDisplayChangedEventArgs {
  27584. /** Gets the vrDisplay object (if any) */
  27585. vrDisplay: Nullable<any>;
  27586. /** Gets a boolean indicating if webVR is supported */
  27587. vrSupported: boolean;
  27588. }
  27589. /**
  27590. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27591. */
  27592. export class Engine {
  27593. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27594. static ExceptionList: ({
  27595. key: string;
  27596. capture: string;
  27597. captureConstraint: number;
  27598. targets: string[];
  27599. } | {
  27600. key: string;
  27601. capture: null;
  27602. captureConstraint: null;
  27603. targets: string[];
  27604. })[];
  27605. /** Gets the list of created engines */
  27606. static readonly Instances: Engine[];
  27607. /**
  27608. * Gets the latest created engine
  27609. */
  27610. static readonly LastCreatedEngine: Nullable<Engine>;
  27611. /**
  27612. * Gets the latest created scene
  27613. */
  27614. static readonly LastCreatedScene: Nullable<Scene>;
  27615. /**
  27616. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27617. * @param flag defines which part of the materials must be marked as dirty
  27618. * @param predicate defines a predicate used to filter which materials should be affected
  27619. */
  27620. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27621. /**
  27622. * Hidden
  27623. */
  27624. static _TextureLoaders: IInternalTextureLoader[];
  27625. /** Defines that alpha blending is disabled */
  27626. static readonly ALPHA_DISABLE: number;
  27627. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27628. static readonly ALPHA_ADD: number;
  27629. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27630. static readonly ALPHA_COMBINE: number;
  27631. /** Defines that alpha blending to DEST - SRC * DEST */
  27632. static readonly ALPHA_SUBTRACT: number;
  27633. /** Defines that alpha blending to SRC * DEST */
  27634. static readonly ALPHA_MULTIPLY: number;
  27635. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27636. static readonly ALPHA_MAXIMIZED: number;
  27637. /** Defines that alpha blending to SRC + DEST */
  27638. static readonly ALPHA_ONEONE: number;
  27639. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27640. static readonly ALPHA_PREMULTIPLIED: number;
  27641. /**
  27642. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27643. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27644. */
  27645. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27646. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27647. static readonly ALPHA_INTERPOLATE: number;
  27648. /**
  27649. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27650. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27651. */
  27652. static readonly ALPHA_SCREENMODE: number;
  27653. /** Defines that the ressource is not delayed*/
  27654. static readonly DELAYLOADSTATE_NONE: number;
  27655. /** Defines that the ressource was successfully delay loaded */
  27656. static readonly DELAYLOADSTATE_LOADED: number;
  27657. /** Defines that the ressource is currently delay loading */
  27658. static readonly DELAYLOADSTATE_LOADING: number;
  27659. /** Defines that the ressource is delayed and has not started loading */
  27660. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27661. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27662. static readonly NEVER: number;
  27663. /** 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 */
  27664. static readonly ALWAYS: number;
  27665. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27666. static readonly LESS: number;
  27667. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27668. static readonly EQUAL: number;
  27669. /** 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 */
  27670. static readonly LEQUAL: number;
  27671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27672. static readonly GREATER: number;
  27673. /** 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 */
  27674. static readonly GEQUAL: number;
  27675. /** 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 */
  27676. static readonly NOTEQUAL: number;
  27677. /** Passed to stencilOperation to specify that stencil value must be kept */
  27678. static readonly KEEP: number;
  27679. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27680. static readonly REPLACE: number;
  27681. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27682. static readonly INCR: number;
  27683. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27684. static readonly DECR: number;
  27685. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27686. static readonly INVERT: number;
  27687. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27688. static readonly INCR_WRAP: number;
  27689. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27690. static readonly DECR_WRAP: number;
  27691. /** Texture is not repeating outside of 0..1 UVs */
  27692. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27693. /** Texture is repeating outside of 0..1 UVs */
  27694. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27695. /** Texture is repeating and mirrored */
  27696. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27697. /** ALPHA */
  27698. static readonly TEXTUREFORMAT_ALPHA: number;
  27699. /** LUMINANCE */
  27700. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27701. /** LUMINANCE_ALPHA */
  27702. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27703. /** RGB */
  27704. static readonly TEXTUREFORMAT_RGB: number;
  27705. /** RGBA */
  27706. static readonly TEXTUREFORMAT_RGBA: number;
  27707. /** RED */
  27708. static readonly TEXTUREFORMAT_RED: number;
  27709. /** RED (2nd reference) */
  27710. static readonly TEXTUREFORMAT_R: number;
  27711. /** RG */
  27712. static readonly TEXTUREFORMAT_RG: number;
  27713. /** RED_INTEGER */
  27714. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27715. /** RED_INTEGER (2nd reference) */
  27716. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27717. /** RG_INTEGER */
  27718. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27719. /** RGB_INTEGER */
  27720. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27721. /** RGBA_INTEGER */
  27722. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27723. /** UNSIGNED_BYTE */
  27724. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27725. /** UNSIGNED_BYTE (2nd reference) */
  27726. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27727. /** FLOAT */
  27728. static readonly TEXTURETYPE_FLOAT: number;
  27729. /** HALF_FLOAT */
  27730. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27731. /** BYTE */
  27732. static readonly TEXTURETYPE_BYTE: number;
  27733. /** SHORT */
  27734. static readonly TEXTURETYPE_SHORT: number;
  27735. /** UNSIGNED_SHORT */
  27736. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27737. /** INT */
  27738. static readonly TEXTURETYPE_INT: number;
  27739. /** UNSIGNED_INT */
  27740. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27741. /** UNSIGNED_SHORT_4_4_4_4 */
  27742. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27743. /** UNSIGNED_SHORT_5_5_5_1 */
  27744. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27745. /** UNSIGNED_SHORT_5_6_5 */
  27746. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27747. /** UNSIGNED_INT_2_10_10_10_REV */
  27748. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27749. /** UNSIGNED_INT_24_8 */
  27750. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27751. /** UNSIGNED_INT_10F_11F_11F_REV */
  27752. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27753. /** UNSIGNED_INT_5_9_9_9_REV */
  27754. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27755. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27756. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27757. /** nearest is mag = nearest and min = nearest and mip = linear */
  27758. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27759. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27760. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27761. /** Trilinear is mag = linear and min = linear and mip = linear */
  27762. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27763. /** nearest is mag = nearest and min = nearest and mip = linear */
  27764. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27765. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27766. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27767. /** Trilinear is mag = linear and min = linear and mip = linear */
  27768. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27769. /** mag = nearest and min = nearest and mip = nearest */
  27770. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27771. /** mag = nearest and min = linear and mip = nearest */
  27772. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27773. /** mag = nearest and min = linear and mip = linear */
  27774. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27775. /** mag = nearest and min = linear and mip = none */
  27776. static readonly TEXTURE_NEAREST_LINEAR: number;
  27777. /** mag = nearest and min = nearest and mip = none */
  27778. static readonly TEXTURE_NEAREST_NEAREST: number;
  27779. /** mag = linear and min = nearest and mip = nearest */
  27780. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27781. /** mag = linear and min = nearest and mip = linear */
  27782. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27783. /** mag = linear and min = linear and mip = none */
  27784. static readonly TEXTURE_LINEAR_LINEAR: number;
  27785. /** mag = linear and min = nearest and mip = none */
  27786. static readonly TEXTURE_LINEAR_NEAREST: number;
  27787. /** Explicit coordinates mode */
  27788. static readonly TEXTURE_EXPLICIT_MODE: number;
  27789. /** Spherical coordinates mode */
  27790. static readonly TEXTURE_SPHERICAL_MODE: number;
  27791. /** Planar coordinates mode */
  27792. static readonly TEXTURE_PLANAR_MODE: number;
  27793. /** Cubic coordinates mode */
  27794. static readonly TEXTURE_CUBIC_MODE: number;
  27795. /** Projection coordinates mode */
  27796. static readonly TEXTURE_PROJECTION_MODE: number;
  27797. /** Skybox coordinates mode */
  27798. static readonly TEXTURE_SKYBOX_MODE: number;
  27799. /** Inverse Cubic coordinates mode */
  27800. static readonly TEXTURE_INVCUBIC_MODE: number;
  27801. /** Equirectangular coordinates mode */
  27802. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27803. /** Equirectangular Fixed coordinates mode */
  27804. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27805. /** Equirectangular Fixed Mirrored coordinates mode */
  27806. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27807. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27808. static readonly SCALEMODE_FLOOR: number;
  27809. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27810. static readonly SCALEMODE_NEAREST: number;
  27811. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27812. static readonly SCALEMODE_CEILING: number;
  27813. /**
  27814. * Returns the current npm package of the sdk
  27815. */
  27816. static readonly NpmPackage: string;
  27817. /**
  27818. * Returns the current version of the framework
  27819. */
  27820. static readonly Version: string;
  27821. /**
  27822. * Returns a string describing the current engine
  27823. */
  27824. readonly description: string;
  27825. /**
  27826. * Gets or sets the epsilon value used by collision engine
  27827. */
  27828. static CollisionsEpsilon: number;
  27829. /**
  27830. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27831. */
  27832. static ShadersRepository: string;
  27833. /**
  27834. * Method called to create the default loading screen.
  27835. * This can be overriden in your own app.
  27836. * @param canvas The rendering canvas element
  27837. * @returns The loading screen
  27838. */
  27839. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27840. /**
  27841. * Method called to create the default rescale post process on each engine.
  27842. */
  27843. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27844. /**
  27845. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27846. */
  27847. forcePOTTextures: boolean;
  27848. /**
  27849. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27850. */
  27851. isFullscreen: boolean;
  27852. /**
  27853. * Gets a boolean indicating if the pointer is currently locked
  27854. */
  27855. isPointerLock: boolean;
  27856. /**
  27857. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27858. */
  27859. cullBackFaces: boolean;
  27860. /**
  27861. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27862. */
  27863. renderEvenInBackground: boolean;
  27864. /**
  27865. * Gets or sets a boolean indicating that cache can be kept between frames
  27866. */
  27867. preventCacheWipeBetweenFrames: boolean;
  27868. /**
  27869. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27870. **/
  27871. enableOfflineSupport: boolean;
  27872. /**
  27873. * 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)
  27874. **/
  27875. disableManifestCheck: boolean;
  27876. /**
  27877. * Gets the list of created scenes
  27878. */
  27879. scenes: Scene[];
  27880. /**
  27881. * Event raised when a new scene is created
  27882. */
  27883. onNewSceneAddedObservable: Observable<Scene>;
  27884. /**
  27885. * Gets the list of created postprocesses
  27886. */
  27887. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27888. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27889. validateShaderPrograms: boolean;
  27890. /**
  27891. * Observable event triggered each time the rendering canvas is resized
  27892. */
  27893. onResizeObservable: Observable<Engine>;
  27894. /**
  27895. * Observable event triggered each time the canvas loses focus
  27896. */
  27897. onCanvasBlurObservable: Observable<Engine>;
  27898. /**
  27899. * Observable event triggered each time the canvas gains focus
  27900. */
  27901. onCanvasFocusObservable: Observable<Engine>;
  27902. /**
  27903. * Observable event triggered each time the canvas receives pointerout event
  27904. */
  27905. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27906. /**
  27907. * Observable event triggered before each texture is initialized
  27908. */
  27909. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27910. private _vrDisplay;
  27911. private _vrSupported;
  27912. private _oldSize;
  27913. private _oldHardwareScaleFactor;
  27914. private _vrExclusivePointerMode;
  27915. private _webVRInitPromise;
  27916. /**
  27917. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27918. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27919. */
  27920. readonly isInVRExclusivePointerMode: boolean;
  27921. /**
  27922. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27923. */
  27924. disableUniformBuffers: boolean;
  27925. /** @hidden */
  27926. _uniformBuffers: UniformBuffer[];
  27927. /**
  27928. * Gets a boolean indicating that the engine supports uniform buffers
  27929. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27930. */
  27931. readonly supportsUniformBuffers: boolean;
  27932. /**
  27933. * Observable raised when the engine begins a new frame
  27934. */
  27935. onBeginFrameObservable: Observable<Engine>;
  27936. /**
  27937. * If set, will be used to request the next animation frame for the render loop
  27938. */
  27939. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27940. /**
  27941. * Observable raised when the engine ends the current frame
  27942. */
  27943. onEndFrameObservable: Observable<Engine>;
  27944. /**
  27945. * Observable raised when the engine is about to compile a shader
  27946. */
  27947. onBeforeShaderCompilationObservable: Observable<Engine>;
  27948. /**
  27949. * Observable raised when the engine has jsut compiled a shader
  27950. */
  27951. onAfterShaderCompilationObservable: Observable<Engine>;
  27952. /** @hidden */
  27953. _gl: WebGLRenderingContext;
  27954. private _renderingCanvas;
  27955. private _windowIsBackground;
  27956. private _webGLVersion;
  27957. protected _highPrecisionShadersAllowed: boolean;
  27958. /** @hidden */
  27959. readonly _shouldUseHighPrecisionShader: boolean;
  27960. /**
  27961. * Gets a boolean indicating that only power of 2 textures are supported
  27962. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27963. */
  27964. readonly needPOTTextures: boolean;
  27965. /** @hidden */
  27966. _badOS: boolean;
  27967. /** @hidden */
  27968. _badDesktopOS: boolean;
  27969. /**
  27970. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27971. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27972. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27973. */
  27974. disableTextureBindingOptimization: boolean;
  27975. /**
  27976. * Gets the audio engine
  27977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27978. * @ignorenaming
  27979. */
  27980. static audioEngine: IAudioEngine;
  27981. /**
  27982. * Default AudioEngine factory responsible of creating the Audio Engine.
  27983. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27984. */
  27985. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27986. /**
  27987. * Default offline support factory responsible of creating a tool used to store data locally.
  27988. * By default, this will create a Database object if the workload has been embedded.
  27989. */
  27990. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27991. private _onFocus;
  27992. private _onBlur;
  27993. private _onCanvasPointerOut;
  27994. private _onCanvasBlur;
  27995. private _onCanvasFocus;
  27996. private _onFullscreenChange;
  27997. private _onPointerLockChange;
  27998. private _onVRDisplayPointerRestricted;
  27999. private _onVRDisplayPointerUnrestricted;
  28000. private _onVrDisplayConnect;
  28001. private _onVrDisplayDisconnect;
  28002. private _onVrDisplayPresentChange;
  28003. /**
  28004. * Observable signaled when VR display mode changes
  28005. */
  28006. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28007. /**
  28008. * Observable signaled when VR request present is complete
  28009. */
  28010. onVRRequestPresentComplete: Observable<boolean>;
  28011. /**
  28012. * Observable signaled when VR request present starts
  28013. */
  28014. onVRRequestPresentStart: Observable<Engine>;
  28015. private _hardwareScalingLevel;
  28016. /** @hidden */
  28017. protected _caps: EngineCapabilities;
  28018. private _pointerLockRequested;
  28019. private _isStencilEnable;
  28020. private _colorWrite;
  28021. private _loadingScreen;
  28022. /** @hidden */
  28023. _drawCalls: PerfCounter;
  28024. /** @hidden */
  28025. _textureCollisions: PerfCounter;
  28026. private _glVersion;
  28027. private _glRenderer;
  28028. private _glVendor;
  28029. private _videoTextureSupported;
  28030. private _renderingQueueLaunched;
  28031. private _activeRenderLoops;
  28032. private _deterministicLockstep;
  28033. private _lockstepMaxSteps;
  28034. /**
  28035. * Observable signaled when a context lost event is raised
  28036. */
  28037. onContextLostObservable: Observable<Engine>;
  28038. /**
  28039. * Observable signaled when a context restored event is raised
  28040. */
  28041. onContextRestoredObservable: Observable<Engine>;
  28042. private _onContextLost;
  28043. private _onContextRestored;
  28044. private _contextWasLost;
  28045. private _doNotHandleContextLost;
  28046. /**
  28047. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28049. */
  28050. doNotHandleContextLost: boolean;
  28051. private _performanceMonitor;
  28052. private _fps;
  28053. private _deltaTime;
  28054. /**
  28055. * Turn this value on if you want to pause FPS computation when in background
  28056. */
  28057. disablePerformanceMonitorInBackground: boolean;
  28058. /**
  28059. * Gets the performance monitor attached to this engine
  28060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28061. */
  28062. readonly performanceMonitor: PerformanceMonitor;
  28063. /** @hidden */
  28064. protected _depthCullingState: _DepthCullingState;
  28065. /** @hidden */
  28066. protected _stencilState: _StencilState;
  28067. /** @hidden */
  28068. protected _alphaState: _AlphaState;
  28069. /** @hidden */
  28070. protected _alphaMode: number;
  28071. protected _internalTexturesCache: InternalTexture[];
  28072. /** @hidden */
  28073. protected _activeChannel: number;
  28074. private _currentTextureChannel;
  28075. /** @hidden */
  28076. protected _boundTexturesCache: {
  28077. [key: string]: Nullable<InternalTexture>;
  28078. };
  28079. /** @hidden */
  28080. protected _currentEffect: Nullable<Effect>;
  28081. /** @hidden */
  28082. protected _currentProgram: Nullable<WebGLProgram>;
  28083. private _compiledEffects;
  28084. private _vertexAttribArraysEnabled;
  28085. /** @hidden */
  28086. protected _cachedViewport: Nullable<Viewport>;
  28087. private _cachedVertexArrayObject;
  28088. /** @hidden */
  28089. protected _cachedVertexBuffers: any;
  28090. /** @hidden */
  28091. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28092. /** @hidden */
  28093. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28094. /** @hidden */
  28095. protected _currentRenderTarget: Nullable<InternalTexture>;
  28096. private _uintIndicesCurrentlySet;
  28097. private _currentBoundBuffer;
  28098. /** @hidden */
  28099. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28100. private _currentBufferPointers;
  28101. private _currentInstanceLocations;
  28102. private _currentInstanceBuffers;
  28103. private _textureUnits;
  28104. private _firstBoundInternalTextureTracker;
  28105. private _lastBoundInternalTextureTracker;
  28106. private _workingCanvas;
  28107. private _workingContext;
  28108. private _rescalePostProcess;
  28109. private _dummyFramebuffer;
  28110. private _externalData;
  28111. private _bindedRenderFunction;
  28112. private _vaoRecordInProgress;
  28113. private _mustWipeVertexAttributes;
  28114. private _emptyTexture;
  28115. private _emptyCubeTexture;
  28116. private _emptyTexture3D;
  28117. /** @hidden */
  28118. _frameHandler: number;
  28119. private _nextFreeTextureSlots;
  28120. private _maxSimultaneousTextures;
  28121. private _activeRequests;
  28122. private _texturesSupported;
  28123. private _textureFormatInUse;
  28124. /**
  28125. * Gets the list of texture formats supported
  28126. */
  28127. readonly texturesSupported: Array<string>;
  28128. /**
  28129. * Gets the list of texture formats in use
  28130. */
  28131. readonly textureFormatInUse: Nullable<string>;
  28132. /**
  28133. * Gets the current viewport
  28134. */
  28135. readonly currentViewport: Nullable<Viewport>;
  28136. /**
  28137. * Gets the default empty texture
  28138. */
  28139. readonly emptyTexture: InternalTexture;
  28140. /**
  28141. * Gets the default empty 3D texture
  28142. */
  28143. readonly emptyTexture3D: InternalTexture;
  28144. /**
  28145. * Gets the default empty cube texture
  28146. */
  28147. readonly emptyCubeTexture: InternalTexture;
  28148. /**
  28149. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28150. */
  28151. readonly premultipliedAlpha: boolean;
  28152. /**
  28153. * Creates a new engine
  28154. * @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
  28155. * @param antialias defines enable antialiasing (default: false)
  28156. * @param options defines further options to be sent to the getContext() function
  28157. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28158. */
  28159. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28160. private _disableTouchAction;
  28161. private _rebuildInternalTextures;
  28162. private _rebuildEffects;
  28163. /**
  28164. * Gets a boolean indicating if all created effects are ready
  28165. * @returns true if all effects are ready
  28166. */
  28167. areAllEffectsReady(): boolean;
  28168. private _rebuildBuffers;
  28169. private _initGLContext;
  28170. /**
  28171. * Gets version of the current webGL context
  28172. */
  28173. readonly webGLVersion: number;
  28174. /**
  28175. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28176. */
  28177. readonly isStencilEnable: boolean;
  28178. private _prepareWorkingCanvas;
  28179. /**
  28180. * Reset the texture cache to empty state
  28181. */
  28182. resetTextureCache(): void;
  28183. /**
  28184. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28186. * @returns true if engine is in deterministic lock step mode
  28187. */
  28188. isDeterministicLockStep(): boolean;
  28189. /**
  28190. * Gets the max steps when engine is running in deterministic lock step
  28191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28192. * @returns the max steps
  28193. */
  28194. getLockstepMaxSteps(): number;
  28195. /**
  28196. * Gets an object containing information about the current webGL context
  28197. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28198. */
  28199. getGlInfo(): {
  28200. vendor: string;
  28201. renderer: string;
  28202. version: string;
  28203. };
  28204. /**
  28205. * Gets current aspect ratio
  28206. * @param camera defines the camera to use to get the aspect ratio
  28207. * @param useScreen defines if screen size must be used (or the current render target if any)
  28208. * @returns a number defining the aspect ratio
  28209. */
  28210. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28211. /**
  28212. * Gets current screen aspect ratio
  28213. * @returns a number defining the aspect ratio
  28214. */
  28215. getScreenAspectRatio(): number;
  28216. /**
  28217. * Gets the current render width
  28218. * @param useScreen defines if screen size must be used (or the current render target if any)
  28219. * @returns a number defining the current render width
  28220. */
  28221. getRenderWidth(useScreen?: boolean): number;
  28222. /**
  28223. * Gets the current render height
  28224. * @param useScreen defines if screen size must be used (or the current render target if any)
  28225. * @returns a number defining the current render height
  28226. */
  28227. getRenderHeight(useScreen?: boolean): number;
  28228. /**
  28229. * Gets the HTML canvas attached with the current webGL context
  28230. * @returns a HTML canvas
  28231. */
  28232. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28233. /**
  28234. * Gets the client rect of the HTML canvas attached with the current webGL context
  28235. * @returns a client rectanglee
  28236. */
  28237. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28238. /**
  28239. * Defines the hardware scaling level.
  28240. * By default the hardware scaling level is computed from the window device ratio.
  28241. * 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.
  28242. * @param level defines the level to use
  28243. */
  28244. setHardwareScalingLevel(level: number): void;
  28245. /**
  28246. * Gets the current hardware scaling level.
  28247. * By default the hardware scaling level is computed from the window device ratio.
  28248. * 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.
  28249. * @returns a number indicating the current hardware scaling level
  28250. */
  28251. getHardwareScalingLevel(): number;
  28252. /**
  28253. * Gets the list of loaded textures
  28254. * @returns an array containing all loaded textures
  28255. */
  28256. getLoadedTexturesCache(): InternalTexture[];
  28257. /**
  28258. * Gets the object containing all engine capabilities
  28259. * @returns the EngineCapabilities object
  28260. */
  28261. getCaps(): EngineCapabilities;
  28262. /**
  28263. * Gets the current depth function
  28264. * @returns a number defining the depth function
  28265. */
  28266. getDepthFunction(): Nullable<number>;
  28267. /**
  28268. * Sets the current depth function
  28269. * @param depthFunc defines the function to use
  28270. */
  28271. setDepthFunction(depthFunc: number): void;
  28272. /**
  28273. * Sets the current depth function to GREATER
  28274. */
  28275. setDepthFunctionToGreater(): void;
  28276. /**
  28277. * Sets the current depth function to GEQUAL
  28278. */
  28279. setDepthFunctionToGreaterOrEqual(): void;
  28280. /**
  28281. * Sets the current depth function to LESS
  28282. */
  28283. setDepthFunctionToLess(): void;
  28284. private _cachedStencilBuffer;
  28285. private _cachedStencilFunction;
  28286. private _cachedStencilMask;
  28287. private _cachedStencilOperationPass;
  28288. private _cachedStencilOperationFail;
  28289. private _cachedStencilOperationDepthFail;
  28290. private _cachedStencilReference;
  28291. /**
  28292. * Caches the the state of the stencil buffer
  28293. */
  28294. cacheStencilState(): void;
  28295. /**
  28296. * Restores the state of the stencil buffer
  28297. */
  28298. restoreStencilState(): void;
  28299. /**
  28300. * Sets the current depth function to LEQUAL
  28301. */
  28302. setDepthFunctionToLessOrEqual(): void;
  28303. /**
  28304. * Gets a boolean indicating if stencil buffer is enabled
  28305. * @returns the current stencil buffer state
  28306. */
  28307. getStencilBuffer(): boolean;
  28308. /**
  28309. * Enable or disable the stencil buffer
  28310. * @param enable defines if the stencil buffer must be enabled or disabled
  28311. */
  28312. setStencilBuffer(enable: boolean): void;
  28313. /**
  28314. * Gets the current stencil mask
  28315. * @returns a number defining the new stencil mask to use
  28316. */
  28317. getStencilMask(): number;
  28318. /**
  28319. * Sets the current stencil mask
  28320. * @param mask defines the new stencil mask to use
  28321. */
  28322. setStencilMask(mask: number): void;
  28323. /**
  28324. * Gets the current stencil function
  28325. * @returns a number defining the stencil function to use
  28326. */
  28327. getStencilFunction(): number;
  28328. /**
  28329. * Gets the current stencil reference value
  28330. * @returns a number defining the stencil reference value to use
  28331. */
  28332. getStencilFunctionReference(): number;
  28333. /**
  28334. * Gets the current stencil mask
  28335. * @returns a number defining the stencil mask to use
  28336. */
  28337. getStencilFunctionMask(): number;
  28338. /**
  28339. * Sets the current stencil function
  28340. * @param stencilFunc defines the new stencil function to use
  28341. */
  28342. setStencilFunction(stencilFunc: number): void;
  28343. /**
  28344. * Sets the current stencil reference
  28345. * @param reference defines the new stencil reference to use
  28346. */
  28347. setStencilFunctionReference(reference: number): void;
  28348. /**
  28349. * Sets the current stencil mask
  28350. * @param mask defines the new stencil mask to use
  28351. */
  28352. setStencilFunctionMask(mask: number): void;
  28353. /**
  28354. * Gets the current stencil operation when stencil fails
  28355. * @returns a number defining stencil operation to use when stencil fails
  28356. */
  28357. getStencilOperationFail(): number;
  28358. /**
  28359. * Gets the current stencil operation when depth fails
  28360. * @returns a number defining stencil operation to use when depth fails
  28361. */
  28362. getStencilOperationDepthFail(): number;
  28363. /**
  28364. * Gets the current stencil operation when stencil passes
  28365. * @returns a number defining stencil operation to use when stencil passes
  28366. */
  28367. getStencilOperationPass(): number;
  28368. /**
  28369. * Sets the stencil operation to use when stencil fails
  28370. * @param operation defines the stencil operation to use when stencil fails
  28371. */
  28372. setStencilOperationFail(operation: number): void;
  28373. /**
  28374. * Sets the stencil operation to use when depth fails
  28375. * @param operation defines the stencil operation to use when depth fails
  28376. */
  28377. setStencilOperationDepthFail(operation: number): void;
  28378. /**
  28379. * Sets the stencil operation to use when stencil passes
  28380. * @param operation defines the stencil operation to use when stencil passes
  28381. */
  28382. setStencilOperationPass(operation: number): void;
  28383. /**
  28384. * Sets a boolean indicating if the dithering state is enabled or disabled
  28385. * @param value defines the dithering state
  28386. */
  28387. setDitheringState(value: boolean): void;
  28388. /**
  28389. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28390. * @param value defines the rasterizer state
  28391. */
  28392. setRasterizerState(value: boolean): void;
  28393. /**
  28394. * stop executing a render loop function and remove it from the execution array
  28395. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28396. */
  28397. stopRenderLoop(renderFunction?: () => void): void;
  28398. /** @hidden */
  28399. _renderLoop(): void;
  28400. /**
  28401. * Register and execute a render loop. The engine can have more than one render function
  28402. * @param renderFunction defines the function to continuously execute
  28403. */
  28404. runRenderLoop(renderFunction: () => void): void;
  28405. /**
  28406. * Toggle full screen mode
  28407. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28408. */
  28409. switchFullscreen(requestPointerLock: boolean): void;
  28410. /**
  28411. * Enters full screen mode
  28412. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28413. */
  28414. enterFullscreen(requestPointerLock: boolean): void;
  28415. /**
  28416. * Exits full screen mode
  28417. */
  28418. exitFullscreen(): void;
  28419. /**
  28420. * Clear the current render buffer or the current render target (if any is set up)
  28421. * @param color defines the color to use
  28422. * @param backBuffer defines if the back buffer must be cleared
  28423. * @param depth defines if the depth buffer must be cleared
  28424. * @param stencil defines if the stencil buffer must be cleared
  28425. */
  28426. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28427. /**
  28428. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28429. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28430. * @param y defines the y-coordinate of the corner of the clear rectangle
  28431. * @param width defines the width of the clear rectangle
  28432. * @param height defines the height of the clear rectangle
  28433. * @param clearColor defines the clear color
  28434. */
  28435. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28436. /**
  28437. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28438. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28439. * @param y defines the y-coordinate of the corner of the clear rectangle
  28440. * @param width defines the width of the clear rectangle
  28441. * @param height defines the height of the clear rectangle
  28442. */
  28443. enableScissor(x: number, y: number, width: number, height: number): void;
  28444. /**
  28445. * Disable previously set scissor test rectangle
  28446. */
  28447. disableScissor(): void;
  28448. private _viewportCached;
  28449. /** @hidden */
  28450. _viewport(x: number, y: number, width: number, height: number): void;
  28451. /**
  28452. * Set the WebGL's viewport
  28453. * @param viewport defines the viewport element to be used
  28454. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28455. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28456. */
  28457. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28458. /**
  28459. * Directly set the WebGL Viewport
  28460. * @param x defines the x coordinate of the viewport (in screen space)
  28461. * @param y defines the y coordinate of the viewport (in screen space)
  28462. * @param width defines the width of the viewport (in screen space)
  28463. * @param height defines the height of the viewport (in screen space)
  28464. * @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
  28465. */
  28466. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28467. /**
  28468. * Begin a new frame
  28469. */
  28470. beginFrame(): void;
  28471. /**
  28472. * Enf the current frame
  28473. */
  28474. endFrame(): void;
  28475. /**
  28476. * Resize the view according to the canvas' size
  28477. */
  28478. resize(): void;
  28479. /**
  28480. * Force a specific size of the canvas
  28481. * @param width defines the new canvas' width
  28482. * @param height defines the new canvas' height
  28483. */
  28484. setSize(width: number, height: number): void;
  28485. /**
  28486. * Gets a boolean indicating if a webVR device was detected
  28487. * @returns true if a webVR device was detected
  28488. */
  28489. isVRDevicePresent(): boolean;
  28490. /**
  28491. * Gets the current webVR device
  28492. * @returns the current webVR device (or null)
  28493. */
  28494. getVRDevice(): any;
  28495. /**
  28496. * Initializes a webVR display and starts listening to display change events
  28497. * The onVRDisplayChangedObservable will be notified upon these changes
  28498. * @returns The onVRDisplayChangedObservable
  28499. */
  28500. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28501. /**
  28502. * Initializes a webVR display and starts listening to display change events
  28503. * The onVRDisplayChangedObservable will be notified upon these changes
  28504. * @returns A promise containing a VRDisplay and if vr is supported
  28505. */
  28506. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28507. /**
  28508. * Call this function to switch to webVR mode
  28509. * Will do nothing if webVR is not supported or if there is no webVR device
  28510. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28511. */
  28512. enableVR(): void;
  28513. /**
  28514. * Call this function to leave webVR mode
  28515. * Will do nothing if webVR is not supported or if there is no webVR device
  28516. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28517. */
  28518. disableVR(): void;
  28519. private _onVRFullScreenTriggered;
  28520. private _getVRDisplaysAsync;
  28521. /**
  28522. * Binds the frame buffer to the specified texture.
  28523. * @param texture The texture to render to or null for the default canvas
  28524. * @param faceIndex The face of the texture to render to in case of cube texture
  28525. * @param requiredWidth The width of the target to render to
  28526. * @param requiredHeight The height of the target to render to
  28527. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28528. * @param depthStencilTexture The depth stencil texture to use to render
  28529. * @param lodLevel defines le lod level to bind to the frame buffer
  28530. */
  28531. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28532. private bindUnboundFramebuffer;
  28533. /**
  28534. * Unbind the current render target texture from the webGL context
  28535. * @param texture defines the render target texture to unbind
  28536. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28537. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28538. */
  28539. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28540. /**
  28541. * Unbind a list of render target textures from the webGL context
  28542. * This is used only when drawBuffer extension or webGL2 are active
  28543. * @param textures defines the render target textures to unbind
  28544. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28545. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28546. */
  28547. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28548. /**
  28549. * Force the mipmap generation for the given render target texture
  28550. * @param texture defines the render target texture to use
  28551. */
  28552. generateMipMapsForCubemap(texture: InternalTexture): void;
  28553. /**
  28554. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28555. */
  28556. flushFramebuffer(): void;
  28557. /**
  28558. * Unbind the current render target and bind the default framebuffer
  28559. */
  28560. restoreDefaultFramebuffer(): void;
  28561. /**
  28562. * Create an uniform buffer
  28563. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28564. * @param elements defines the content of the uniform buffer
  28565. * @returns the webGL uniform buffer
  28566. */
  28567. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28568. /**
  28569. * Create a dynamic uniform buffer
  28570. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28571. * @param elements defines the content of the uniform buffer
  28572. * @returns the webGL uniform buffer
  28573. */
  28574. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28575. /**
  28576. * Update an existing uniform buffer
  28577. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28578. * @param uniformBuffer defines the target uniform buffer
  28579. * @param elements defines the content to update
  28580. * @param offset defines the offset in the uniform buffer where update should start
  28581. * @param count defines the size of the data to update
  28582. */
  28583. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28584. private _resetVertexBufferBinding;
  28585. /**
  28586. * Creates a vertex buffer
  28587. * @param data the data for the vertex buffer
  28588. * @returns the new WebGL static buffer
  28589. */
  28590. createVertexBuffer(data: DataArray): WebGLBuffer;
  28591. /**
  28592. * Creates a dynamic vertex buffer
  28593. * @param data the data for the dynamic vertex buffer
  28594. * @returns the new WebGL dynamic buffer
  28595. */
  28596. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28597. /**
  28598. * Update a dynamic index buffer
  28599. * @param indexBuffer defines the target index buffer
  28600. * @param indices defines the data to update
  28601. * @param offset defines the offset in the target index buffer where update should start
  28602. */
  28603. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28604. /**
  28605. * Updates a dynamic vertex buffer.
  28606. * @param vertexBuffer the vertex buffer to update
  28607. * @param data the data used to update the vertex buffer
  28608. * @param byteOffset the byte offset of the data
  28609. * @param byteLength the byte length of the data
  28610. */
  28611. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28612. private _resetIndexBufferBinding;
  28613. /**
  28614. * Creates a new index buffer
  28615. * @param indices defines the content of the index buffer
  28616. * @param updatable defines if the index buffer must be updatable
  28617. * @returns a new webGL buffer
  28618. */
  28619. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28620. /**
  28621. * Bind a webGL buffer to the webGL context
  28622. * @param buffer defines the buffer to bind
  28623. */
  28624. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28625. /**
  28626. * Bind an uniform buffer to the current webGL context
  28627. * @param buffer defines the buffer to bind
  28628. */
  28629. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28630. /**
  28631. * Bind a buffer to the current webGL context at a given location
  28632. * @param buffer defines the buffer to bind
  28633. * @param location defines the index where to bind the buffer
  28634. */
  28635. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28636. /**
  28637. * Bind a specific block at a given index in a specific shader program
  28638. * @param shaderProgram defines the shader program
  28639. * @param blockName defines the block name
  28640. * @param index defines the index where to bind the block
  28641. */
  28642. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28643. private bindIndexBuffer;
  28644. private bindBuffer;
  28645. /**
  28646. * update the bound buffer with the given data
  28647. * @param data defines the data to update
  28648. */
  28649. updateArrayBuffer(data: Float32Array): void;
  28650. private _vertexAttribPointer;
  28651. private _bindIndexBufferWithCache;
  28652. private _bindVertexBuffersAttributes;
  28653. /**
  28654. * Records a vertex array object
  28655. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28656. * @param vertexBuffers defines the list of vertex buffers to store
  28657. * @param indexBuffer defines the index buffer to store
  28658. * @param effect defines the effect to store
  28659. * @returns the new vertex array object
  28660. */
  28661. recordVertexArrayObject(vertexBuffers: {
  28662. [key: string]: VertexBuffer;
  28663. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28664. /**
  28665. * Bind a specific vertex array object
  28666. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28667. * @param vertexArrayObject defines the vertex array object to bind
  28668. * @param indexBuffer defines the index buffer to bind
  28669. */
  28670. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28671. /**
  28672. * Bind webGl buffers directly to the webGL context
  28673. * @param vertexBuffer defines the vertex buffer to bind
  28674. * @param indexBuffer defines the index buffer to bind
  28675. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28676. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28677. * @param effect defines the effect associated with the vertex buffer
  28678. */
  28679. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28680. private _unbindVertexArrayObject;
  28681. /**
  28682. * Bind a list of vertex buffers to the webGL context
  28683. * @param vertexBuffers defines the list of vertex buffers to bind
  28684. * @param indexBuffer defines the index buffer to bind
  28685. * @param effect defines the effect associated with the vertex buffers
  28686. */
  28687. bindBuffers(vertexBuffers: {
  28688. [key: string]: Nullable<VertexBuffer>;
  28689. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28690. /**
  28691. * Unbind all instance attributes
  28692. */
  28693. unbindInstanceAttributes(): void;
  28694. /**
  28695. * Release and free the memory of a vertex array object
  28696. * @param vao defines the vertex array object to delete
  28697. */
  28698. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28699. /** @hidden */
  28700. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28701. /**
  28702. * Creates a webGL buffer to use with instanciation
  28703. * @param capacity defines the size of the buffer
  28704. * @returns the webGL buffer
  28705. */
  28706. createInstancesBuffer(capacity: number): WebGLBuffer;
  28707. /**
  28708. * Delete a webGL buffer used with instanciation
  28709. * @param buffer defines the webGL buffer to delete
  28710. */
  28711. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28712. /**
  28713. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28714. * @param instancesBuffer defines the webGL buffer to update and bind
  28715. * @param data defines the data to store in the buffer
  28716. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28717. */
  28718. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28719. /**
  28720. * Apply all cached states (depth, culling, stencil and alpha)
  28721. */
  28722. applyStates(): void;
  28723. /**
  28724. * Send a draw order
  28725. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28726. * @param indexStart defines the starting index
  28727. * @param indexCount defines the number of index to draw
  28728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28729. */
  28730. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28731. /**
  28732. * Draw a list of points
  28733. * @param verticesStart defines the index of first vertex to draw
  28734. * @param verticesCount defines the count of vertices to draw
  28735. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28736. */
  28737. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28738. /**
  28739. * Draw a list of unindexed primitives
  28740. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28741. * @param verticesStart defines the index of first vertex to draw
  28742. * @param verticesCount defines the count of vertices to draw
  28743. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28744. */
  28745. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28746. /**
  28747. * Draw a list of indexed primitives
  28748. * @param fillMode defines the primitive to use
  28749. * @param indexStart defines the starting index
  28750. * @param indexCount defines the number of index to draw
  28751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28752. */
  28753. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28754. /**
  28755. * Draw a list of unindexed primitives
  28756. * @param fillMode defines the primitive to use
  28757. * @param verticesStart defines the index of first vertex to draw
  28758. * @param verticesCount defines the count of vertices to draw
  28759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28760. */
  28761. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28762. private _drawMode;
  28763. /** @hidden */
  28764. _releaseEffect(effect: Effect): void;
  28765. /** @hidden */
  28766. _deleteProgram(program: WebGLProgram): void;
  28767. /**
  28768. * Create a new effect (used to store vertex/fragment shaders)
  28769. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28770. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28771. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28772. * @param samplers defines an array of string used to represent textures
  28773. * @param defines defines the string containing the defines to use to compile the shaders
  28774. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28775. * @param onCompiled defines a function to call when the effect creation is successful
  28776. * @param onError defines a function to call when the effect creation has failed
  28777. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28778. * @returns the new Effect
  28779. */
  28780. 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;
  28781. private _compileShader;
  28782. private _compileRawShader;
  28783. /**
  28784. * Directly creates a webGL program
  28785. * @param vertexCode defines the vertex shader code to use
  28786. * @param fragmentCode defines the fragment shader code to use
  28787. * @param context defines the webGL context to use (if not set, the current one will be used)
  28788. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28789. * @returns the new webGL program
  28790. */
  28791. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28792. /**
  28793. * Creates a webGL program
  28794. * @param vertexCode defines the vertex shader code to use
  28795. * @param fragmentCode defines the fragment shader code to use
  28796. * @param defines defines the string containing the defines to use to compile the shaders
  28797. * @param context defines the webGL context to use (if not set, the current one will be used)
  28798. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28799. * @returns the new webGL program
  28800. */
  28801. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28802. private _createShaderProgram;
  28803. private _finalizeProgram;
  28804. /** @hidden */
  28805. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28806. /** @hidden */
  28807. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28808. /**
  28809. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28810. * @param shaderProgram defines the webGL program to use
  28811. * @param uniformsNames defines the list of uniform names
  28812. * @returns an array of webGL uniform locations
  28813. */
  28814. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28815. /**
  28816. * Gets the lsit of active attributes for a given webGL program
  28817. * @param shaderProgram defines the webGL program to use
  28818. * @param attributesNames defines the list of attribute names to get
  28819. * @returns an array of indices indicating the offset of each attribute
  28820. */
  28821. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28822. /**
  28823. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28824. * @param effect defines the effect to activate
  28825. */
  28826. enableEffect(effect: Nullable<Effect>): void;
  28827. /**
  28828. * Set the value of an uniform to an array of int32
  28829. * @param uniform defines the webGL uniform location where to store the value
  28830. * @param array defines the array of int32 to store
  28831. */
  28832. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28833. /**
  28834. * Set the value of an uniform to an array of int32 (stored as vec2)
  28835. * @param uniform defines the webGL uniform location where to store the value
  28836. * @param array defines the array of int32 to store
  28837. */
  28838. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28839. /**
  28840. * Set the value of an uniform to an array of int32 (stored as vec3)
  28841. * @param uniform defines the webGL uniform location where to store the value
  28842. * @param array defines the array of int32 to store
  28843. */
  28844. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28845. /**
  28846. * Set the value of an uniform to an array of int32 (stored as vec4)
  28847. * @param uniform defines the webGL uniform location where to store the value
  28848. * @param array defines the array of int32 to store
  28849. */
  28850. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28851. /**
  28852. * Set the value of an uniform to an array of float32
  28853. * @param uniform defines the webGL uniform location where to store the value
  28854. * @param array defines the array of float32 to store
  28855. */
  28856. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28857. /**
  28858. * Set the value of an uniform to an array of float32 (stored as vec2)
  28859. * @param uniform defines the webGL uniform location where to store the value
  28860. * @param array defines the array of float32 to store
  28861. */
  28862. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28863. /**
  28864. * Set the value of an uniform to an array of float32 (stored as vec3)
  28865. * @param uniform defines the webGL uniform location where to store the value
  28866. * @param array defines the array of float32 to store
  28867. */
  28868. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28869. /**
  28870. * Set the value of an uniform to an array of float32 (stored as vec4)
  28871. * @param uniform defines the webGL uniform location where to store the value
  28872. * @param array defines the array of float32 to store
  28873. */
  28874. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28875. /**
  28876. * Set the value of an uniform to an array of number
  28877. * @param uniform defines the webGL uniform location where to store the value
  28878. * @param array defines the array of number to store
  28879. */
  28880. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28881. /**
  28882. * Set the value of an uniform to an array of number (stored as vec2)
  28883. * @param uniform defines the webGL uniform location where to store the value
  28884. * @param array defines the array of number to store
  28885. */
  28886. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28887. /**
  28888. * Set the value of an uniform to an array of number (stored as vec3)
  28889. * @param uniform defines the webGL uniform location where to store the value
  28890. * @param array defines the array of number to store
  28891. */
  28892. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28893. /**
  28894. * Set the value of an uniform to an array of number (stored as vec4)
  28895. * @param uniform defines the webGL uniform location where to store the value
  28896. * @param array defines the array of number to store
  28897. */
  28898. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28899. /**
  28900. * Set the value of an uniform to an array of float32 (stored as matrices)
  28901. * @param uniform defines the webGL uniform location where to store the value
  28902. * @param matrices defines the array of float32 to store
  28903. */
  28904. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28905. /**
  28906. * Set the value of an uniform to a matrix
  28907. * @param uniform defines the webGL uniform location where to store the value
  28908. * @param matrix defines the matrix to store
  28909. */
  28910. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28911. /**
  28912. * Set the value of an uniform to a matrix (3x3)
  28913. * @param uniform defines the webGL uniform location where to store the value
  28914. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28915. */
  28916. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28917. /**
  28918. * Set the value of an uniform to a matrix (2x2)
  28919. * @param uniform defines the webGL uniform location where to store the value
  28920. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28921. */
  28922. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28923. /**
  28924. * Set the value of an uniform to a number (int)
  28925. * @param uniform defines the webGL uniform location where to store the value
  28926. * @param value defines the int number to store
  28927. */
  28928. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28929. /**
  28930. * Set the value of an uniform to a number (float)
  28931. * @param uniform defines the webGL uniform location where to store the value
  28932. * @param value defines the float number to store
  28933. */
  28934. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28935. /**
  28936. * Set the value of an uniform to a vec2
  28937. * @param uniform defines the webGL uniform location where to store the value
  28938. * @param x defines the 1st component of the value
  28939. * @param y defines the 2nd component of the value
  28940. */
  28941. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28942. /**
  28943. * Set the value of an uniform to a vec3
  28944. * @param uniform defines the webGL uniform location where to store the value
  28945. * @param x defines the 1st component of the value
  28946. * @param y defines the 2nd component of the value
  28947. * @param z defines the 3rd component of the value
  28948. */
  28949. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28950. /**
  28951. * Set the value of an uniform to a boolean
  28952. * @param uniform defines the webGL uniform location where to store the value
  28953. * @param bool defines the boolean to store
  28954. */
  28955. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28956. /**
  28957. * Set the value of an uniform to a vec4
  28958. * @param uniform defines the webGL uniform location where to store the value
  28959. * @param x defines the 1st component of the value
  28960. * @param y defines the 2nd component of the value
  28961. * @param z defines the 3rd component of the value
  28962. * @param w defines the 4th component of the value
  28963. */
  28964. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28965. /**
  28966. * Set the value of an uniform to a Color3
  28967. * @param uniform defines the webGL uniform location where to store the value
  28968. * @param color3 defines the color to store
  28969. */
  28970. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28971. /**
  28972. * Set the value of an uniform to a Color3 and an alpha value
  28973. * @param uniform defines the webGL uniform location where to store the value
  28974. * @param color3 defines the color to store
  28975. * @param alpha defines the alpha component to store
  28976. */
  28977. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28978. /**
  28979. * Sets a Color4 on a uniform variable
  28980. * @param uniform defines the uniform location
  28981. * @param color4 defines the value to be set
  28982. */
  28983. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28984. /**
  28985. * Set various states to the webGL context
  28986. * @param culling defines backface culling state
  28987. * @param zOffset defines the value to apply to zOffset (0 by default)
  28988. * @param force defines if states must be applied even if cache is up to date
  28989. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28990. */
  28991. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28992. /**
  28993. * Set the z offset to apply to current rendering
  28994. * @param value defines the offset to apply
  28995. */
  28996. setZOffset(value: number): void;
  28997. /**
  28998. * Gets the current value of the zOffset
  28999. * @returns the current zOffset state
  29000. */
  29001. getZOffset(): number;
  29002. /**
  29003. * Enable or disable depth buffering
  29004. * @param enable defines the state to set
  29005. */
  29006. setDepthBuffer(enable: boolean): void;
  29007. /**
  29008. * Gets a boolean indicating if depth writing is enabled
  29009. * @returns the current depth writing state
  29010. */
  29011. getDepthWrite(): boolean;
  29012. /**
  29013. * Enable or disable depth writing
  29014. * @param enable defines the state to set
  29015. */
  29016. setDepthWrite(enable: boolean): void;
  29017. /**
  29018. * Enable or disable color writing
  29019. * @param enable defines the state to set
  29020. */
  29021. setColorWrite(enable: boolean): void;
  29022. /**
  29023. * Gets a boolean indicating if color writing is enabled
  29024. * @returns the current color writing state
  29025. */
  29026. getColorWrite(): boolean;
  29027. /**
  29028. * Sets alpha constants used by some alpha blending modes
  29029. * @param r defines the red component
  29030. * @param g defines the green component
  29031. * @param b defines the blue component
  29032. * @param a defines the alpha component
  29033. */
  29034. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29035. /**
  29036. * Sets the current alpha mode
  29037. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29038. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29039. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29040. */
  29041. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29042. /**
  29043. * Gets the current alpha mode
  29044. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29045. * @returns the current alpha mode
  29046. */
  29047. getAlphaMode(): number;
  29048. /**
  29049. * Clears the list of texture accessible through engine.
  29050. * This can help preventing texture load conflict due to name collision.
  29051. */
  29052. clearInternalTexturesCache(): void;
  29053. /**
  29054. * Force the entire cache to be cleared
  29055. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29056. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29057. */
  29058. wipeCaches(bruteForce?: boolean): void;
  29059. /**
  29060. * Set the compressed texture format to use, based on the formats you have, and the formats
  29061. * supported by the hardware / browser.
  29062. *
  29063. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29064. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29065. * to API arguments needed to compressed textures. This puts the burden on the container
  29066. * generator to house the arcane code for determining these for current & future formats.
  29067. *
  29068. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29069. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29070. *
  29071. * Note: The result of this call is not taken into account when a texture is base64.
  29072. *
  29073. * @param formatsAvailable defines the list of those format families you have created
  29074. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29075. *
  29076. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29077. * @returns The extension selected.
  29078. */
  29079. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29080. private _getSamplingParameters;
  29081. private _partialLoadImg;
  29082. private _cascadeLoadImgs;
  29083. /** @hidden */
  29084. _createTexture(): WebGLTexture;
  29085. /**
  29086. * Usually called from Texture.ts.
  29087. * Passed information to create a WebGLTexture
  29088. * @param urlArg defines a value which contains one of the following:
  29089. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29090. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29091. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29092. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29093. * @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)
  29094. * @param scene needed for loading to the correct scene
  29095. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29096. * @param onLoad optional callback to be called upon successful completion
  29097. * @param onError optional callback to be called upon failure
  29098. * @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
  29099. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29100. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29101. * @param forcedExtension defines the extension to use to pick the right loader
  29102. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29103. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29104. */
  29105. 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;
  29106. private _rescaleTexture;
  29107. /**
  29108. * Update a raw texture
  29109. * @param texture defines the texture to update
  29110. * @param data defines the data to store in the texture
  29111. * @param format defines the format of the data
  29112. * @param invertY defines if data must be stored with Y axis inverted
  29113. * @param compression defines the compression used (null by default)
  29114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29115. */
  29116. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29117. /**
  29118. * Creates a raw texture
  29119. * @param data defines the data to store in the texture
  29120. * @param width defines the width of the texture
  29121. * @param height defines the height of the texture
  29122. * @param format defines the format of the data
  29123. * @param generateMipMaps defines if the engine should generate the mip levels
  29124. * @param invertY defines if data must be stored with Y axis inverted
  29125. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29126. * @param compression defines the compression used (null by default)
  29127. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29128. * @returns the raw texture inside an InternalTexture
  29129. */
  29130. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29131. private _unpackFlipYCached;
  29132. /**
  29133. * In case you are sharing the context with other applications, it might
  29134. * be interested to not cache the unpack flip y state to ensure a consistent
  29135. * value would be set.
  29136. */
  29137. enableUnpackFlipYCached: boolean;
  29138. /** @hidden */
  29139. _unpackFlipY(value: boolean): void;
  29140. /** @hidden */
  29141. _getUnpackAlignement(): number;
  29142. /**
  29143. * Creates a dynamic texture
  29144. * @param width defines the width of the texture
  29145. * @param height defines the height of the texture
  29146. * @param generateMipMaps defines if the engine should generate the mip levels
  29147. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29148. * @returns the dynamic texture inside an InternalTexture
  29149. */
  29150. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29151. /**
  29152. * Update the sampling mode of a given texture
  29153. * @param samplingMode defines the required sampling mode
  29154. * @param texture defines the texture to update
  29155. */
  29156. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29157. /**
  29158. * Update the content of a dynamic texture
  29159. * @param texture defines the texture to update
  29160. * @param canvas defines the canvas containing the source
  29161. * @param invertY defines if data must be stored with Y axis inverted
  29162. * @param premulAlpha defines if alpha is stored as premultiplied
  29163. * @param format defines the format of the data
  29164. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29165. */
  29166. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29167. /**
  29168. * Update a video texture
  29169. * @param texture defines the texture to update
  29170. * @param video defines the video element to use
  29171. * @param invertY defines if data must be stored with Y axis inverted
  29172. */
  29173. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29174. /**
  29175. * Updates a depth texture Comparison Mode and Function.
  29176. * If the comparison Function is equal to 0, the mode will be set to none.
  29177. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29178. * @param texture The texture to set the comparison function for
  29179. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29180. */
  29181. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29182. private _setupDepthStencilTexture;
  29183. /**
  29184. * Creates a depth stencil texture.
  29185. * This is only available in WebGL 2 or with the depth texture extension available.
  29186. * @param size The size of face edge in the texture.
  29187. * @param options The options defining the texture.
  29188. * @returns The texture
  29189. */
  29190. createDepthStencilTexture(size: number | {
  29191. width: number;
  29192. height: number;
  29193. }, options: DepthTextureCreationOptions): InternalTexture;
  29194. /**
  29195. * Creates a depth stencil texture.
  29196. * This is only available in WebGL 2 or with the depth texture extension available.
  29197. * @param size The size of face edge in the texture.
  29198. * @param options The options defining the texture.
  29199. * @returns The texture
  29200. */
  29201. private _createDepthStencilTexture;
  29202. /**
  29203. * Creates a depth stencil cube texture.
  29204. * This is only available in WebGL 2.
  29205. * @param size The size of face edge in the cube texture.
  29206. * @param options The options defining the cube texture.
  29207. * @returns The cube texture
  29208. */
  29209. private _createDepthStencilCubeTexture;
  29210. /**
  29211. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29212. * @param renderTarget The render target to set the frame buffer for
  29213. */
  29214. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29215. /**
  29216. * Creates a new render target texture
  29217. * @param size defines the size of the texture
  29218. * @param options defines the options used to create the texture
  29219. * @returns a new render target texture stored in an InternalTexture
  29220. */
  29221. createRenderTargetTexture(size: number | {
  29222. width: number;
  29223. height: number;
  29224. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29225. /**
  29226. * Create a multi render target texture
  29227. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29228. * @param size defines the size of the texture
  29229. * @param options defines the creation options
  29230. * @returns the cube texture as an InternalTexture
  29231. */
  29232. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29233. private _setupFramebufferDepthAttachments;
  29234. /**
  29235. * Updates the sample count of a render target texture
  29236. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29237. * @param texture defines the texture to update
  29238. * @param samples defines the sample count to set
  29239. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29240. */
  29241. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29242. /**
  29243. * Update the sample count for a given multiple render target texture
  29244. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29245. * @param textures defines the textures to update
  29246. * @param samples defines the sample count to set
  29247. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29248. */
  29249. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29250. /** @hidden */
  29251. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29252. /** @hidden */
  29253. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29254. /** @hidden */
  29255. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29256. /** @hidden */
  29257. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29258. /**
  29259. * Creates a new multiview render target
  29260. * @param width defines the width of the texture
  29261. * @param height defines the height of the texture
  29262. * @returns the created multiview texture
  29263. */
  29264. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  29265. /**
  29266. * Binds a multiview framebuffer to be drawn to
  29267. * @param multiviewTexture texture to bind
  29268. */
  29269. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  29270. /**
  29271. * Creates a new render target cube texture
  29272. * @param size defines the size of the texture
  29273. * @param options defines the options used to create the texture
  29274. * @returns a new render target cube texture stored in an InternalTexture
  29275. */
  29276. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29277. /**
  29278. * Creates a cube texture
  29279. * @param rootUrl defines the url where the files to load is located
  29280. * @param scene defines the current scene
  29281. * @param files defines the list of files to load (1 per face)
  29282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29283. * @param onLoad defines an optional callback raised when the texture is loaded
  29284. * @param onError defines an optional callback raised if there is an issue to load the texture
  29285. * @param format defines the format of the data
  29286. * @param forcedExtension defines the extension to use to pick the right loader
  29287. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29288. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29289. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29290. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29291. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29292. * @returns the cube texture as an InternalTexture
  29293. */
  29294. 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;
  29295. /**
  29296. * @hidden
  29297. */
  29298. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29299. /**
  29300. * Update a raw cube texture
  29301. * @param texture defines the texture to udpdate
  29302. * @param data defines the data to store
  29303. * @param format defines the data format
  29304. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29305. * @param invertY defines if data must be stored with Y axis inverted
  29306. * @param compression defines the compression used (null by default)
  29307. * @param level defines which level of the texture to update
  29308. */
  29309. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29310. /**
  29311. * Creates a new raw cube texture
  29312. * @param data defines the array of data to use to create each face
  29313. * @param size defines the size of the textures
  29314. * @param format defines the format of the data
  29315. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29316. * @param generateMipMaps defines if the engine should generate the mip levels
  29317. * @param invertY defines if data must be stored with Y axis inverted
  29318. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29319. * @param compression defines the compression used (null by default)
  29320. * @returns the cube texture as an InternalTexture
  29321. */
  29322. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29323. /**
  29324. * Creates a new raw cube texture from a specified url
  29325. * @param url defines the url where the data is located
  29326. * @param scene defines the current scene
  29327. * @param size defines the size of the textures
  29328. * @param format defines the format of the data
  29329. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29330. * @param noMipmap defines if the engine should avoid generating the mip levels
  29331. * @param callback defines a callback used to extract texture data from loaded data
  29332. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29333. * @param onLoad defines a callback called when texture is loaded
  29334. * @param onError defines a callback called if there is an error
  29335. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29336. * @param invertY defines if data must be stored with Y axis inverted
  29337. * @returns the cube texture as an InternalTexture
  29338. */
  29339. 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;
  29340. /**
  29341. * Update a raw 3D texture
  29342. * @param texture defines the texture to update
  29343. * @param data defines the data to store
  29344. * @param format defines the data format
  29345. * @param invertY defines if data must be stored with Y axis inverted
  29346. * @param compression defines the used compression (can be null)
  29347. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29348. */
  29349. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29350. /**
  29351. * Creates a new raw 3D texture
  29352. * @param data defines the data used to create the texture
  29353. * @param width defines the width of the texture
  29354. * @param height defines the height of the texture
  29355. * @param depth defines the depth of the texture
  29356. * @param format defines the format of the texture
  29357. * @param generateMipMaps defines if the engine must generate mip levels
  29358. * @param invertY defines if data must be stored with Y axis inverted
  29359. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29360. * @param compression defines the compressed used (can be null)
  29361. * @param textureType defines the compressed used (can be null)
  29362. * @returns a new raw 3D texture (stored in an InternalTexture)
  29363. */
  29364. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29365. private _prepareWebGLTextureContinuation;
  29366. private _prepareWebGLTexture;
  29367. private _convertRGBtoRGBATextureData;
  29368. /** @hidden */
  29369. _releaseFramebufferObjects(texture: InternalTexture): void;
  29370. /** @hidden */
  29371. _releaseTexture(texture: InternalTexture): void;
  29372. private setProgram;
  29373. private _boundUniforms;
  29374. /**
  29375. * Binds an effect to the webGL context
  29376. * @param effect defines the effect to bind
  29377. */
  29378. bindSamplers(effect: Effect): void;
  29379. private _moveBoundTextureOnTop;
  29380. private _getCorrectTextureChannel;
  29381. private _linkTrackers;
  29382. private _removeDesignatedSlot;
  29383. private _activateCurrentTexture;
  29384. /** @hidden */
  29385. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29386. /** @hidden */
  29387. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29388. /**
  29389. * Sets a texture to the webGL context from a postprocess
  29390. * @param channel defines the channel to use
  29391. * @param postProcess defines the source postprocess
  29392. */
  29393. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29394. /**
  29395. * Binds the output of the passed in post process to the texture channel specified
  29396. * @param channel The channel the texture should be bound to
  29397. * @param postProcess The post process which's output should be bound
  29398. */
  29399. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29400. /**
  29401. * Unbind all textures from the webGL context
  29402. */
  29403. unbindAllTextures(): void;
  29404. /**
  29405. * Sets a texture to the according uniform.
  29406. * @param channel The texture channel
  29407. * @param uniform The uniform to set
  29408. * @param texture The texture to apply
  29409. */
  29410. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29411. /**
  29412. * Sets a depth stencil texture from a render target to the according uniform.
  29413. * @param channel The texture channel
  29414. * @param uniform The uniform to set
  29415. * @param texture The render target texture containing the depth stencil texture to apply
  29416. */
  29417. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29418. private _bindSamplerUniformToChannel;
  29419. private _getTextureWrapMode;
  29420. private _setTexture;
  29421. /**
  29422. * Sets an array of texture to the webGL context
  29423. * @param channel defines the channel where the texture array must be set
  29424. * @param uniform defines the associated uniform location
  29425. * @param textures defines the array of textures to bind
  29426. */
  29427. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29428. /** @hidden */
  29429. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29430. private _setTextureParameterFloat;
  29431. private _setTextureParameterInteger;
  29432. /**
  29433. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29434. * @param x defines the x coordinate of the rectangle where pixels must be read
  29435. * @param y defines the y coordinate of the rectangle where pixels must be read
  29436. * @param width defines the width of the rectangle where pixels must be read
  29437. * @param height defines the height of the rectangle where pixels must be read
  29438. * @returns a Uint8Array containing RGBA colors
  29439. */
  29440. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29441. /**
  29442. * Add an externaly attached data from its key.
  29443. * This method call will fail and return false, if such key already exists.
  29444. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29445. * @param key the unique key that identifies the data
  29446. * @param data the data object to associate to the key for this Engine instance
  29447. * @return true if no such key were already present and the data was added successfully, false otherwise
  29448. */
  29449. addExternalData<T>(key: string, data: T): boolean;
  29450. /**
  29451. * Get an externaly attached data from its key
  29452. * @param key the unique key that identifies the data
  29453. * @return the associated data, if present (can be null), or undefined if not present
  29454. */
  29455. getExternalData<T>(key: string): T;
  29456. /**
  29457. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29458. * @param key the unique key that identifies the data
  29459. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29460. * @return the associated data, can be null if the factory returned null.
  29461. */
  29462. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29463. /**
  29464. * Remove an externaly attached data from the Engine instance
  29465. * @param key the unique key that identifies the data
  29466. * @return true if the data was successfully removed, false if it doesn't exist
  29467. */
  29468. removeExternalData(key: string): boolean;
  29469. /**
  29470. * Unbind all vertex attributes from the webGL context
  29471. */
  29472. unbindAllAttributes(): void;
  29473. /**
  29474. * 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
  29475. */
  29476. releaseEffects(): void;
  29477. /**
  29478. * Dispose and release all associated resources
  29479. */
  29480. dispose(): void;
  29481. /**
  29482. * Display the loading screen
  29483. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29484. */
  29485. displayLoadingUI(): void;
  29486. /**
  29487. * Hide the loading screen
  29488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29489. */
  29490. hideLoadingUI(): void;
  29491. /**
  29492. * Gets the current loading screen object
  29493. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29494. */
  29495. /**
  29496. * Sets the current loading screen object
  29497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29498. */
  29499. loadingScreen: ILoadingScreen;
  29500. /**
  29501. * Sets the current loading screen text
  29502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29503. */
  29504. loadingUIText: string;
  29505. /**
  29506. * Sets the current loading screen background color
  29507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29508. */
  29509. loadingUIBackgroundColor: string;
  29510. /**
  29511. * Attach a new callback raised when context lost event is fired
  29512. * @param callback defines the callback to call
  29513. */
  29514. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29515. /**
  29516. * Attach a new callback raised when context restored event is fired
  29517. * @param callback defines the callback to call
  29518. */
  29519. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29520. /**
  29521. * Gets the source code of the vertex shader associated with a specific webGL program
  29522. * @param program defines the program to use
  29523. * @returns a string containing the source code of the vertex shader associated with the program
  29524. */
  29525. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29526. /**
  29527. * Gets the source code of the fragment shader associated with a specific webGL program
  29528. * @param program defines the program to use
  29529. * @returns a string containing the source code of the fragment shader associated with the program
  29530. */
  29531. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29532. /**
  29533. * Get the current error code of the webGL context
  29534. * @returns the error code
  29535. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29536. */
  29537. getError(): number;
  29538. /**
  29539. * Gets the current framerate
  29540. * @returns a number representing the framerate
  29541. */
  29542. getFps(): number;
  29543. /**
  29544. * Gets the time spent between current and previous frame
  29545. * @returns a number representing the delta time in ms
  29546. */
  29547. getDeltaTime(): number;
  29548. private _measureFps;
  29549. /** @hidden */
  29550. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29551. private _canRenderToFloatFramebuffer;
  29552. private _canRenderToHalfFloatFramebuffer;
  29553. private _canRenderToFramebuffer;
  29554. /** @hidden */
  29555. _getWebGLTextureType(type: number): number;
  29556. private _getInternalFormat;
  29557. /** @hidden */
  29558. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29559. /** @hidden */
  29560. _getRGBAMultiSampleBufferFormat(type: number): number;
  29561. /** @hidden */
  29562. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  29563. /** @hidden */
  29564. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29565. private _partialLoadFile;
  29566. private _cascadeLoadFiles;
  29567. /**
  29568. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29569. * @returns true if the engine can be created
  29570. * @ignorenaming
  29571. */
  29572. static isSupported(): boolean;
  29573. }
  29574. }
  29575. declare module "babylonjs/Materials/effect" {
  29576. import { Observable } from "babylonjs/Misc/observable";
  29577. import { Nullable } from "babylonjs/types";
  29578. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29579. import { Engine } from "babylonjs/Engines/engine";
  29580. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29585. /**
  29586. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29587. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29588. */
  29589. export class EffectFallbacks {
  29590. private _defines;
  29591. private _currentRank;
  29592. private _maxRank;
  29593. private _mesh;
  29594. /**
  29595. * Removes the fallback from the bound mesh.
  29596. */
  29597. unBindMesh(): void;
  29598. /**
  29599. * Adds a fallback on the specified property.
  29600. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29601. * @param define The name of the define in the shader
  29602. */
  29603. addFallback(rank: number, define: string): void;
  29604. /**
  29605. * Sets the mesh to use CPU skinning when needing to fallback.
  29606. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29607. * @param mesh The mesh to use the fallbacks.
  29608. */
  29609. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29610. /**
  29611. * Checks to see if more fallbacks are still availible.
  29612. */
  29613. readonly isMoreFallbacks: boolean;
  29614. /**
  29615. * Removes the defines that shoould be removed when falling back.
  29616. * @param currentDefines defines the current define statements for the shader.
  29617. * @param effect defines the current effect we try to compile
  29618. * @returns The resulting defines with defines of the current rank removed.
  29619. */
  29620. reduce(currentDefines: string, effect: Effect): string;
  29621. }
  29622. /**
  29623. * Options to be used when creating an effect.
  29624. */
  29625. export class EffectCreationOptions {
  29626. /**
  29627. * Atrributes that will be used in the shader.
  29628. */
  29629. attributes: string[];
  29630. /**
  29631. * Uniform varible names that will be set in the shader.
  29632. */
  29633. uniformsNames: string[];
  29634. /**
  29635. * Uniform buffer varible names that will be set in the shader.
  29636. */
  29637. uniformBuffersNames: string[];
  29638. /**
  29639. * Sampler texture variable names that will be set in the shader.
  29640. */
  29641. samplers: string[];
  29642. /**
  29643. * Define statements that will be set in the shader.
  29644. */
  29645. defines: any;
  29646. /**
  29647. * Possible fallbacks for this effect to improve performance when needed.
  29648. */
  29649. fallbacks: Nullable<EffectFallbacks>;
  29650. /**
  29651. * Callback that will be called when the shader is compiled.
  29652. */
  29653. onCompiled: Nullable<(effect: Effect) => void>;
  29654. /**
  29655. * Callback that will be called if an error occurs during shader compilation.
  29656. */
  29657. onError: Nullable<(effect: Effect, errors: string) => void>;
  29658. /**
  29659. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29660. */
  29661. indexParameters: any;
  29662. /**
  29663. * Max number of lights that can be used in the shader.
  29664. */
  29665. maxSimultaneousLights: number;
  29666. /**
  29667. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29668. */
  29669. transformFeedbackVaryings: Nullable<string[]>;
  29670. }
  29671. /**
  29672. * Effect containing vertex and fragment shader that can be executed on an object.
  29673. */
  29674. export class Effect {
  29675. /**
  29676. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29677. */
  29678. static ShadersRepository: string;
  29679. /**
  29680. * Name of the effect.
  29681. */
  29682. name: any;
  29683. /**
  29684. * String container all the define statements that should be set on the shader.
  29685. */
  29686. defines: string;
  29687. /**
  29688. * Callback that will be called when the shader is compiled.
  29689. */
  29690. onCompiled: Nullable<(effect: Effect) => void>;
  29691. /**
  29692. * Callback that will be called if an error occurs during shader compilation.
  29693. */
  29694. onError: Nullable<(effect: Effect, errors: string) => void>;
  29695. /**
  29696. * Callback that will be called when effect is bound.
  29697. */
  29698. onBind: Nullable<(effect: Effect) => void>;
  29699. /**
  29700. * Unique ID of the effect.
  29701. */
  29702. uniqueId: number;
  29703. /**
  29704. * Observable that will be called when the shader is compiled.
  29705. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29706. */
  29707. onCompileObservable: Observable<Effect>;
  29708. /**
  29709. * Observable that will be called if an error occurs during shader compilation.
  29710. */
  29711. onErrorObservable: Observable<Effect>;
  29712. /** @hidden */
  29713. _onBindObservable: Nullable<Observable<Effect>>;
  29714. /**
  29715. * Observable that will be called when effect is bound.
  29716. */
  29717. readonly onBindObservable: Observable<Effect>;
  29718. /** @hidden */
  29719. _bonesComputationForcedToCPU: boolean;
  29720. private static _uniqueIdSeed;
  29721. private _engine;
  29722. private _uniformBuffersNames;
  29723. private _uniformsNames;
  29724. private _samplers;
  29725. private _isReady;
  29726. private _compilationError;
  29727. private _attributesNames;
  29728. private _attributes;
  29729. private _uniforms;
  29730. /**
  29731. * Key for the effect.
  29732. * @hidden
  29733. */
  29734. _key: string;
  29735. private _indexParameters;
  29736. private _fallbacks;
  29737. private _vertexSourceCode;
  29738. private _fragmentSourceCode;
  29739. private _vertexSourceCodeOverride;
  29740. private _fragmentSourceCodeOverride;
  29741. private _transformFeedbackVaryings;
  29742. /**
  29743. * Compiled shader to webGL program.
  29744. * @hidden
  29745. */
  29746. _program: WebGLProgram;
  29747. private _valueCache;
  29748. private static _baseCache;
  29749. /**
  29750. * Instantiates an effect.
  29751. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29752. * @param baseName Name of the effect.
  29753. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29754. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29755. * @param samplers List of sampler variables that will be passed to the shader.
  29756. * @param engine Engine to be used to render the effect
  29757. * @param defines Define statements to be added to the shader.
  29758. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29759. * @param onCompiled Callback that will be called when the shader is compiled.
  29760. * @param onError Callback that will be called if an error occurs during shader compilation.
  29761. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29762. */
  29763. 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);
  29764. /**
  29765. * Unique key for this effect
  29766. */
  29767. readonly key: string;
  29768. /**
  29769. * If the effect has been compiled and prepared.
  29770. * @returns if the effect is compiled and prepared.
  29771. */
  29772. isReady(): boolean;
  29773. /**
  29774. * The engine the effect was initialized with.
  29775. * @returns the engine.
  29776. */
  29777. getEngine(): Engine;
  29778. /**
  29779. * The compiled webGL program for the effect
  29780. * @returns the webGL program.
  29781. */
  29782. getProgram(): WebGLProgram;
  29783. /**
  29784. * The set of names of attribute variables for the shader.
  29785. * @returns An array of attribute names.
  29786. */
  29787. getAttributesNames(): string[];
  29788. /**
  29789. * Returns the attribute at the given index.
  29790. * @param index The index of the attribute.
  29791. * @returns The location of the attribute.
  29792. */
  29793. getAttributeLocation(index: number): number;
  29794. /**
  29795. * Returns the attribute based on the name of the variable.
  29796. * @param name of the attribute to look up.
  29797. * @returns the attribute location.
  29798. */
  29799. getAttributeLocationByName(name: string): number;
  29800. /**
  29801. * The number of attributes.
  29802. * @returns the numnber of attributes.
  29803. */
  29804. getAttributesCount(): number;
  29805. /**
  29806. * Gets the index of a uniform variable.
  29807. * @param uniformName of the uniform to look up.
  29808. * @returns the index.
  29809. */
  29810. getUniformIndex(uniformName: string): number;
  29811. /**
  29812. * Returns the attribute based on the name of the variable.
  29813. * @param uniformName of the uniform to look up.
  29814. * @returns the location of the uniform.
  29815. */
  29816. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29817. /**
  29818. * Returns an array of sampler variable names
  29819. * @returns The array of sampler variable neames.
  29820. */
  29821. getSamplers(): string[];
  29822. /**
  29823. * The error from the last compilation.
  29824. * @returns the error string.
  29825. */
  29826. getCompilationError(): string;
  29827. /**
  29828. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29829. * @param func The callback to be used.
  29830. */
  29831. executeWhenCompiled(func: (effect: Effect) => void): void;
  29832. private _checkIsReady;
  29833. /** @hidden */
  29834. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29835. /** @hidden */
  29836. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29837. /** @hidden */
  29838. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29839. private _processShaderConversion;
  29840. private _processIncludes;
  29841. private _processPrecision;
  29842. /**
  29843. * Recompiles the webGL program
  29844. * @param vertexSourceCode The source code for the vertex shader.
  29845. * @param fragmentSourceCode The source code for the fragment shader.
  29846. * @param onCompiled Callback called when completed.
  29847. * @param onError Callback called on error.
  29848. * @hidden
  29849. */
  29850. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29851. /**
  29852. * Gets the uniform locations of the the specified variable names
  29853. * @param names THe names of the variables to lookup.
  29854. * @returns Array of locations in the same order as variable names.
  29855. */
  29856. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29857. /**
  29858. * Prepares the effect
  29859. * @hidden
  29860. */
  29861. _prepareEffect(): void;
  29862. /**
  29863. * Checks if the effect is supported. (Must be called after compilation)
  29864. */
  29865. readonly isSupported: boolean;
  29866. /**
  29867. * Binds a texture to the engine to be used as output of the shader.
  29868. * @param channel Name of the output variable.
  29869. * @param texture Texture to bind.
  29870. * @hidden
  29871. */
  29872. _bindTexture(channel: string, texture: InternalTexture): void;
  29873. /**
  29874. * Sets a texture on the engine to be used in the shader.
  29875. * @param channel Name of the sampler variable.
  29876. * @param texture Texture to set.
  29877. */
  29878. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29879. /**
  29880. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29881. * @param channel Name of the sampler variable.
  29882. * @param texture Texture to set.
  29883. */
  29884. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29885. /**
  29886. * Sets an array of textures on the engine to be used in the shader.
  29887. * @param channel Name of the variable.
  29888. * @param textures Textures to set.
  29889. */
  29890. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29891. /**
  29892. * 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)
  29893. * @param channel Name of the sampler variable.
  29894. * @param postProcess Post process to get the input texture from.
  29895. */
  29896. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29897. /**
  29898. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29899. * 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)
  29900. * @param channel Name of the sampler variable.
  29901. * @param postProcess Post process to get the output texture from.
  29902. */
  29903. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29904. /** @hidden */
  29905. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29906. /** @hidden */
  29907. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29908. /** @hidden */
  29909. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29910. /** @hidden */
  29911. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29912. /**
  29913. * Binds a buffer to a uniform.
  29914. * @param buffer Buffer to bind.
  29915. * @param name Name of the uniform variable to bind to.
  29916. */
  29917. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29918. /**
  29919. * Binds block to a uniform.
  29920. * @param blockName Name of the block to bind.
  29921. * @param index Index to bind.
  29922. */
  29923. bindUniformBlock(blockName: string, index: number): void;
  29924. /**
  29925. * Sets an interger value on a uniform variable.
  29926. * @param uniformName Name of the variable.
  29927. * @param value Value to be set.
  29928. * @returns this effect.
  29929. */
  29930. setInt(uniformName: string, value: number): Effect;
  29931. /**
  29932. * Sets an int array on a uniform variable.
  29933. * @param uniformName Name of the variable.
  29934. * @param array array to be set.
  29935. * @returns this effect.
  29936. */
  29937. setIntArray(uniformName: string, array: Int32Array): Effect;
  29938. /**
  29939. * 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)
  29940. * @param uniformName Name of the variable.
  29941. * @param array array to be set.
  29942. * @returns this effect.
  29943. */
  29944. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29945. /**
  29946. * 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)
  29947. * @param uniformName Name of the variable.
  29948. * @param array array to be set.
  29949. * @returns this effect.
  29950. */
  29951. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29952. /**
  29953. * 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)
  29954. * @param uniformName Name of the variable.
  29955. * @param array array to be set.
  29956. * @returns this effect.
  29957. */
  29958. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29959. /**
  29960. * Sets an float array on a uniform variable.
  29961. * @param uniformName Name of the variable.
  29962. * @param array array to be set.
  29963. * @returns this effect.
  29964. */
  29965. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29966. /**
  29967. * 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)
  29968. * @param uniformName Name of the variable.
  29969. * @param array array to be set.
  29970. * @returns this effect.
  29971. */
  29972. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29973. /**
  29974. * 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)
  29975. * @param uniformName Name of the variable.
  29976. * @param array array to be set.
  29977. * @returns this effect.
  29978. */
  29979. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29980. /**
  29981. * 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)
  29982. * @param uniformName Name of the variable.
  29983. * @param array array to be set.
  29984. * @returns this effect.
  29985. */
  29986. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29987. /**
  29988. * Sets an array on a uniform variable.
  29989. * @param uniformName Name of the variable.
  29990. * @param array array to be set.
  29991. * @returns this effect.
  29992. */
  29993. setArray(uniformName: string, array: number[]): Effect;
  29994. /**
  29995. * 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)
  29996. * @param uniformName Name of the variable.
  29997. * @param array array to be set.
  29998. * @returns this effect.
  29999. */
  30000. setArray2(uniformName: string, array: number[]): Effect;
  30001. /**
  30002. * 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)
  30003. * @param uniformName Name of the variable.
  30004. * @param array array to be set.
  30005. * @returns this effect.
  30006. */
  30007. setArray3(uniformName: string, array: number[]): Effect;
  30008. /**
  30009. * 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)
  30010. * @param uniformName Name of the variable.
  30011. * @param array array to be set.
  30012. * @returns this effect.
  30013. */
  30014. setArray4(uniformName: string, array: number[]): Effect;
  30015. /**
  30016. * Sets matrices on a uniform variable.
  30017. * @param uniformName Name of the variable.
  30018. * @param matrices matrices to be set.
  30019. * @returns this effect.
  30020. */
  30021. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30022. /**
  30023. * Sets matrix on a uniform variable.
  30024. * @param uniformName Name of the variable.
  30025. * @param matrix matrix to be set.
  30026. * @returns this effect.
  30027. */
  30028. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30029. /**
  30030. * 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)
  30031. * @param uniformName Name of the variable.
  30032. * @param matrix matrix to be set.
  30033. * @returns this effect.
  30034. */
  30035. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30036. /**
  30037. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30038. * @param uniformName Name of the variable.
  30039. * @param matrix matrix to be set.
  30040. * @returns this effect.
  30041. */
  30042. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30043. /**
  30044. * Sets a float on a uniform variable.
  30045. * @param uniformName Name of the variable.
  30046. * @param value value to be set.
  30047. * @returns this effect.
  30048. */
  30049. setFloat(uniformName: string, value: number): Effect;
  30050. /**
  30051. * Sets a boolean on a uniform variable.
  30052. * @param uniformName Name of the variable.
  30053. * @param bool value to be set.
  30054. * @returns this effect.
  30055. */
  30056. setBool(uniformName: string, bool: boolean): Effect;
  30057. /**
  30058. * Sets a Vector2 on a uniform variable.
  30059. * @param uniformName Name of the variable.
  30060. * @param vector2 vector2 to be set.
  30061. * @returns this effect.
  30062. */
  30063. setVector2(uniformName: string, vector2: Vector2): Effect;
  30064. /**
  30065. * Sets a float2 on a uniform variable.
  30066. * @param uniformName Name of the variable.
  30067. * @param x First float in float2.
  30068. * @param y Second float in float2.
  30069. * @returns this effect.
  30070. */
  30071. setFloat2(uniformName: string, x: number, y: number): Effect;
  30072. /**
  30073. * Sets a Vector3 on a uniform variable.
  30074. * @param uniformName Name of the variable.
  30075. * @param vector3 Value to be set.
  30076. * @returns this effect.
  30077. */
  30078. setVector3(uniformName: string, vector3: Vector3): Effect;
  30079. /**
  30080. * Sets a float3 on a uniform variable.
  30081. * @param uniformName Name of the variable.
  30082. * @param x First float in float3.
  30083. * @param y Second float in float3.
  30084. * @param z Third float in float3.
  30085. * @returns this effect.
  30086. */
  30087. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30088. /**
  30089. * Sets a Vector4 on a uniform variable.
  30090. * @param uniformName Name of the variable.
  30091. * @param vector4 Value to be set.
  30092. * @returns this effect.
  30093. */
  30094. setVector4(uniformName: string, vector4: Vector4): Effect;
  30095. /**
  30096. * Sets a float4 on a uniform variable.
  30097. * @param uniformName Name of the variable.
  30098. * @param x First float in float4.
  30099. * @param y Second float in float4.
  30100. * @param z Third float in float4.
  30101. * @param w Fourth float in float4.
  30102. * @returns this effect.
  30103. */
  30104. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30105. /**
  30106. * Sets a Color3 on a uniform variable.
  30107. * @param uniformName Name of the variable.
  30108. * @param color3 Value to be set.
  30109. * @returns this effect.
  30110. */
  30111. setColor3(uniformName: string, color3: Color3): Effect;
  30112. /**
  30113. * Sets a Color4 on a uniform variable.
  30114. * @param uniformName Name of the variable.
  30115. * @param color3 Value to be set.
  30116. * @param alpha Alpha value to be set.
  30117. * @returns this effect.
  30118. */
  30119. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30120. /**
  30121. * Sets a Color4 on a uniform variable
  30122. * @param uniformName defines the name of the variable
  30123. * @param color4 defines the value to be set
  30124. * @returns this effect.
  30125. */
  30126. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30127. /**
  30128. * This function will add a new shader to the shader store
  30129. * @param name the name of the shader
  30130. * @param pixelShader optional pixel shader content
  30131. * @param vertexShader optional vertex shader content
  30132. */
  30133. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30134. /**
  30135. * Store of each shader (The can be looked up using effect.key)
  30136. */
  30137. static ShadersStore: {
  30138. [key: string]: string;
  30139. };
  30140. /**
  30141. * Store of each included file for a shader (The can be looked up using effect.key)
  30142. */
  30143. static IncludesShadersStore: {
  30144. [key: string]: string;
  30145. };
  30146. /**
  30147. * Resets the cache of effects.
  30148. */
  30149. static ResetCache(): void;
  30150. }
  30151. }
  30152. declare module "babylonjs/Materials/colorCurves" {
  30153. import { Effect } from "babylonjs/Materials/effect";
  30154. /**
  30155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30157. * 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;
  30158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30159. */
  30160. export class ColorCurves {
  30161. private _dirty;
  30162. private _tempColor;
  30163. private _globalCurve;
  30164. private _highlightsCurve;
  30165. private _midtonesCurve;
  30166. private _shadowsCurve;
  30167. private _positiveCurve;
  30168. private _negativeCurve;
  30169. private _globalHue;
  30170. private _globalDensity;
  30171. private _globalSaturation;
  30172. private _globalExposure;
  30173. /**
  30174. * Gets the global Hue value.
  30175. * 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).
  30176. */
  30177. /**
  30178. * Sets the global Hue value.
  30179. * 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).
  30180. */
  30181. globalHue: number;
  30182. /**
  30183. * Gets the global Density value.
  30184. * 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.
  30185. * Values less than zero provide a filter of opposite hue.
  30186. */
  30187. /**
  30188. * Sets the global Density value.
  30189. * 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.
  30190. * Values less than zero provide a filter of opposite hue.
  30191. */
  30192. globalDensity: number;
  30193. /**
  30194. * Gets the global Saturation value.
  30195. * 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.
  30196. */
  30197. /**
  30198. * Sets the global Saturation value.
  30199. * 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.
  30200. */
  30201. globalSaturation: number;
  30202. /**
  30203. * Gets the global Exposure value.
  30204. * 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.
  30205. */
  30206. /**
  30207. * Sets the global Exposure value.
  30208. * 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.
  30209. */
  30210. globalExposure: number;
  30211. private _highlightsHue;
  30212. private _highlightsDensity;
  30213. private _highlightsSaturation;
  30214. private _highlightsExposure;
  30215. /**
  30216. * Gets the highlights Hue value.
  30217. * 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).
  30218. */
  30219. /**
  30220. * Sets the highlights Hue value.
  30221. * 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).
  30222. */
  30223. highlightsHue: number;
  30224. /**
  30225. * Gets the highlights Density value.
  30226. * 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.
  30227. * Values less than zero provide a filter of opposite hue.
  30228. */
  30229. /**
  30230. * Sets the highlights Density value.
  30231. * 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.
  30232. * Values less than zero provide a filter of opposite hue.
  30233. */
  30234. highlightsDensity: number;
  30235. /**
  30236. * Gets the highlights Saturation value.
  30237. * 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.
  30238. */
  30239. /**
  30240. * Sets the highlights Saturation value.
  30241. * 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.
  30242. */
  30243. highlightsSaturation: number;
  30244. /**
  30245. * Gets the highlights Exposure value.
  30246. * 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.
  30247. */
  30248. /**
  30249. * Sets the highlights Exposure value.
  30250. * 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.
  30251. */
  30252. highlightsExposure: number;
  30253. private _midtonesHue;
  30254. private _midtonesDensity;
  30255. private _midtonesSaturation;
  30256. private _midtonesExposure;
  30257. /**
  30258. * Gets the midtones Hue value.
  30259. * 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).
  30260. */
  30261. /**
  30262. * Sets the midtones Hue value.
  30263. * 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).
  30264. */
  30265. midtonesHue: number;
  30266. /**
  30267. * Gets the midtones Density value.
  30268. * 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.
  30269. * Values less than zero provide a filter of opposite hue.
  30270. */
  30271. /**
  30272. * Sets the midtones Density value.
  30273. * 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.
  30274. * Values less than zero provide a filter of opposite hue.
  30275. */
  30276. midtonesDensity: number;
  30277. /**
  30278. * Gets the midtones Saturation value.
  30279. * 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.
  30280. */
  30281. /**
  30282. * Sets the midtones Saturation value.
  30283. * 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.
  30284. */
  30285. midtonesSaturation: number;
  30286. /**
  30287. * Gets the midtones Exposure value.
  30288. * 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.
  30289. */
  30290. /**
  30291. * Sets the midtones Exposure value.
  30292. * 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.
  30293. */
  30294. midtonesExposure: number;
  30295. private _shadowsHue;
  30296. private _shadowsDensity;
  30297. private _shadowsSaturation;
  30298. private _shadowsExposure;
  30299. /**
  30300. * Gets the shadows Hue value.
  30301. * 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).
  30302. */
  30303. /**
  30304. * Sets the shadows Hue value.
  30305. * 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).
  30306. */
  30307. shadowsHue: number;
  30308. /**
  30309. * Gets the shadows Density value.
  30310. * 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.
  30311. * Values less than zero provide a filter of opposite hue.
  30312. */
  30313. /**
  30314. * Sets the shadows Density value.
  30315. * 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.
  30316. * Values less than zero provide a filter of opposite hue.
  30317. */
  30318. shadowsDensity: number;
  30319. /**
  30320. * Gets the shadows Saturation value.
  30321. * 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.
  30322. */
  30323. /**
  30324. * Sets the shadows Saturation value.
  30325. * 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.
  30326. */
  30327. shadowsSaturation: number;
  30328. /**
  30329. * Gets the shadows Exposure value.
  30330. * 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.
  30331. */
  30332. /**
  30333. * Sets the shadows Exposure value.
  30334. * 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.
  30335. */
  30336. shadowsExposure: number;
  30337. /**
  30338. * Returns the class name
  30339. * @returns The class name
  30340. */
  30341. getClassName(): string;
  30342. /**
  30343. * Binds the color curves to the shader.
  30344. * @param colorCurves The color curve to bind
  30345. * @param effect The effect to bind to
  30346. * @param positiveUniform The positive uniform shader parameter
  30347. * @param neutralUniform The neutral uniform shader parameter
  30348. * @param negativeUniform The negative uniform shader parameter
  30349. */
  30350. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30351. /**
  30352. * Prepare the list of uniforms associated with the ColorCurves effects.
  30353. * @param uniformsList The list of uniforms used in the effect
  30354. */
  30355. static PrepareUniforms(uniformsList: string[]): void;
  30356. /**
  30357. * Returns color grading data based on a hue, density, saturation and exposure value.
  30358. * @param filterHue The hue of the color filter.
  30359. * @param filterDensity The density of the color filter.
  30360. * @param saturation The saturation.
  30361. * @param exposure The exposure.
  30362. * @param result The result data container.
  30363. */
  30364. private getColorGradingDataToRef;
  30365. /**
  30366. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30367. * @param value The input slider value in range [-100,100].
  30368. * @returns Adjusted value.
  30369. */
  30370. private static applyColorGradingSliderNonlinear;
  30371. /**
  30372. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30373. * @param hue The hue (H) input.
  30374. * @param saturation The saturation (S) input.
  30375. * @param brightness The brightness (B) input.
  30376. * @result An RGBA color represented as Vector4.
  30377. */
  30378. private static fromHSBToRef;
  30379. /**
  30380. * Returns a value clamped between min and max
  30381. * @param value The value to clamp
  30382. * @param min The minimum of value
  30383. * @param max The maximum of value
  30384. * @returns The clamped value.
  30385. */
  30386. private static clamp;
  30387. /**
  30388. * Clones the current color curve instance.
  30389. * @return The cloned curves
  30390. */
  30391. clone(): ColorCurves;
  30392. /**
  30393. * Serializes the current color curve instance to a json representation.
  30394. * @return a JSON representation
  30395. */
  30396. serialize(): any;
  30397. /**
  30398. * Parses the color curve from a json representation.
  30399. * @param source the JSON source to parse
  30400. * @return The parsed curves
  30401. */
  30402. static Parse(source: any): ColorCurves;
  30403. }
  30404. }
  30405. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30406. import { Observable } from "babylonjs/Misc/observable";
  30407. import { Nullable } from "babylonjs/types";
  30408. import { Color4 } from "babylonjs/Maths/math";
  30409. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30410. import { Effect } from "babylonjs/Materials/effect";
  30411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30412. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30413. /**
  30414. * Interface to follow in your material defines to integrate easily the
  30415. * Image proccessing functions.
  30416. * @hidden
  30417. */
  30418. export interface IImageProcessingConfigurationDefines {
  30419. IMAGEPROCESSING: boolean;
  30420. VIGNETTE: boolean;
  30421. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30422. VIGNETTEBLENDMODEOPAQUE: boolean;
  30423. TONEMAPPING: boolean;
  30424. TONEMAPPING_ACES: boolean;
  30425. CONTRAST: boolean;
  30426. EXPOSURE: boolean;
  30427. COLORCURVES: boolean;
  30428. COLORGRADING: boolean;
  30429. COLORGRADING3D: boolean;
  30430. SAMPLER3DGREENDEPTH: boolean;
  30431. SAMPLER3DBGRMAP: boolean;
  30432. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30433. }
  30434. /**
  30435. * @hidden
  30436. */
  30437. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30438. IMAGEPROCESSING: boolean;
  30439. VIGNETTE: boolean;
  30440. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30441. VIGNETTEBLENDMODEOPAQUE: boolean;
  30442. TONEMAPPING: boolean;
  30443. TONEMAPPING_ACES: boolean;
  30444. CONTRAST: boolean;
  30445. COLORCURVES: boolean;
  30446. COLORGRADING: boolean;
  30447. COLORGRADING3D: boolean;
  30448. SAMPLER3DGREENDEPTH: boolean;
  30449. SAMPLER3DBGRMAP: boolean;
  30450. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30451. EXPOSURE: boolean;
  30452. constructor();
  30453. }
  30454. /**
  30455. * This groups together the common properties used for image processing either in direct forward pass
  30456. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30457. * or not.
  30458. */
  30459. export class ImageProcessingConfiguration {
  30460. /**
  30461. * Default tone mapping applied in BabylonJS.
  30462. */
  30463. static readonly TONEMAPPING_STANDARD: number;
  30464. /**
  30465. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30466. * to other engines rendering to increase portability.
  30467. */
  30468. static readonly TONEMAPPING_ACES: number;
  30469. /**
  30470. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30471. */
  30472. colorCurves: Nullable<ColorCurves>;
  30473. private _colorCurvesEnabled;
  30474. /**
  30475. * Gets wether the color curves effect is enabled.
  30476. */
  30477. /**
  30478. * Sets wether the color curves effect is enabled.
  30479. */
  30480. colorCurvesEnabled: boolean;
  30481. private _colorGradingTexture;
  30482. /**
  30483. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30484. */
  30485. /**
  30486. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30487. */
  30488. colorGradingTexture: Nullable<BaseTexture>;
  30489. private _colorGradingEnabled;
  30490. /**
  30491. * Gets wether the color grading effect is enabled.
  30492. */
  30493. /**
  30494. * Sets wether the color grading effect is enabled.
  30495. */
  30496. colorGradingEnabled: boolean;
  30497. private _colorGradingWithGreenDepth;
  30498. /**
  30499. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30500. */
  30501. /**
  30502. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30503. */
  30504. colorGradingWithGreenDepth: boolean;
  30505. private _colorGradingBGR;
  30506. /**
  30507. * Gets wether the color grading texture contains BGR values.
  30508. */
  30509. /**
  30510. * Sets wether the color grading texture contains BGR values.
  30511. */
  30512. colorGradingBGR: boolean;
  30513. /** @hidden */
  30514. _exposure: number;
  30515. /**
  30516. * Gets the Exposure used in the effect.
  30517. */
  30518. /**
  30519. * Sets the Exposure used in the effect.
  30520. */
  30521. exposure: number;
  30522. private _toneMappingEnabled;
  30523. /**
  30524. * Gets wether the tone mapping effect is enabled.
  30525. */
  30526. /**
  30527. * Sets wether the tone mapping effect is enabled.
  30528. */
  30529. toneMappingEnabled: boolean;
  30530. private _toneMappingType;
  30531. /**
  30532. * Gets the type of tone mapping effect.
  30533. */
  30534. /**
  30535. * Sets the type of tone mapping effect used in BabylonJS.
  30536. */
  30537. toneMappingType: number;
  30538. protected _contrast: number;
  30539. /**
  30540. * Gets the contrast used in the effect.
  30541. */
  30542. /**
  30543. * Sets the contrast used in the effect.
  30544. */
  30545. contrast: number;
  30546. /**
  30547. * Vignette stretch size.
  30548. */
  30549. vignetteStretch: number;
  30550. /**
  30551. * Vignette centre X Offset.
  30552. */
  30553. vignetteCentreX: number;
  30554. /**
  30555. * Vignette centre Y Offset.
  30556. */
  30557. vignetteCentreY: number;
  30558. /**
  30559. * Vignette weight or intensity of the vignette effect.
  30560. */
  30561. vignetteWeight: number;
  30562. /**
  30563. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30564. * if vignetteEnabled is set to true.
  30565. */
  30566. vignetteColor: Color4;
  30567. /**
  30568. * Camera field of view used by the Vignette effect.
  30569. */
  30570. vignetteCameraFov: number;
  30571. private _vignetteBlendMode;
  30572. /**
  30573. * Gets the vignette blend mode allowing different kind of effect.
  30574. */
  30575. /**
  30576. * Sets the vignette blend mode allowing different kind of effect.
  30577. */
  30578. vignetteBlendMode: number;
  30579. private _vignetteEnabled;
  30580. /**
  30581. * Gets wether the vignette effect is enabled.
  30582. */
  30583. /**
  30584. * Sets wether the vignette effect is enabled.
  30585. */
  30586. vignetteEnabled: boolean;
  30587. private _applyByPostProcess;
  30588. /**
  30589. * Gets wether the image processing is applied through a post process or not.
  30590. */
  30591. /**
  30592. * Sets wether the image processing is applied through a post process or not.
  30593. */
  30594. applyByPostProcess: boolean;
  30595. private _isEnabled;
  30596. /**
  30597. * Gets wether the image processing is enabled or not.
  30598. */
  30599. /**
  30600. * Sets wether the image processing is enabled or not.
  30601. */
  30602. isEnabled: boolean;
  30603. /**
  30604. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30605. */
  30606. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30607. /**
  30608. * Method called each time the image processing information changes requires to recompile the effect.
  30609. */
  30610. protected _updateParameters(): void;
  30611. /**
  30612. * Gets the current class name.
  30613. * @return "ImageProcessingConfiguration"
  30614. */
  30615. getClassName(): string;
  30616. /**
  30617. * Prepare the list of uniforms associated with the Image Processing effects.
  30618. * @param uniforms The list of uniforms used in the effect
  30619. * @param defines the list of defines currently in use
  30620. */
  30621. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30622. /**
  30623. * Prepare the list of samplers associated with the Image Processing effects.
  30624. * @param samplersList The list of uniforms used in the effect
  30625. * @param defines the list of defines currently in use
  30626. */
  30627. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30628. /**
  30629. * Prepare the list of defines associated to the shader.
  30630. * @param defines the list of defines to complete
  30631. * @param forPostProcess Define if we are currently in post process mode or not
  30632. */
  30633. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30634. /**
  30635. * Returns true if all the image processing information are ready.
  30636. * @returns True if ready, otherwise, false
  30637. */
  30638. isReady(): boolean;
  30639. /**
  30640. * Binds the image processing to the shader.
  30641. * @param effect The effect to bind to
  30642. * @param aspectRatio Define the current aspect ratio of the effect
  30643. */
  30644. bind(effect: Effect, aspectRatio?: number): void;
  30645. /**
  30646. * Clones the current image processing instance.
  30647. * @return The cloned image processing
  30648. */
  30649. clone(): ImageProcessingConfiguration;
  30650. /**
  30651. * Serializes the current image processing instance to a json representation.
  30652. * @return a JSON representation
  30653. */
  30654. serialize(): any;
  30655. /**
  30656. * Parses the image processing from a json representation.
  30657. * @param source the JSON source to parse
  30658. * @return The parsed image processing
  30659. */
  30660. static Parse(source: any): ImageProcessingConfiguration;
  30661. private static _VIGNETTEMODE_MULTIPLY;
  30662. private static _VIGNETTEMODE_OPAQUE;
  30663. /**
  30664. * Used to apply the vignette as a mix with the pixel color.
  30665. */
  30666. static readonly VIGNETTEMODE_MULTIPLY: number;
  30667. /**
  30668. * Used to apply the vignette as a replacement of the pixel color.
  30669. */
  30670. static readonly VIGNETTEMODE_OPAQUE: number;
  30671. }
  30672. }
  30673. declare module "babylonjs/Materials/fresnelParameters" {
  30674. import { Color3 } from "babylonjs/Maths/math";
  30675. /**
  30676. * This represents all the required information to add a fresnel effect on a material:
  30677. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30678. */
  30679. export class FresnelParameters {
  30680. private _isEnabled;
  30681. /**
  30682. * Define if the fresnel effect is enable or not.
  30683. */
  30684. isEnabled: boolean;
  30685. /**
  30686. * Define the color used on edges (grazing angle)
  30687. */
  30688. leftColor: Color3;
  30689. /**
  30690. * Define the color used on center
  30691. */
  30692. rightColor: Color3;
  30693. /**
  30694. * Define bias applied to computed fresnel term
  30695. */
  30696. bias: number;
  30697. /**
  30698. * Defined the power exponent applied to fresnel term
  30699. */
  30700. power: number;
  30701. /**
  30702. * Clones the current fresnel and its valuues
  30703. * @returns a clone fresnel configuration
  30704. */
  30705. clone(): FresnelParameters;
  30706. /**
  30707. * Serializes the current fresnel parameters to a JSON representation.
  30708. * @return the JSON serialization
  30709. */
  30710. serialize(): any;
  30711. /**
  30712. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30713. * @param parsedFresnelParameters Define the JSON representation
  30714. * @returns the parsed parameters
  30715. */
  30716. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30717. }
  30718. }
  30719. declare module "babylonjs/Misc/decorators" {
  30720. import { Nullable } from "babylonjs/types";
  30721. import { Scene } from "babylonjs/scene";
  30722. import { IAnimatable } from "babylonjs/Misc/tools";
  30723. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30724. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30725. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30726. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30727. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30728. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30729. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30730. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30731. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30732. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30733. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30734. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30735. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30736. /**
  30737. * Decorator used to define property that can be serialized as reference to a camera
  30738. * @param sourceName defines the name of the property to decorate
  30739. */
  30740. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30741. /**
  30742. * Class used to help serialization objects
  30743. */
  30744. export class SerializationHelper {
  30745. /** hidden */
  30746. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30747. /** hidden */
  30748. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30749. /** hidden */
  30750. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30751. /** hidden */
  30752. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30753. /**
  30754. * Appends the serialized animations from the source animations
  30755. * @param source Source containing the animations
  30756. * @param destination Target to store the animations
  30757. */
  30758. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30759. /**
  30760. * Static function used to serialized a specific entity
  30761. * @param entity defines the entity to serialize
  30762. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30763. * @returns a JSON compatible object representing the serialization of the entity
  30764. */
  30765. static Serialize<T>(entity: T, serializationObject?: any): any;
  30766. /**
  30767. * Creates a new entity from a serialization data object
  30768. * @param creationFunction defines a function used to instanciated the new entity
  30769. * @param source defines the source serialization data
  30770. * @param scene defines the hosting scene
  30771. * @param rootUrl defines the root url for resources
  30772. * @returns a new entity
  30773. */
  30774. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30775. /**
  30776. * Clones an object
  30777. * @param creationFunction defines the function used to instanciate the new object
  30778. * @param source defines the source object
  30779. * @returns the cloned object
  30780. */
  30781. static Clone<T>(creationFunction: () => T, source: T): T;
  30782. /**
  30783. * Instanciates a new object based on a source one (some data will be shared between both object)
  30784. * @param creationFunction defines the function used to instanciate the new object
  30785. * @param source defines the source object
  30786. * @returns the new object
  30787. */
  30788. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30789. }
  30790. }
  30791. declare module "babylonjs/Cameras/camera" {
  30792. import { SmartArray } from "babylonjs/Misc/smartArray";
  30793. import { Observable } from "babylonjs/Misc/observable";
  30794. import { Nullable } from "babylonjs/types";
  30795. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30796. import { Scene } from "babylonjs/scene";
  30797. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30798. import { Node } from "babylonjs/node";
  30799. import { Mesh } from "babylonjs/Meshes/mesh";
  30800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30801. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30802. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30803. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30804. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30805. import { Ray } from "babylonjs/Culling/ray";
  30806. /**
  30807. * This is the base class of all the camera used in the application.
  30808. * @see http://doc.babylonjs.com/features/cameras
  30809. */
  30810. export class Camera extends Node {
  30811. /** @hidden */
  30812. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30813. /**
  30814. * This is the default projection mode used by the cameras.
  30815. * It helps recreating a feeling of perspective and better appreciate depth.
  30816. * This is the best way to simulate real life cameras.
  30817. */
  30818. static readonly PERSPECTIVE_CAMERA: number;
  30819. /**
  30820. * This helps creating camera with an orthographic mode.
  30821. * 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.
  30822. */
  30823. static readonly ORTHOGRAPHIC_CAMERA: number;
  30824. /**
  30825. * This is the default FOV mode for perspective cameras.
  30826. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30827. */
  30828. static readonly FOVMODE_VERTICAL_FIXED: number;
  30829. /**
  30830. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30831. */
  30832. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30833. /**
  30834. * This specifies ther is no need for a camera rig.
  30835. * Basically only one eye is rendered corresponding to the camera.
  30836. */
  30837. static readonly RIG_MODE_NONE: number;
  30838. /**
  30839. * Simulates a camera Rig with one blue eye and one red eye.
  30840. * This can be use with 3d blue and red glasses.
  30841. */
  30842. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30843. /**
  30844. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30845. */
  30846. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30847. /**
  30848. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30849. */
  30850. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30851. /**
  30852. * Defines that both eyes of the camera will be rendered over under each other.
  30853. */
  30854. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30855. /**
  30856. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30857. */
  30858. static readonly RIG_MODE_VR: number;
  30859. /**
  30860. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30861. */
  30862. static readonly RIG_MODE_WEBVR: number;
  30863. /**
  30864. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30865. */
  30866. static readonly RIG_MODE_CUSTOM: number;
  30867. /**
  30868. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30869. */
  30870. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30871. /**
  30872. * Define the input manager associated with the camera.
  30873. */
  30874. inputs: CameraInputsManager<Camera>;
  30875. /** @hidden */
  30876. _position: Vector3;
  30877. /**
  30878. * Define the current local position of the camera in the scene
  30879. */
  30880. position: Vector3;
  30881. /**
  30882. * The vector the camera should consider as up.
  30883. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30884. */
  30885. upVector: Vector3;
  30886. /**
  30887. * Define the current limit on the left side for an orthographic camera
  30888. * In scene unit
  30889. */
  30890. orthoLeft: Nullable<number>;
  30891. /**
  30892. * Define the current limit on the right side for an orthographic camera
  30893. * In scene unit
  30894. */
  30895. orthoRight: Nullable<number>;
  30896. /**
  30897. * Define the current limit on the bottom side for an orthographic camera
  30898. * In scene unit
  30899. */
  30900. orthoBottom: Nullable<number>;
  30901. /**
  30902. * Define the current limit on the top side for an orthographic camera
  30903. * In scene unit
  30904. */
  30905. orthoTop: Nullable<number>;
  30906. /**
  30907. * Field Of View is set in Radians. (default is 0.8)
  30908. */
  30909. fov: number;
  30910. /**
  30911. * Define the minimum distance the camera can see from.
  30912. * This is important to note that the depth buffer are not infinite and the closer it starts
  30913. * the more your scene might encounter depth fighting issue.
  30914. */
  30915. minZ: number;
  30916. /**
  30917. * Define the maximum distance the camera can see to.
  30918. * This is important to note that the depth buffer are not infinite and the further it end
  30919. * the more your scene might encounter depth fighting issue.
  30920. */
  30921. maxZ: number;
  30922. /**
  30923. * Define the default inertia of the camera.
  30924. * This helps giving a smooth feeling to the camera movement.
  30925. */
  30926. inertia: number;
  30927. /**
  30928. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30929. */
  30930. mode: number;
  30931. /**
  30932. * Define wether the camera is intermediate.
  30933. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30934. */
  30935. isIntermediate: boolean;
  30936. /**
  30937. * Define the viewport of the camera.
  30938. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30939. */
  30940. viewport: Viewport;
  30941. /**
  30942. * Restricts the camera to viewing objects with the same layerMask.
  30943. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30944. */
  30945. layerMask: number;
  30946. /**
  30947. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30948. */
  30949. fovMode: number;
  30950. /**
  30951. * Rig mode of the camera.
  30952. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30953. * This is normally controlled byt the camera themselves as internal use.
  30954. */
  30955. cameraRigMode: number;
  30956. /**
  30957. * Defines the distance between both "eyes" in case of a RIG
  30958. */
  30959. interaxialDistance: number;
  30960. /**
  30961. * Defines if stereoscopic rendering is done side by side or over under.
  30962. */
  30963. isStereoscopicSideBySide: boolean;
  30964. /**
  30965. * 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
  30966. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30967. * else in the scene.
  30968. */
  30969. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30970. /**
  30971. * When set, the camera will render to this render target instead of the default canvas
  30972. */
  30973. outputRenderTarget: Nullable<RenderTargetTexture>;
  30974. /**
  30975. * @hidden
  30976. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  30977. */
  30978. _useMultiviewToSingleView: boolean;
  30979. /**
  30980. * @hidden
  30981. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  30982. */
  30983. _multiviewTexture: Nullable<RenderTargetTexture>;
  30984. /**
  30985. * @hidden
  30986. * ensures the multiview texture of the camera exists and has the specified width/height
  30987. * @param width height to set on the multiview texture
  30988. * @param height width to set on the multiview texture
  30989. */
  30990. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  30991. /**
  30992. * Observable triggered when the camera view matrix has changed.
  30993. */
  30994. onViewMatrixChangedObservable: Observable<Camera>;
  30995. /**
  30996. * Observable triggered when the camera Projection matrix has changed.
  30997. */
  30998. onProjectionMatrixChangedObservable: Observable<Camera>;
  30999. /**
  31000. * Observable triggered when the inputs have been processed.
  31001. */
  31002. onAfterCheckInputsObservable: Observable<Camera>;
  31003. /**
  31004. * Observable triggered when reset has been called and applied to the camera.
  31005. */
  31006. onRestoreStateObservable: Observable<Camera>;
  31007. /** @hidden */
  31008. _cameraRigParams: any;
  31009. /** @hidden */
  31010. _rigCameras: Camera[];
  31011. /** @hidden */
  31012. _rigPostProcess: Nullable<PostProcess>;
  31013. protected _webvrViewMatrix: Matrix;
  31014. /** @hidden */
  31015. _skipRendering: boolean;
  31016. /** @hidden */
  31017. _projectionMatrix: Matrix;
  31018. /** @hidden */
  31019. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31020. /** @hidden */
  31021. _activeMeshes: SmartArray<AbstractMesh>;
  31022. protected _globalPosition: Vector3;
  31023. /** hidden */
  31024. _computedViewMatrix: Matrix;
  31025. private _doNotComputeProjectionMatrix;
  31026. private _transformMatrix;
  31027. private _frustumPlanes;
  31028. private _refreshFrustumPlanes;
  31029. private _storedFov;
  31030. private _stateStored;
  31031. /**
  31032. * Instantiates a new camera object.
  31033. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31034. * @see http://doc.babylonjs.com/features/cameras
  31035. * @param name Defines the name of the camera in the scene
  31036. * @param position Defines the position of the camera
  31037. * @param scene Defines the scene the camera belongs too
  31038. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31039. */
  31040. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31041. /**
  31042. * Store current camera state (fov, position, etc..)
  31043. * @returns the camera
  31044. */
  31045. storeState(): Camera;
  31046. /**
  31047. * Restores the camera state values if it has been stored. You must call storeState() first
  31048. */
  31049. protected _restoreStateValues(): boolean;
  31050. /**
  31051. * Restored camera state. You must call storeState() first.
  31052. * @returns true if restored and false otherwise
  31053. */
  31054. restoreState(): boolean;
  31055. /**
  31056. * Gets the class name of the camera.
  31057. * @returns the class name
  31058. */
  31059. getClassName(): string;
  31060. /** @hidden */
  31061. readonly _isCamera: boolean;
  31062. /**
  31063. * Gets a string representation of the camera useful for debug purpose.
  31064. * @param fullDetails Defines that a more verboe level of logging is required
  31065. * @returns the string representation
  31066. */
  31067. toString(fullDetails?: boolean): string;
  31068. /**
  31069. * Gets the current world space position of the camera.
  31070. */
  31071. readonly globalPosition: Vector3;
  31072. /**
  31073. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31074. * @returns the active meshe list
  31075. */
  31076. getActiveMeshes(): SmartArray<AbstractMesh>;
  31077. /**
  31078. * Check wether a mesh is part of the current active mesh list of the camera
  31079. * @param mesh Defines the mesh to check
  31080. * @returns true if active, false otherwise
  31081. */
  31082. isActiveMesh(mesh: Mesh): boolean;
  31083. /**
  31084. * Is this camera ready to be used/rendered
  31085. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31086. * @return true if the camera is ready
  31087. */
  31088. isReady(completeCheck?: boolean): boolean;
  31089. /** @hidden */
  31090. _initCache(): void;
  31091. /** @hidden */
  31092. _updateCache(ignoreParentClass?: boolean): void;
  31093. /** @hidden */
  31094. _isSynchronized(): boolean;
  31095. /** @hidden */
  31096. _isSynchronizedViewMatrix(): boolean;
  31097. /** @hidden */
  31098. _isSynchronizedProjectionMatrix(): boolean;
  31099. /**
  31100. * Attach the input controls to a specific dom element to get the input from.
  31101. * @param element Defines the element the controls should be listened from
  31102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31103. */
  31104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31105. /**
  31106. * Detach the current controls from the specified dom element.
  31107. * @param element Defines the element to stop listening the inputs from
  31108. */
  31109. detachControl(element: HTMLElement): void;
  31110. /**
  31111. * Update the camera state according to the different inputs gathered during the frame.
  31112. */
  31113. update(): void;
  31114. /** @hidden */
  31115. _checkInputs(): void;
  31116. /** @hidden */
  31117. readonly rigCameras: Camera[];
  31118. /**
  31119. * Gets the post process used by the rig cameras
  31120. */
  31121. readonly rigPostProcess: Nullable<PostProcess>;
  31122. /**
  31123. * Internal, gets the first post proces.
  31124. * @returns the first post process to be run on this camera.
  31125. */
  31126. _getFirstPostProcess(): Nullable<PostProcess>;
  31127. private _cascadePostProcessesToRigCams;
  31128. /**
  31129. * Attach a post process to the camera.
  31130. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31131. * @param postProcess The post process to attach to the camera
  31132. * @param insertAt The position of the post process in case several of them are in use in the scene
  31133. * @returns the position the post process has been inserted at
  31134. */
  31135. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31136. /**
  31137. * Detach a post process to the camera.
  31138. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31139. * @param postProcess The post process to detach from the camera
  31140. */
  31141. detachPostProcess(postProcess: PostProcess): void;
  31142. /**
  31143. * Gets the current world matrix of the camera
  31144. */
  31145. getWorldMatrix(): Matrix;
  31146. /** @hidden */
  31147. _getViewMatrix(): Matrix;
  31148. /**
  31149. * Gets the current view matrix of the camera.
  31150. * @param force forces the camera to recompute the matrix without looking at the cached state
  31151. * @returns the view matrix
  31152. */
  31153. getViewMatrix(force?: boolean): Matrix;
  31154. /**
  31155. * Freeze the projection matrix.
  31156. * It will prevent the cache check of the camera projection compute and can speed up perf
  31157. * if no parameter of the camera are meant to change
  31158. * @param projection Defines manually a projection if necessary
  31159. */
  31160. freezeProjectionMatrix(projection?: Matrix): void;
  31161. /**
  31162. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31163. */
  31164. unfreezeProjectionMatrix(): void;
  31165. /**
  31166. * Gets the current projection matrix of the camera.
  31167. * @param force forces the camera to recompute the matrix without looking at the cached state
  31168. * @returns the projection matrix
  31169. */
  31170. getProjectionMatrix(force?: boolean): Matrix;
  31171. /**
  31172. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31173. * @returns a Matrix
  31174. */
  31175. getTransformationMatrix(): Matrix;
  31176. private _updateFrustumPlanes;
  31177. /**
  31178. * Checks if a cullable object (mesh...) is in the camera frustum
  31179. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31180. * @param target The object to check
  31181. * @returns true if the object is in frustum otherwise false
  31182. */
  31183. isInFrustum(target: ICullable): boolean;
  31184. /**
  31185. * Checks if a cullable object (mesh...) is in the camera frustum
  31186. * Unlike isInFrustum this cheks the full bounding box
  31187. * @param target The object to check
  31188. * @returns true if the object is in frustum otherwise false
  31189. */
  31190. isCompletelyInFrustum(target: ICullable): boolean;
  31191. /**
  31192. * Gets a ray in the forward direction from the camera.
  31193. * @param length Defines the length of the ray to create
  31194. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31195. * @param origin Defines the start point of the ray which defaults to the camera position
  31196. * @returns the forward ray
  31197. */
  31198. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31199. /**
  31200. * Releases resources associated with this node.
  31201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31203. */
  31204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31205. /** @hidden */
  31206. _isLeftCamera: boolean;
  31207. /**
  31208. * Gets the left camera of a rig setup in case of Rigged Camera
  31209. */
  31210. readonly isLeftCamera: boolean;
  31211. /** @hidden */
  31212. _isRightCamera: boolean;
  31213. /**
  31214. * Gets the right camera of a rig setup in case of Rigged Camera
  31215. */
  31216. readonly isRightCamera: boolean;
  31217. /**
  31218. * Gets the left camera of a rig setup in case of Rigged Camera
  31219. */
  31220. readonly leftCamera: Nullable<FreeCamera>;
  31221. /**
  31222. * Gets the right camera of a rig setup in case of Rigged Camera
  31223. */
  31224. readonly rightCamera: Nullable<FreeCamera>;
  31225. /**
  31226. * Gets the left camera target of a rig setup in case of Rigged Camera
  31227. * @returns the target position
  31228. */
  31229. getLeftTarget(): Nullable<Vector3>;
  31230. /**
  31231. * Gets the right camera target of a rig setup in case of Rigged Camera
  31232. * @returns the target position
  31233. */
  31234. getRightTarget(): Nullable<Vector3>;
  31235. /**
  31236. * @hidden
  31237. */
  31238. setCameraRigMode(mode: number, rigParams: any): void;
  31239. /** @hidden */
  31240. static _setStereoscopicRigMode(camera: Camera): void;
  31241. /** @hidden */
  31242. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31243. /** @hidden */
  31244. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31245. /** @hidden */
  31246. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31247. /** @hidden */
  31248. _getVRProjectionMatrix(): Matrix;
  31249. protected _updateCameraRotationMatrix(): void;
  31250. protected _updateWebVRCameraRotationMatrix(): void;
  31251. /**
  31252. * This function MUST be overwritten by the different WebVR cameras available.
  31253. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31254. * @hidden
  31255. */
  31256. _getWebVRProjectionMatrix(): Matrix;
  31257. /**
  31258. * This function MUST be overwritten by the different WebVR cameras available.
  31259. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31260. * @hidden
  31261. */
  31262. _getWebVRViewMatrix(): Matrix;
  31263. /** @hidden */
  31264. setCameraRigParameter(name: string, value: any): void;
  31265. /**
  31266. * needs to be overridden by children so sub has required properties to be copied
  31267. * @hidden
  31268. */
  31269. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31270. /**
  31271. * May need to be overridden by children
  31272. * @hidden
  31273. */
  31274. _updateRigCameras(): void;
  31275. /** @hidden */
  31276. _setupInputs(): void;
  31277. /**
  31278. * Serialiaze the camera setup to a json represention
  31279. * @returns the JSON representation
  31280. */
  31281. serialize(): any;
  31282. /**
  31283. * Clones the current camera.
  31284. * @param name The cloned camera name
  31285. * @returns the cloned camera
  31286. */
  31287. clone(name: string): Camera;
  31288. /**
  31289. * Gets the direction of the camera relative to a given local axis.
  31290. * @param localAxis Defines the reference axis to provide a relative direction.
  31291. * @return the direction
  31292. */
  31293. getDirection(localAxis: Vector3): Vector3;
  31294. /**
  31295. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31296. * @param localAxis Defines the reference axis to provide a relative direction.
  31297. * @param result Defines the vector to store the result in
  31298. */
  31299. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31300. /**
  31301. * Gets a camera constructor for a given camera type
  31302. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31303. * @param name The name of the camera the result will be able to instantiate
  31304. * @param scene The scene the result will construct the camera in
  31305. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31306. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31307. * @returns a factory method to construc the camera
  31308. */
  31309. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31310. /**
  31311. * Compute the world matrix of the camera.
  31312. * @returns the camera workd matrix
  31313. */
  31314. computeWorldMatrix(): Matrix;
  31315. /**
  31316. * Parse a JSON and creates the camera from the parsed information
  31317. * @param parsedCamera The JSON to parse
  31318. * @param scene The scene to instantiate the camera in
  31319. * @returns the newly constructed camera
  31320. */
  31321. static Parse(parsedCamera: any, scene: Scene): Camera;
  31322. }
  31323. }
  31324. declare module "babylonjs/Misc/tools" {
  31325. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31326. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31327. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31328. import { Observable } from "babylonjs/Misc/observable";
  31329. import { DomManagement } from "babylonjs/Misc/domManagement";
  31330. import { WebRequest } from "babylonjs/Misc/webRequest";
  31331. import { Camera } from "babylonjs/Cameras/camera";
  31332. import { Engine } from "babylonjs/Engines/engine";
  31333. import { Animation } from "babylonjs/Animations/animation";
  31334. /**
  31335. * Interface for any object that can request an animation frame
  31336. */
  31337. export interface ICustomAnimationFrameRequester {
  31338. /**
  31339. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31340. */
  31341. renderFunction?: Function;
  31342. /**
  31343. * Called to request the next frame to render to
  31344. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31345. */
  31346. requestAnimationFrame: Function;
  31347. /**
  31348. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31349. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31350. */
  31351. requestID?: number;
  31352. }
  31353. /**
  31354. * Interface containing an array of animations
  31355. */
  31356. export interface IAnimatable {
  31357. /**
  31358. * Array of animations
  31359. */
  31360. animations: Array<Animation>;
  31361. }
  31362. /** Interface used by value gradients (color, factor, ...) */
  31363. export interface IValueGradient {
  31364. /**
  31365. * Gets or sets the gradient value (between 0 and 1)
  31366. */
  31367. gradient: number;
  31368. }
  31369. /** Class used to store color4 gradient */
  31370. export class ColorGradient implements IValueGradient {
  31371. /**
  31372. * Gets or sets the gradient value (between 0 and 1)
  31373. */
  31374. gradient: number;
  31375. /**
  31376. * Gets or sets first associated color
  31377. */
  31378. color1: Color4;
  31379. /**
  31380. * Gets or sets second associated color
  31381. */
  31382. color2?: Color4;
  31383. /**
  31384. * Will get a color picked randomly between color1 and color2.
  31385. * If color2 is undefined then color1 will be used
  31386. * @param result defines the target Color4 to store the result in
  31387. */
  31388. getColorToRef(result: Color4): void;
  31389. }
  31390. /** Class used to store color 3 gradient */
  31391. export class Color3Gradient implements IValueGradient {
  31392. /**
  31393. * Gets or sets the gradient value (between 0 and 1)
  31394. */
  31395. gradient: number;
  31396. /**
  31397. * Gets or sets the associated color
  31398. */
  31399. color: Color3;
  31400. }
  31401. /** Class used to store factor gradient */
  31402. export class FactorGradient implements IValueGradient {
  31403. /**
  31404. * Gets or sets the gradient value (between 0 and 1)
  31405. */
  31406. gradient: number;
  31407. /**
  31408. * Gets or sets first associated factor
  31409. */
  31410. factor1: number;
  31411. /**
  31412. * Gets or sets second associated factor
  31413. */
  31414. factor2?: number;
  31415. /**
  31416. * Will get a number picked randomly between factor1 and factor2.
  31417. * If factor2 is undefined then factor1 will be used
  31418. * @returns the picked number
  31419. */
  31420. getFactor(): number;
  31421. }
  31422. /**
  31423. * @ignore
  31424. * Application error to support additional information when loading a file
  31425. */
  31426. export class LoadFileError extends Error {
  31427. /** defines the optional web request */
  31428. request?: WebRequest | undefined;
  31429. private static _setPrototypeOf;
  31430. /**
  31431. * Creates a new LoadFileError
  31432. * @param message defines the message of the error
  31433. * @param request defines the optional web request
  31434. */
  31435. constructor(message: string,
  31436. /** defines the optional web request */
  31437. request?: WebRequest | undefined);
  31438. }
  31439. /**
  31440. * Class used to define a retry strategy when error happens while loading assets
  31441. */
  31442. export class RetryStrategy {
  31443. /**
  31444. * Function used to defines an exponential back off strategy
  31445. * @param maxRetries defines the maximum number of retries (3 by default)
  31446. * @param baseInterval defines the interval between retries
  31447. * @returns the strategy function to use
  31448. */
  31449. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31450. }
  31451. /**
  31452. * File request interface
  31453. */
  31454. export interface IFileRequest {
  31455. /**
  31456. * Raised when the request is complete (success or error).
  31457. */
  31458. onCompleteObservable: Observable<IFileRequest>;
  31459. /**
  31460. * Aborts the request for a file.
  31461. */
  31462. abort: () => void;
  31463. }
  31464. /**
  31465. * Class containing a set of static utilities functions
  31466. */
  31467. export class Tools {
  31468. /**
  31469. * Gets or sets the base URL to use to load assets
  31470. */
  31471. static BaseUrl: string;
  31472. /**
  31473. * Enable/Disable Custom HTTP Request Headers globally.
  31474. * default = false
  31475. * @see CustomRequestHeaders
  31476. */
  31477. static UseCustomRequestHeaders: boolean;
  31478. /**
  31479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31480. * i.e. when loading files, where the server/service expects an Authorization header
  31481. */
  31482. static CustomRequestHeaders: {
  31483. [key: string]: string;
  31484. };
  31485. /**
  31486. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31487. */
  31488. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31489. /**
  31490. * Default behaviour for cors in the application.
  31491. * It can be a string if the expected behavior is identical in the entire app.
  31492. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31493. */
  31494. static CorsBehavior: string | ((url: string | string[]) => string);
  31495. /**
  31496. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31497. * @ignorenaming
  31498. */
  31499. static UseFallbackTexture: boolean;
  31500. /**
  31501. * Use this object to register external classes like custom textures or material
  31502. * to allow the laoders to instantiate them
  31503. */
  31504. static RegisteredExternalClasses: {
  31505. [key: string]: Object;
  31506. };
  31507. /**
  31508. * Texture content used if a texture cannot loaded
  31509. * @ignorenaming
  31510. */
  31511. static fallbackTexture: string;
  31512. /**
  31513. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31514. * @param u defines the coordinate on X axis
  31515. * @param v defines the coordinate on Y axis
  31516. * @param width defines the width of the source data
  31517. * @param height defines the height of the source data
  31518. * @param pixels defines the source byte array
  31519. * @param color defines the output color
  31520. */
  31521. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31522. /**
  31523. * Interpolates between a and b via alpha
  31524. * @param a The lower value (returned when alpha = 0)
  31525. * @param b The upper value (returned when alpha = 1)
  31526. * @param alpha The interpolation-factor
  31527. * @return The mixed value
  31528. */
  31529. static Mix(a: number, b: number, alpha: number): number;
  31530. /**
  31531. * Tries to instantiate a new object from a given class name
  31532. * @param className defines the class name to instantiate
  31533. * @returns the new object or null if the system was not able to do the instantiation
  31534. */
  31535. static Instantiate(className: string): any;
  31536. /**
  31537. * Provides a slice function that will work even on IE
  31538. * @param data defines the array to slice
  31539. * @param start defines the start of the data (optional)
  31540. * @param end defines the end of the data (optional)
  31541. * @returns the new sliced array
  31542. */
  31543. static Slice<T>(data: T, start?: number, end?: number): T;
  31544. /**
  31545. * Polyfill for setImmediate
  31546. * @param action defines the action to execute after the current execution block
  31547. */
  31548. static SetImmediate(action: () => void): void;
  31549. /**
  31550. * Function indicating if a number is an exponent of 2
  31551. * @param value defines the value to test
  31552. * @returns true if the value is an exponent of 2
  31553. */
  31554. static IsExponentOfTwo(value: number): boolean;
  31555. private static _tmpFloatArray;
  31556. /**
  31557. * Returns the nearest 32-bit single precision float representation of a Number
  31558. * @param value A Number. If the parameter is of a different type, it will get converted
  31559. * to a number or to NaN if it cannot be converted
  31560. * @returns number
  31561. */
  31562. static FloatRound(value: number): number;
  31563. /**
  31564. * Find the next highest power of two.
  31565. * @param x Number to start search from.
  31566. * @return Next highest power of two.
  31567. */
  31568. static CeilingPOT(x: number): number;
  31569. /**
  31570. * Find the next lowest power of two.
  31571. * @param x Number to start search from.
  31572. * @return Next lowest power of two.
  31573. */
  31574. static FloorPOT(x: number): number;
  31575. /**
  31576. * Find the nearest power of two.
  31577. * @param x Number to start search from.
  31578. * @return Next nearest power of two.
  31579. */
  31580. static NearestPOT(x: number): number;
  31581. /**
  31582. * Get the closest exponent of two
  31583. * @param value defines the value to approximate
  31584. * @param max defines the maximum value to return
  31585. * @param mode defines how to define the closest value
  31586. * @returns closest exponent of two of the given value
  31587. */
  31588. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31589. /**
  31590. * Extracts the filename from a path
  31591. * @param path defines the path to use
  31592. * @returns the filename
  31593. */
  31594. static GetFilename(path: string): string;
  31595. /**
  31596. * Extracts the "folder" part of a path (everything before the filename).
  31597. * @param uri The URI to extract the info from
  31598. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31599. * @returns The "folder" part of the path
  31600. */
  31601. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31602. /**
  31603. * Extracts text content from a DOM element hierarchy
  31604. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31605. */
  31606. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31607. /**
  31608. * Convert an angle in radians to degrees
  31609. * @param angle defines the angle to convert
  31610. * @returns the angle in degrees
  31611. */
  31612. static ToDegrees(angle: number): number;
  31613. /**
  31614. * Convert an angle in degrees to radians
  31615. * @param angle defines the angle to convert
  31616. * @returns the angle in radians
  31617. */
  31618. static ToRadians(angle: number): number;
  31619. /**
  31620. * Encode a buffer to a base64 string
  31621. * @param buffer defines the buffer to encode
  31622. * @returns the encoded string
  31623. */
  31624. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31625. /**
  31626. * Extracts minimum and maximum values from a list of indexed positions
  31627. * @param positions defines the positions to use
  31628. * @param indices defines the indices to the positions
  31629. * @param indexStart defines the start index
  31630. * @param indexCount defines the end index
  31631. * @param bias defines bias value to add to the result
  31632. * @return minimum and maximum values
  31633. */
  31634. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31635. minimum: Vector3;
  31636. maximum: Vector3;
  31637. };
  31638. /**
  31639. * Extracts minimum and maximum values from a list of positions
  31640. * @param positions defines the positions to use
  31641. * @param start defines the start index in the positions array
  31642. * @param count defines the number of positions to handle
  31643. * @param bias defines bias value to add to the result
  31644. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31645. * @return minimum and maximum values
  31646. */
  31647. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31648. minimum: Vector3;
  31649. maximum: Vector3;
  31650. };
  31651. /**
  31652. * Returns an array if obj is not an array
  31653. * @param obj defines the object to evaluate as an array
  31654. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31655. * @returns either obj directly if obj is an array or a new array containing obj
  31656. */
  31657. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31658. /**
  31659. * Gets the pointer prefix to use
  31660. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31661. */
  31662. static GetPointerPrefix(): string;
  31663. /**
  31664. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31665. * @param func - the function to be called
  31666. * @param requester - the object that will request the next frame. Falls back to window.
  31667. * @returns frame number
  31668. */
  31669. static QueueNewFrame(func: () => void, requester?: any): number;
  31670. /**
  31671. * Ask the browser to promote the current element to fullscreen rendering mode
  31672. * @param element defines the DOM element to promote
  31673. */
  31674. static RequestFullscreen(element: HTMLElement): void;
  31675. /**
  31676. * Asks the browser to exit fullscreen mode
  31677. */
  31678. static ExitFullscreen(): void;
  31679. /**
  31680. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31681. * @param url define the url we are trying
  31682. * @param element define the dom element where to configure the cors policy
  31683. */
  31684. static SetCorsBehavior(url: string | string[], element: {
  31685. crossOrigin: string | null;
  31686. }): void;
  31687. /**
  31688. * Removes unwanted characters from an url
  31689. * @param url defines the url to clean
  31690. * @returns the cleaned url
  31691. */
  31692. static CleanUrl(url: string): string;
  31693. /**
  31694. * Gets or sets a function used to pre-process url before using them to load assets
  31695. */
  31696. static PreprocessUrl: (url: string) => string;
  31697. /**
  31698. * Loads an image as an HTMLImageElement.
  31699. * @param input url string, ArrayBuffer, or Blob to load
  31700. * @param onLoad callback called when the image successfully loads
  31701. * @param onError callback called when the image fails to load
  31702. * @param offlineProvider offline provider for caching
  31703. * @returns the HTMLImageElement of the loaded image
  31704. */
  31705. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31706. /**
  31707. * Loads a file
  31708. * @param url url string, ArrayBuffer, or Blob to load
  31709. * @param onSuccess callback called when the file successfully loads
  31710. * @param onProgress callback called while file is loading (if the server supports this mode)
  31711. * @param offlineProvider defines the offline provider for caching
  31712. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31713. * @param onError callback called when the file fails to load
  31714. * @returns a file request object
  31715. */
  31716. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31717. /**
  31718. * Load a script (identified by an url). When the url returns, the
  31719. * content of this file is added into a new script element, attached to the DOM (body element)
  31720. * @param scriptUrl defines the url of the script to laod
  31721. * @param onSuccess defines the callback called when the script is loaded
  31722. * @param onError defines the callback to call if an error occurs
  31723. */
  31724. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31725. /**
  31726. * Loads a file from a blob
  31727. * @param fileToLoad defines the blob to use
  31728. * @param callback defines the callback to call when data is loaded
  31729. * @param progressCallback defines the callback to call during loading process
  31730. * @returns a file request object
  31731. */
  31732. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31733. /**
  31734. * Loads a file
  31735. * @param fileToLoad defines the file to load
  31736. * @param callback defines the callback to call when data is loaded
  31737. * @param progressCallBack defines the callback to call during loading process
  31738. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31739. * @returns a file request object
  31740. */
  31741. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31742. /**
  31743. * Creates a data url from a given string content
  31744. * @param content defines the content to convert
  31745. * @returns the new data url link
  31746. */
  31747. static FileAsURL(content: string): string;
  31748. /**
  31749. * Format the given number to a specific decimal format
  31750. * @param value defines the number to format
  31751. * @param decimals defines the number of decimals to use
  31752. * @returns the formatted string
  31753. */
  31754. static Format(value: number, decimals?: number): string;
  31755. /**
  31756. * Checks if a given vector is inside a specific range
  31757. * @param v defines the vector to test
  31758. * @param min defines the minimum range
  31759. * @param max defines the maximum range
  31760. */
  31761. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31762. /**
  31763. * Tries to copy an object by duplicating every property
  31764. * @param source defines the source object
  31765. * @param destination defines the target object
  31766. * @param doNotCopyList defines a list of properties to avoid
  31767. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31768. */
  31769. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31770. /**
  31771. * Gets a boolean indicating if the given object has no own property
  31772. * @param obj defines the object to test
  31773. * @returns true if object has no own property
  31774. */
  31775. static IsEmpty(obj: any): boolean;
  31776. /**
  31777. * Function used to register events at window level
  31778. * @param events defines the events to register
  31779. */
  31780. static RegisterTopRootEvents(events: {
  31781. name: string;
  31782. handler: Nullable<(e: FocusEvent) => any>;
  31783. }[]): void;
  31784. /**
  31785. * Function used to unregister events from window level
  31786. * @param events defines the events to unregister
  31787. */
  31788. static UnregisterTopRootEvents(events: {
  31789. name: string;
  31790. handler: Nullable<(e: FocusEvent) => any>;
  31791. }[]): void;
  31792. /**
  31793. * @ignore
  31794. */
  31795. static _ScreenshotCanvas: HTMLCanvasElement;
  31796. /**
  31797. * Dumps the current bound framebuffer
  31798. * @param width defines the rendering width
  31799. * @param height defines the rendering height
  31800. * @param engine defines the hosting engine
  31801. * @param successCallback defines the callback triggered once the data are available
  31802. * @param mimeType defines the mime type of the result
  31803. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31804. */
  31805. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31806. /**
  31807. * Converts the canvas data to blob.
  31808. * This acts as a polyfill for browsers not supporting the to blob function.
  31809. * @param canvas Defines the canvas to extract the data from
  31810. * @param successCallback Defines the callback triggered once the data are available
  31811. * @param mimeType Defines the mime type of the result
  31812. */
  31813. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31814. /**
  31815. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31816. * @param successCallback defines the callback triggered once the data are available
  31817. * @param mimeType defines the mime type of the result
  31818. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31819. */
  31820. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31821. /**
  31822. * Downloads a blob in the browser
  31823. * @param blob defines the blob to download
  31824. * @param fileName defines the name of the downloaded file
  31825. */
  31826. static Download(blob: Blob, fileName: string): void;
  31827. /**
  31828. * Captures a screenshot of the current rendering
  31829. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31830. * @param engine defines the rendering engine
  31831. * @param camera defines the source camera
  31832. * @param size This parameter can be set to a single number or to an object with the
  31833. * following (optional) properties: precision, width, height. If a single number is passed,
  31834. * it will be used for both width and height. If an object is passed, the screenshot size
  31835. * will be derived from the parameters. The precision property is a multiplier allowing
  31836. * rendering at a higher or lower resolution
  31837. * @param successCallback defines the callback receives a single parameter which contains the
  31838. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31839. * src parameter of an <img> to display it
  31840. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31841. * Check your browser for supported MIME types
  31842. */
  31843. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31844. /**
  31845. * Generates an image screenshot from the specified camera.
  31846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31847. * @param engine The engine to use for rendering
  31848. * @param camera The camera to use for rendering
  31849. * @param size This parameter can be set to a single number or to an object with the
  31850. * following (optional) properties: precision, width, height. If a single number is passed,
  31851. * it will be used for both width and height. If an object is passed, the screenshot size
  31852. * will be derived from the parameters. The precision property is a multiplier allowing
  31853. * rendering at a higher or lower resolution
  31854. * @param successCallback The callback receives a single parameter which contains the
  31855. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31856. * src parameter of an <img> to display it
  31857. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31858. * Check your browser for supported MIME types
  31859. * @param samples Texture samples (default: 1)
  31860. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31861. * @param fileName A name for for the downloaded file.
  31862. */
  31863. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31864. /**
  31865. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31866. * Be aware Math.random() could cause collisions, but:
  31867. * "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"
  31868. * @returns a pseudo random id
  31869. */
  31870. static RandomId(): string;
  31871. /**
  31872. * Test if the given uri is a base64 string
  31873. * @param uri The uri to test
  31874. * @return True if the uri is a base64 string or false otherwise
  31875. */
  31876. static IsBase64(uri: string): boolean;
  31877. /**
  31878. * Decode the given base64 uri.
  31879. * @param uri The uri to decode
  31880. * @return The decoded base64 data.
  31881. */
  31882. static DecodeBase64(uri: string): ArrayBuffer;
  31883. /**
  31884. * No log
  31885. */
  31886. static readonly NoneLogLevel: number;
  31887. /**
  31888. * Only message logs
  31889. */
  31890. static readonly MessageLogLevel: number;
  31891. /**
  31892. * Only warning logs
  31893. */
  31894. static readonly WarningLogLevel: number;
  31895. /**
  31896. * Only error logs
  31897. */
  31898. static readonly ErrorLogLevel: number;
  31899. /**
  31900. * All logs
  31901. */
  31902. static readonly AllLogLevel: number;
  31903. /**
  31904. * Gets a value indicating the number of loading errors
  31905. * @ignorenaming
  31906. */
  31907. static readonly errorsCount: number;
  31908. /**
  31909. * Callback called when a new log is added
  31910. */
  31911. static OnNewCacheEntry: (entry: string) => void;
  31912. /**
  31913. * Log a message to the console
  31914. * @param message defines the message to log
  31915. */
  31916. static Log(message: string): void;
  31917. /**
  31918. * Write a warning message to the console
  31919. * @param message defines the message to log
  31920. */
  31921. static Warn(message: string): void;
  31922. /**
  31923. * Write an error message to the console
  31924. * @param message defines the message to log
  31925. */
  31926. static Error(message: string): void;
  31927. /**
  31928. * Gets current log cache (list of logs)
  31929. */
  31930. static readonly LogCache: string;
  31931. /**
  31932. * Clears the log cache
  31933. */
  31934. static ClearLogCache(): void;
  31935. /**
  31936. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31937. */
  31938. static LogLevels: number;
  31939. /**
  31940. * Checks if the loaded document was accessed via `file:`-Protocol.
  31941. * @returns boolean
  31942. */
  31943. static IsFileURL(): boolean;
  31944. /**
  31945. * Checks if the window object exists
  31946. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31947. */
  31948. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31949. /**
  31950. * No performance log
  31951. */
  31952. static readonly PerformanceNoneLogLevel: number;
  31953. /**
  31954. * Use user marks to log performance
  31955. */
  31956. static readonly PerformanceUserMarkLogLevel: number;
  31957. /**
  31958. * Log performance to the console
  31959. */
  31960. static readonly PerformanceConsoleLogLevel: number;
  31961. private static _performance;
  31962. /**
  31963. * Sets the current performance log level
  31964. */
  31965. static PerformanceLogLevel: number;
  31966. private static _StartPerformanceCounterDisabled;
  31967. private static _EndPerformanceCounterDisabled;
  31968. private static _StartUserMark;
  31969. private static _EndUserMark;
  31970. private static _StartPerformanceConsole;
  31971. private static _EndPerformanceConsole;
  31972. /**
  31973. * Starts a performance counter
  31974. */
  31975. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31976. /**
  31977. * Ends a specific performance coutner
  31978. */
  31979. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31980. /**
  31981. * Gets either window.performance.now() if supported or Date.now() else
  31982. */
  31983. static readonly Now: number;
  31984. /**
  31985. * This method will return the name of the class used to create the instance of the given object.
  31986. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31987. * @param object the object to get the class name from
  31988. * @param isType defines if the object is actually a type
  31989. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31990. */
  31991. static GetClassName(object: any, isType?: boolean): string;
  31992. /**
  31993. * Gets the first element of an array satisfying a given predicate
  31994. * @param array defines the array to browse
  31995. * @param predicate defines the predicate to use
  31996. * @returns null if not found or the element
  31997. */
  31998. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31999. /**
  32000. * This method will return the name of the full name of the class, including its owning module (if any).
  32001. * 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).
  32002. * @param object the object to get the class name from
  32003. * @param isType defines if the object is actually a type
  32004. * @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.
  32005. * @ignorenaming
  32006. */
  32007. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32008. /**
  32009. * Returns a promise that resolves after the given amount of time.
  32010. * @param delay Number of milliseconds to delay
  32011. * @returns Promise that resolves after the given amount of time
  32012. */
  32013. static DelayAsync(delay: number): Promise<void>;
  32014. /**
  32015. * Gets the current gradient from an array of IValueGradient
  32016. * @param ratio defines the current ratio to get
  32017. * @param gradients defines the array of IValueGradient
  32018. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32019. */
  32020. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32021. }
  32022. /**
  32023. * This class is used to track a performance counter which is number based.
  32024. * The user has access to many properties which give statistics of different nature.
  32025. *
  32026. * The implementer can track two kinds of Performance Counter: time and count.
  32027. * 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.
  32028. * 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.
  32029. */
  32030. export class PerfCounter {
  32031. /**
  32032. * Gets or sets a global boolean to turn on and off all the counters
  32033. */
  32034. static Enabled: boolean;
  32035. /**
  32036. * Returns the smallest value ever
  32037. */
  32038. readonly min: number;
  32039. /**
  32040. * Returns the biggest value ever
  32041. */
  32042. readonly max: number;
  32043. /**
  32044. * Returns the average value since the performance counter is running
  32045. */
  32046. readonly average: number;
  32047. /**
  32048. * Returns the average value of the last second the counter was monitored
  32049. */
  32050. readonly lastSecAverage: number;
  32051. /**
  32052. * Returns the current value
  32053. */
  32054. readonly current: number;
  32055. /**
  32056. * Gets the accumulated total
  32057. */
  32058. readonly total: number;
  32059. /**
  32060. * Gets the total value count
  32061. */
  32062. readonly count: number;
  32063. /**
  32064. * Creates a new counter
  32065. */
  32066. constructor();
  32067. /**
  32068. * Call this method to start monitoring a new frame.
  32069. * 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.
  32070. */
  32071. fetchNewFrame(): void;
  32072. /**
  32073. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32074. * @param newCount the count value to add to the monitored count
  32075. * @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.
  32076. */
  32077. addCount(newCount: number, fetchResult: boolean): void;
  32078. /**
  32079. * Start monitoring this performance counter
  32080. */
  32081. beginMonitoring(): void;
  32082. /**
  32083. * Compute the time lapsed since the previous beginMonitoring() call.
  32084. * @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
  32085. */
  32086. endMonitoring(newFrame?: boolean): void;
  32087. private _fetchResult;
  32088. private _startMonitoringTime;
  32089. private _min;
  32090. private _max;
  32091. private _average;
  32092. private _current;
  32093. private _totalValueCount;
  32094. private _totalAccumulated;
  32095. private _lastSecAverage;
  32096. private _lastSecAccumulated;
  32097. private _lastSecTime;
  32098. private _lastSecValueCount;
  32099. }
  32100. /**
  32101. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32102. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32103. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32104. * @param name The name of the class, case should be preserved
  32105. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32106. */
  32107. export function className(name: string, module?: string): (target: Object) => void;
  32108. /**
  32109. * An implementation of a loop for asynchronous functions.
  32110. */
  32111. export class AsyncLoop {
  32112. /**
  32113. * Defines the number of iterations for the loop
  32114. */
  32115. iterations: number;
  32116. /**
  32117. * Defines the current index of the loop.
  32118. */
  32119. index: number;
  32120. private _done;
  32121. private _fn;
  32122. private _successCallback;
  32123. /**
  32124. * Constructor.
  32125. * @param iterations the number of iterations.
  32126. * @param func the function to run each iteration
  32127. * @param successCallback the callback that will be called upon succesful execution
  32128. * @param offset starting offset.
  32129. */
  32130. constructor(
  32131. /**
  32132. * Defines the number of iterations for the loop
  32133. */
  32134. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32135. /**
  32136. * Execute the next iteration. Must be called after the last iteration was finished.
  32137. */
  32138. executeNext(): void;
  32139. /**
  32140. * Break the loop and run the success callback.
  32141. */
  32142. breakLoop(): void;
  32143. /**
  32144. * Create and run an async loop.
  32145. * @param iterations the number of iterations.
  32146. * @param fn the function to run each iteration
  32147. * @param successCallback the callback that will be called upon succesful execution
  32148. * @param offset starting offset.
  32149. * @returns the created async loop object
  32150. */
  32151. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32152. /**
  32153. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32154. * @param iterations total number of iterations
  32155. * @param syncedIterations number of synchronous iterations in each async iteration.
  32156. * @param fn the function to call each iteration.
  32157. * @param callback a success call back that will be called when iterating stops.
  32158. * @param breakFunction a break condition (optional)
  32159. * @param timeout timeout settings for the setTimeout function. default - 0.
  32160. * @returns the created async loop object
  32161. */
  32162. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32163. }
  32164. }
  32165. declare module "babylonjs/Collisions/collisionCoordinator" {
  32166. import { Nullable } from "babylonjs/types";
  32167. import { Scene } from "babylonjs/scene";
  32168. import { Vector3 } from "babylonjs/Maths/math";
  32169. import { Collider } from "babylonjs/Collisions/collider";
  32170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32171. /** @hidden */
  32172. export interface ICollisionCoordinator {
  32173. createCollider(): Collider;
  32174. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32175. init(scene: Scene): void;
  32176. }
  32177. /** @hidden */
  32178. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32179. private _scene;
  32180. private _scaledPosition;
  32181. private _scaledVelocity;
  32182. private _finalPosition;
  32183. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32184. createCollider(): Collider;
  32185. init(scene: Scene): void;
  32186. private _collideWithWorld;
  32187. }
  32188. }
  32189. declare module "babylonjs/Animations/animationGroup" {
  32190. import { Animatable } from "babylonjs/Animations/animatable";
  32191. import { Animation } from "babylonjs/Animations/animation";
  32192. import { Scene, IDisposable } from "babylonjs/scene";
  32193. import { Observable } from "babylonjs/Misc/observable";
  32194. import { Nullable } from "babylonjs/types";
  32195. /**
  32196. * This class defines the direct association between an animation and a target
  32197. */
  32198. export class TargetedAnimation {
  32199. /**
  32200. * Animation to perform
  32201. */
  32202. animation: Animation;
  32203. /**
  32204. * Target to animate
  32205. */
  32206. target: any;
  32207. }
  32208. /**
  32209. * Use this class to create coordinated animations on multiple targets
  32210. */
  32211. export class AnimationGroup implements IDisposable {
  32212. /** The name of the animation group */
  32213. name: string;
  32214. private _scene;
  32215. private _targetedAnimations;
  32216. private _animatables;
  32217. private _from;
  32218. private _to;
  32219. private _isStarted;
  32220. private _isPaused;
  32221. private _speedRatio;
  32222. /**
  32223. * Gets or sets the unique id of the node
  32224. */
  32225. uniqueId: number;
  32226. /**
  32227. * This observable will notify when one animation have ended
  32228. */
  32229. onAnimationEndObservable: Observable<TargetedAnimation>;
  32230. /**
  32231. * Observer raised when one animation loops
  32232. */
  32233. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32234. /**
  32235. * This observable will notify when all animations have ended.
  32236. */
  32237. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32238. /**
  32239. * This observable will notify when all animations have paused.
  32240. */
  32241. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32242. /**
  32243. * This observable will notify when all animations are playing.
  32244. */
  32245. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32246. /**
  32247. * Gets the first frame
  32248. */
  32249. readonly from: number;
  32250. /**
  32251. * Gets the last frame
  32252. */
  32253. readonly to: number;
  32254. /**
  32255. * Define if the animations are started
  32256. */
  32257. readonly isStarted: boolean;
  32258. /**
  32259. * Gets a value indicating that the current group is playing
  32260. */
  32261. readonly isPlaying: boolean;
  32262. /**
  32263. * Gets or sets the speed ratio to use for all animations
  32264. */
  32265. /**
  32266. * Gets or sets the speed ratio to use for all animations
  32267. */
  32268. speedRatio: number;
  32269. /**
  32270. * Gets the targeted animations for this animation group
  32271. */
  32272. readonly targetedAnimations: Array<TargetedAnimation>;
  32273. /**
  32274. * returning the list of animatables controlled by this animation group.
  32275. */
  32276. readonly animatables: Array<Animatable>;
  32277. /**
  32278. * Instantiates a new Animation Group.
  32279. * This helps managing several animations at once.
  32280. * @see http://doc.babylonjs.com/how_to/group
  32281. * @param name Defines the name of the group
  32282. * @param scene Defines the scene the group belongs to
  32283. */
  32284. constructor(
  32285. /** The name of the animation group */
  32286. name: string, scene?: Nullable<Scene>);
  32287. /**
  32288. * Add an animation (with its target) in the group
  32289. * @param animation defines the animation we want to add
  32290. * @param target defines the target of the animation
  32291. * @returns the TargetedAnimation object
  32292. */
  32293. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32294. /**
  32295. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32296. * It can add constant keys at begin or end
  32297. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32298. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32299. * @returns the animation group
  32300. */
  32301. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32302. /**
  32303. * Start all animations on given targets
  32304. * @param loop defines if animations must loop
  32305. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32306. * @param from defines the from key (optional)
  32307. * @param to defines the to key (optional)
  32308. * @returns the current animation group
  32309. */
  32310. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32311. /**
  32312. * Pause all animations
  32313. * @returns the animation group
  32314. */
  32315. pause(): AnimationGroup;
  32316. /**
  32317. * Play all animations to initial state
  32318. * This function will start() the animations if they were not started or will restart() them if they were paused
  32319. * @param loop defines if animations must loop
  32320. * @returns the animation group
  32321. */
  32322. play(loop?: boolean): AnimationGroup;
  32323. /**
  32324. * Reset all animations to initial state
  32325. * @returns the animation group
  32326. */
  32327. reset(): AnimationGroup;
  32328. /**
  32329. * Restart animations from key 0
  32330. * @returns the animation group
  32331. */
  32332. restart(): AnimationGroup;
  32333. /**
  32334. * Stop all animations
  32335. * @returns the animation group
  32336. */
  32337. stop(): AnimationGroup;
  32338. /**
  32339. * Set animation weight for all animatables
  32340. * @param weight defines the weight to use
  32341. * @return the animationGroup
  32342. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32343. */
  32344. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32345. /**
  32346. * Synchronize and normalize all animatables with a source animatable
  32347. * @param root defines the root animatable to synchronize with
  32348. * @return the animationGroup
  32349. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32350. */
  32351. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32352. /**
  32353. * Goes to a specific frame in this animation group
  32354. * @param frame the frame number to go to
  32355. * @return the animationGroup
  32356. */
  32357. goToFrame(frame: number): AnimationGroup;
  32358. /**
  32359. * Dispose all associated resources
  32360. */
  32361. dispose(): void;
  32362. private _checkAnimationGroupEnded;
  32363. /**
  32364. * Clone the current animation group and returns a copy
  32365. * @param newName defines the name of the new group
  32366. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32367. * @returns the new aniamtion group
  32368. */
  32369. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32370. /**
  32371. * Returns a new AnimationGroup object parsed from the source provided.
  32372. * @param parsedAnimationGroup defines the source
  32373. * @param scene defines the scene that will receive the animationGroup
  32374. * @returns a new AnimationGroup
  32375. */
  32376. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32377. /**
  32378. * Returns the string "AnimationGroup"
  32379. * @returns "AnimationGroup"
  32380. */
  32381. getClassName(): string;
  32382. /**
  32383. * Creates a detailled string about the object
  32384. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32385. * @returns a string representing the object
  32386. */
  32387. toString(fullDetails?: boolean): string;
  32388. }
  32389. }
  32390. declare module "babylonjs/scene" {
  32391. import { Nullable } from "babylonjs/types";
  32392. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32393. import { Observable } from "babylonjs/Misc/observable";
  32394. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32395. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32396. import { Geometry } from "babylonjs/Meshes/geometry";
  32397. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32400. import { Mesh } from "babylonjs/Meshes/mesh";
  32401. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32402. import { Bone } from "babylonjs/Bones/bone";
  32403. import { Skeleton } from "babylonjs/Bones/skeleton";
  32404. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32405. import { Camera } from "babylonjs/Cameras/camera";
  32406. import { AbstractScene } from "babylonjs/abstractScene";
  32407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32409. import { Material } from "babylonjs/Materials/material";
  32410. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32411. import { Effect } from "babylonjs/Materials/effect";
  32412. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32413. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32414. import { Light } from "babylonjs/Lights/light";
  32415. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32416. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32417. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32418. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32420. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32421. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32422. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32423. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32424. import { Engine } from "babylonjs/Engines/engine";
  32425. import { Node } from "babylonjs/node";
  32426. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32427. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32428. import { WebRequest } from "babylonjs/Misc/webRequest";
  32429. import { Ray } from "babylonjs/Culling/ray";
  32430. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32431. import { Animation } from "babylonjs/Animations/animation";
  32432. import { Animatable } from "babylonjs/Animations/animatable";
  32433. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32434. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32435. import { Collider } from "babylonjs/Collisions/collider";
  32436. /**
  32437. * Define an interface for all classes that will hold resources
  32438. */
  32439. export interface IDisposable {
  32440. /**
  32441. * Releases all held resources
  32442. */
  32443. dispose(): void;
  32444. }
  32445. /** Interface defining initialization parameters for Scene class */
  32446. export interface SceneOptions {
  32447. /**
  32448. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32449. * It will improve performance when the number of geometries becomes important.
  32450. */
  32451. useGeometryUniqueIdsMap?: boolean;
  32452. /**
  32453. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32454. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32455. */
  32456. useMaterialMeshMap?: boolean;
  32457. /**
  32458. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32459. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32460. */
  32461. useClonedMeshhMap?: boolean;
  32462. }
  32463. /**
  32464. * Represents a scene to be rendered by the engine.
  32465. * @see http://doc.babylonjs.com/features/scene
  32466. */
  32467. export class Scene extends AbstractScene implements IAnimatable {
  32468. private static _uniqueIdCounter;
  32469. /** The fog is deactivated */
  32470. static readonly FOGMODE_NONE: number;
  32471. /** The fog density is following an exponential function */
  32472. static readonly FOGMODE_EXP: number;
  32473. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32474. static readonly FOGMODE_EXP2: number;
  32475. /** The fog density is following a linear function. */
  32476. static readonly FOGMODE_LINEAR: number;
  32477. /**
  32478. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32480. */
  32481. static MinDeltaTime: number;
  32482. /**
  32483. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32484. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32485. */
  32486. static MaxDeltaTime: number;
  32487. /**
  32488. * Factory used to create the default material.
  32489. * @param name The name of the material to create
  32490. * @param scene The scene to create the material for
  32491. * @returns The default material
  32492. */
  32493. static DefaultMaterialFactory(scene: Scene): Material;
  32494. /**
  32495. * Factory used to create the a collision coordinator.
  32496. * @returns The collision coordinator
  32497. */
  32498. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32499. /** @hidden */
  32500. readonly _isScene: boolean;
  32501. /**
  32502. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32503. */
  32504. autoClear: boolean;
  32505. /**
  32506. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32507. */
  32508. autoClearDepthAndStencil: boolean;
  32509. /**
  32510. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32511. */
  32512. clearColor: Color4;
  32513. /**
  32514. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32515. */
  32516. ambientColor: Color3;
  32517. /**
  32518. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32519. * It should only be one of the following (if not the default embedded one):
  32520. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32521. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32522. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32523. * The material properties need to be setup according to the type of texture in use.
  32524. */
  32525. environmentBRDFTexture: BaseTexture;
  32526. /** @hidden */
  32527. protected _environmentTexture: Nullable<BaseTexture>;
  32528. /**
  32529. * Texture used in all pbr material as the reflection texture.
  32530. * As in the majority of the scene they are the same (exception for multi room and so on),
  32531. * this is easier to reference from here than from all the materials.
  32532. */
  32533. /**
  32534. * Texture used in all pbr material as the reflection texture.
  32535. * As in the majority of the scene they are the same (exception for multi room and so on),
  32536. * this is easier to set here than in all the materials.
  32537. */
  32538. environmentTexture: Nullable<BaseTexture>;
  32539. /** @hidden */
  32540. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32541. /**
  32542. * Default image processing configuration used either in the rendering
  32543. * Forward main pass or through the imageProcessingPostProcess if present.
  32544. * As in the majority of the scene they are the same (exception for multi camera),
  32545. * this is easier to reference from here than from all the materials and post process.
  32546. *
  32547. * No setter as we it is a shared configuration, you can set the values instead.
  32548. */
  32549. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32550. private _forceWireframe;
  32551. /**
  32552. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32553. */
  32554. forceWireframe: boolean;
  32555. private _forcePointsCloud;
  32556. /**
  32557. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32558. */
  32559. forcePointsCloud: boolean;
  32560. /**
  32561. * Gets or sets the active clipplane 1
  32562. */
  32563. clipPlane: Nullable<Plane>;
  32564. /**
  32565. * Gets or sets the active clipplane 2
  32566. */
  32567. clipPlane2: Nullable<Plane>;
  32568. /**
  32569. * Gets or sets the active clipplane 3
  32570. */
  32571. clipPlane3: Nullable<Plane>;
  32572. /**
  32573. * Gets or sets the active clipplane 4
  32574. */
  32575. clipPlane4: Nullable<Plane>;
  32576. /**
  32577. * Gets or sets a boolean indicating if animations are enabled
  32578. */
  32579. animationsEnabled: boolean;
  32580. private _animationPropertiesOverride;
  32581. /**
  32582. * Gets or sets the animation properties override
  32583. */
  32584. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32585. /**
  32586. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32587. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32588. */
  32589. useConstantAnimationDeltaTime: boolean;
  32590. /**
  32591. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32592. * Please note that it requires to run a ray cast through the scene on every frame
  32593. */
  32594. constantlyUpdateMeshUnderPointer: boolean;
  32595. /**
  32596. * Defines the HTML cursor to use when hovering over interactive elements
  32597. */
  32598. hoverCursor: string;
  32599. /**
  32600. * Defines the HTML default cursor to use (empty by default)
  32601. */
  32602. defaultCursor: string;
  32603. /**
  32604. * This is used to call preventDefault() on pointer down
  32605. * in order to block unwanted artifacts like system double clicks
  32606. */
  32607. preventDefaultOnPointerDown: boolean;
  32608. /**
  32609. * This is used to call preventDefault() on pointer up
  32610. * in order to block unwanted artifacts like system double clicks
  32611. */
  32612. preventDefaultOnPointerUp: boolean;
  32613. /**
  32614. * Gets or sets user defined metadata
  32615. */
  32616. metadata: any;
  32617. /**
  32618. * For internal use only. Please do not use.
  32619. */
  32620. reservedDataStore: any;
  32621. /**
  32622. * Gets the name of the plugin used to load this scene (null by default)
  32623. */
  32624. loadingPluginName: string;
  32625. /**
  32626. * Use this array to add regular expressions used to disable offline support for specific urls
  32627. */
  32628. disableOfflineSupportExceptionRules: RegExp[];
  32629. /**
  32630. * An event triggered when the scene is disposed.
  32631. */
  32632. onDisposeObservable: Observable<Scene>;
  32633. private _onDisposeObserver;
  32634. /** Sets a function to be executed when this scene is disposed. */
  32635. onDispose: () => void;
  32636. /**
  32637. * An event triggered before rendering the scene (right after animations and physics)
  32638. */
  32639. onBeforeRenderObservable: Observable<Scene>;
  32640. private _onBeforeRenderObserver;
  32641. /** Sets a function to be executed before rendering this scene */
  32642. beforeRender: Nullable<() => void>;
  32643. /**
  32644. * An event triggered after rendering the scene
  32645. */
  32646. onAfterRenderObservable: Observable<Scene>;
  32647. private _onAfterRenderObserver;
  32648. /** Sets a function to be executed after rendering this scene */
  32649. afterRender: Nullable<() => void>;
  32650. /**
  32651. * An event triggered before animating the scene
  32652. */
  32653. onBeforeAnimationsObservable: Observable<Scene>;
  32654. /**
  32655. * An event triggered after animations processing
  32656. */
  32657. onAfterAnimationsObservable: Observable<Scene>;
  32658. /**
  32659. * An event triggered before draw calls are ready to be sent
  32660. */
  32661. onBeforeDrawPhaseObservable: Observable<Scene>;
  32662. /**
  32663. * An event triggered after draw calls have been sent
  32664. */
  32665. onAfterDrawPhaseObservable: Observable<Scene>;
  32666. /**
  32667. * An event triggered when the scene is ready
  32668. */
  32669. onReadyObservable: Observable<Scene>;
  32670. /**
  32671. * An event triggered before rendering a camera
  32672. */
  32673. onBeforeCameraRenderObservable: Observable<Camera>;
  32674. private _onBeforeCameraRenderObserver;
  32675. /** Sets a function to be executed before rendering a camera*/
  32676. beforeCameraRender: () => void;
  32677. /**
  32678. * An event triggered after rendering a camera
  32679. */
  32680. onAfterCameraRenderObservable: Observable<Camera>;
  32681. private _onAfterCameraRenderObserver;
  32682. /** Sets a function to be executed after rendering a camera*/
  32683. afterCameraRender: () => void;
  32684. /**
  32685. * An event triggered when active meshes evaluation is about to start
  32686. */
  32687. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32688. /**
  32689. * An event triggered when active meshes evaluation is done
  32690. */
  32691. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32692. /**
  32693. * An event triggered when particles rendering is about to start
  32694. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32695. */
  32696. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32697. /**
  32698. * An event triggered when particles rendering is done
  32699. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32700. */
  32701. onAfterParticlesRenderingObservable: Observable<Scene>;
  32702. /**
  32703. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32704. */
  32705. onDataLoadedObservable: Observable<Scene>;
  32706. /**
  32707. * An event triggered when a camera is created
  32708. */
  32709. onNewCameraAddedObservable: Observable<Camera>;
  32710. /**
  32711. * An event triggered when a camera is removed
  32712. */
  32713. onCameraRemovedObservable: Observable<Camera>;
  32714. /**
  32715. * An event triggered when a light is created
  32716. */
  32717. onNewLightAddedObservable: Observable<Light>;
  32718. /**
  32719. * An event triggered when a light is removed
  32720. */
  32721. onLightRemovedObservable: Observable<Light>;
  32722. /**
  32723. * An event triggered when a geometry is created
  32724. */
  32725. onNewGeometryAddedObservable: Observable<Geometry>;
  32726. /**
  32727. * An event triggered when a geometry is removed
  32728. */
  32729. onGeometryRemovedObservable: Observable<Geometry>;
  32730. /**
  32731. * An event triggered when a transform node is created
  32732. */
  32733. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32734. /**
  32735. * An event triggered when a transform node is removed
  32736. */
  32737. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32738. /**
  32739. * An event triggered when a mesh is created
  32740. */
  32741. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32742. /**
  32743. * An event triggered when a mesh is removed
  32744. */
  32745. onMeshRemovedObservable: Observable<AbstractMesh>;
  32746. /**
  32747. * An event triggered when a skeleton is created
  32748. */
  32749. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32750. /**
  32751. * An event triggered when a skeleton is removed
  32752. */
  32753. onSkeletonRemovedObservable: Observable<Skeleton>;
  32754. /**
  32755. * An event triggered when a material is created
  32756. */
  32757. onNewMaterialAddedObservable: Observable<Material>;
  32758. /**
  32759. * An event triggered when a material is removed
  32760. */
  32761. onMaterialRemovedObservable: Observable<Material>;
  32762. /**
  32763. * An event triggered when a texture is created
  32764. */
  32765. onNewTextureAddedObservable: Observable<BaseTexture>;
  32766. /**
  32767. * An event triggered when a texture is removed
  32768. */
  32769. onTextureRemovedObservable: Observable<BaseTexture>;
  32770. /**
  32771. * An event triggered when render targets are about to be rendered
  32772. * Can happen multiple times per frame.
  32773. */
  32774. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32775. /**
  32776. * An event triggered when render targets were rendered.
  32777. * Can happen multiple times per frame.
  32778. */
  32779. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32780. /**
  32781. * An event triggered before calculating deterministic simulation step
  32782. */
  32783. onBeforeStepObservable: Observable<Scene>;
  32784. /**
  32785. * An event triggered after calculating deterministic simulation step
  32786. */
  32787. onAfterStepObservable: Observable<Scene>;
  32788. /**
  32789. * An event triggered when the activeCamera property is updated
  32790. */
  32791. onActiveCameraChanged: Observable<Scene>;
  32792. /**
  32793. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32794. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32795. * 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)
  32796. */
  32797. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32798. /**
  32799. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32800. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32801. * 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)
  32802. */
  32803. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32804. /**
  32805. * This Observable will when a mesh has been imported into the scene.
  32806. */
  32807. onMeshImportedObservable: Observable<AbstractMesh>;
  32808. /**
  32809. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32810. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32811. */
  32812. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32813. /** @hidden */
  32814. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32815. /**
  32816. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32817. */
  32818. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32819. /**
  32820. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32821. */
  32822. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32823. /**
  32824. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32825. */
  32826. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32827. private _onPointerMove;
  32828. private _onPointerDown;
  32829. private _onPointerUp;
  32830. /** Callback called when a pointer move is detected */
  32831. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32832. /** Callback called when a pointer down is detected */
  32833. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32834. /** Callback called when a pointer up is detected */
  32835. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32836. /** Callback called when a pointer pick is detected */
  32837. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32838. /**
  32839. * 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).
  32840. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32841. */
  32842. onPrePointerObservable: Observable<PointerInfoPre>;
  32843. /**
  32844. * Observable event triggered each time an input event is received from the rendering canvas
  32845. */
  32846. onPointerObservable: Observable<PointerInfo>;
  32847. /**
  32848. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32849. */
  32850. readonly unTranslatedPointer: Vector2;
  32851. /** The distance in pixel that you have to move to prevent some events */
  32852. static DragMovementThreshold: number;
  32853. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32854. static LongPressDelay: number;
  32855. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32856. static DoubleClickDelay: number;
  32857. /** If you need to check double click without raising a single click at first click, enable this flag */
  32858. static ExclusiveDoubleClickMode: boolean;
  32859. private _initClickEvent;
  32860. private _initActionManager;
  32861. private _delayedSimpleClick;
  32862. private _delayedSimpleClickTimeout;
  32863. private _previousDelayedSimpleClickTimeout;
  32864. private _meshPickProceed;
  32865. private _previousButtonPressed;
  32866. private _currentPickResult;
  32867. private _previousPickResult;
  32868. private _totalPointersPressed;
  32869. private _doubleClickOccured;
  32870. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32871. cameraToUseForPointers: Nullable<Camera>;
  32872. private _pointerX;
  32873. private _pointerY;
  32874. private _unTranslatedPointerX;
  32875. private _unTranslatedPointerY;
  32876. private _startingPointerPosition;
  32877. private _previousStartingPointerPosition;
  32878. private _startingPointerTime;
  32879. private _previousStartingPointerTime;
  32880. private _pointerCaptures;
  32881. private _timeAccumulator;
  32882. private _currentStepId;
  32883. private _currentInternalStep;
  32884. /** @hidden */
  32885. _mirroredCameraPosition: Nullable<Vector3>;
  32886. /**
  32887. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32888. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32889. */
  32890. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32891. /**
  32892. * Observable event triggered each time an keyboard event is received from the hosting window
  32893. */
  32894. onKeyboardObservable: Observable<KeyboardInfo>;
  32895. private _onKeyDown;
  32896. private _onKeyUp;
  32897. private _onCanvasFocusObserver;
  32898. private _onCanvasBlurObserver;
  32899. private _useRightHandedSystem;
  32900. /**
  32901. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32902. */
  32903. useRightHandedSystem: boolean;
  32904. /**
  32905. * Sets the step Id used by deterministic lock step
  32906. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32907. * @param newStepId defines the step Id
  32908. */
  32909. setStepId(newStepId: number): void;
  32910. /**
  32911. * Gets the step Id used by deterministic lock step
  32912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32913. * @returns the step Id
  32914. */
  32915. getStepId(): number;
  32916. /**
  32917. * Gets the internal step used by deterministic lock step
  32918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32919. * @returns the internal step
  32920. */
  32921. getInternalStep(): number;
  32922. private _fogEnabled;
  32923. /**
  32924. * Gets or sets a boolean indicating if fog is enabled on this scene
  32925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32926. * (Default is true)
  32927. */
  32928. fogEnabled: boolean;
  32929. private _fogMode;
  32930. /**
  32931. * Gets or sets the fog mode to use
  32932. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32933. * | mode | value |
  32934. * | --- | --- |
  32935. * | FOGMODE_NONE | 0 |
  32936. * | FOGMODE_EXP | 1 |
  32937. * | FOGMODE_EXP2 | 2 |
  32938. * | FOGMODE_LINEAR | 3 |
  32939. */
  32940. fogMode: number;
  32941. /**
  32942. * Gets or sets the fog color to use
  32943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32944. * (Default is Color3(0.2, 0.2, 0.3))
  32945. */
  32946. fogColor: Color3;
  32947. /**
  32948. * Gets or sets the fog density to use
  32949. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32950. * (Default is 0.1)
  32951. */
  32952. fogDensity: number;
  32953. /**
  32954. * Gets or sets the fog start distance to use
  32955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32956. * (Default is 0)
  32957. */
  32958. fogStart: number;
  32959. /**
  32960. * Gets or sets the fog end distance to use
  32961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32962. * (Default is 1000)
  32963. */
  32964. fogEnd: number;
  32965. private _shadowsEnabled;
  32966. /**
  32967. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32968. */
  32969. shadowsEnabled: boolean;
  32970. private _lightsEnabled;
  32971. /**
  32972. * Gets or sets a boolean indicating if lights are enabled on this scene
  32973. */
  32974. lightsEnabled: boolean;
  32975. /** All of the active cameras added to this scene. */
  32976. activeCameras: Camera[];
  32977. private _activeCamera;
  32978. /** Gets or sets the current active camera */
  32979. activeCamera: Nullable<Camera>;
  32980. private _defaultMaterial;
  32981. /** The default material used on meshes when no material is affected */
  32982. /** The default material used on meshes when no material is affected */
  32983. defaultMaterial: Material;
  32984. private _texturesEnabled;
  32985. /**
  32986. * Gets or sets a boolean indicating if textures are enabled on this scene
  32987. */
  32988. texturesEnabled: boolean;
  32989. /**
  32990. * Gets or sets a boolean indicating if particles are enabled on this scene
  32991. */
  32992. particlesEnabled: boolean;
  32993. /**
  32994. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32995. */
  32996. spritesEnabled: boolean;
  32997. private _skeletonsEnabled;
  32998. /**
  32999. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33000. */
  33001. skeletonsEnabled: boolean;
  33002. /**
  33003. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33004. */
  33005. lensFlaresEnabled: boolean;
  33006. /**
  33007. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33009. */
  33010. collisionsEnabled: boolean;
  33011. private _collisionCoordinator;
  33012. /** @hidden */
  33013. readonly collisionCoordinator: ICollisionCoordinator;
  33014. /**
  33015. * Defines the gravity applied to this scene (used only for collisions)
  33016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33017. */
  33018. gravity: Vector3;
  33019. /**
  33020. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33021. */
  33022. postProcessesEnabled: boolean;
  33023. /**
  33024. * The list of postprocesses added to the scene
  33025. */
  33026. postProcesses: PostProcess[];
  33027. /**
  33028. * Gets the current postprocess manager
  33029. */
  33030. postProcessManager: PostProcessManager;
  33031. /**
  33032. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33033. */
  33034. renderTargetsEnabled: boolean;
  33035. /**
  33036. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33037. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33038. */
  33039. dumpNextRenderTargets: boolean;
  33040. /**
  33041. * The list of user defined render targets added to the scene
  33042. */
  33043. customRenderTargets: RenderTargetTexture[];
  33044. /**
  33045. * Defines if texture loading must be delayed
  33046. * If true, textures will only be loaded when they need to be rendered
  33047. */
  33048. useDelayedTextureLoading: boolean;
  33049. /**
  33050. * Gets the list of meshes imported to the scene through SceneLoader
  33051. */
  33052. importedMeshesFiles: String[];
  33053. /**
  33054. * Gets or sets a boolean indicating if probes are enabled on this scene
  33055. */
  33056. probesEnabled: boolean;
  33057. /**
  33058. * Gets or sets the current offline provider to use to store scene data
  33059. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33060. */
  33061. offlineProvider: IOfflineProvider;
  33062. /**
  33063. * Gets or sets the action manager associated with the scene
  33064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33065. */
  33066. actionManager: AbstractActionManager;
  33067. private _meshesForIntersections;
  33068. /**
  33069. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33070. */
  33071. proceduralTexturesEnabled: boolean;
  33072. private _engine;
  33073. private _totalVertices;
  33074. /** @hidden */
  33075. _activeIndices: PerfCounter;
  33076. /** @hidden */
  33077. _activeParticles: PerfCounter;
  33078. /** @hidden */
  33079. _activeBones: PerfCounter;
  33080. private _animationRatio;
  33081. /** @hidden */
  33082. _animationTimeLast: number;
  33083. /** @hidden */
  33084. _animationTime: number;
  33085. /**
  33086. * Gets or sets a general scale for animation speed
  33087. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33088. */
  33089. animationTimeScale: number;
  33090. /** @hidden */
  33091. _cachedMaterial: Nullable<Material>;
  33092. /** @hidden */
  33093. _cachedEffect: Nullable<Effect>;
  33094. /** @hidden */
  33095. _cachedVisibility: Nullable<number>;
  33096. private _renderId;
  33097. private _frameId;
  33098. private _executeWhenReadyTimeoutId;
  33099. private _intermediateRendering;
  33100. private _viewUpdateFlag;
  33101. private _projectionUpdateFlag;
  33102. /** @hidden */
  33103. _toBeDisposed: Nullable<IDisposable>[];
  33104. private _activeRequests;
  33105. /** @hidden */
  33106. _pendingData: any[];
  33107. private _isDisposed;
  33108. /**
  33109. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33110. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33111. */
  33112. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33113. private _activeMeshes;
  33114. private _processedMaterials;
  33115. private _renderTargets;
  33116. /** @hidden */
  33117. _activeParticleSystems: SmartArray<IParticleSystem>;
  33118. private _activeSkeletons;
  33119. private _softwareSkinnedMeshes;
  33120. private _renderingManager;
  33121. /** @hidden */
  33122. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33123. private _transformMatrix;
  33124. private _transformMatrixR;
  33125. private _sceneUbo;
  33126. private _multiviewSceneUbo;
  33127. private _viewMatrix;
  33128. private _projectionMatrix;
  33129. private _wheelEventName;
  33130. /** @hidden */
  33131. _forcedViewPosition: Nullable<Vector3>;
  33132. private _frustumPlanes;
  33133. /**
  33134. * Gets the list of frustum planes (built from the active camera)
  33135. */
  33136. readonly frustumPlanes: Plane[];
  33137. /**
  33138. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33139. * This is useful if there are more lights that the maximum simulteanous authorized
  33140. */
  33141. requireLightSorting: boolean;
  33142. /** @hidden */
  33143. readonly useMaterialMeshMap: boolean;
  33144. /** @hidden */
  33145. readonly useClonedMeshhMap: boolean;
  33146. private _pointerOverMesh;
  33147. private _pickedDownMesh;
  33148. private _pickedUpMesh;
  33149. private _externalData;
  33150. private _uid;
  33151. /**
  33152. * @hidden
  33153. * Backing store of defined scene components.
  33154. */
  33155. _components: ISceneComponent[];
  33156. /**
  33157. * @hidden
  33158. * Backing store of defined scene components.
  33159. */
  33160. _serializableComponents: ISceneSerializableComponent[];
  33161. /**
  33162. * List of components to register on the next registration step.
  33163. */
  33164. private _transientComponents;
  33165. /**
  33166. * Registers the transient components if needed.
  33167. */
  33168. private _registerTransientComponents;
  33169. /**
  33170. * @hidden
  33171. * Add a component to the scene.
  33172. * Note that the ccomponent could be registered on th next frame if this is called after
  33173. * the register component stage.
  33174. * @param component Defines the component to add to the scene
  33175. */
  33176. _addComponent(component: ISceneComponent): void;
  33177. /**
  33178. * @hidden
  33179. * Gets a component from the scene.
  33180. * @param name defines the name of the component to retrieve
  33181. * @returns the component or null if not present
  33182. */
  33183. _getComponent(name: string): Nullable<ISceneComponent>;
  33184. /**
  33185. * @hidden
  33186. * Defines the actions happening before camera updates.
  33187. */
  33188. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33189. /**
  33190. * @hidden
  33191. * Defines the actions happening before clear the canvas.
  33192. */
  33193. _beforeClearStage: Stage<SimpleStageAction>;
  33194. /**
  33195. * @hidden
  33196. * Defines the actions when collecting render targets for the frame.
  33197. */
  33198. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33199. /**
  33200. * @hidden
  33201. * Defines the actions happening for one camera in the frame.
  33202. */
  33203. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33204. /**
  33205. * @hidden
  33206. * Defines the actions happening during the per mesh ready checks.
  33207. */
  33208. _isReadyForMeshStage: Stage<MeshStageAction>;
  33209. /**
  33210. * @hidden
  33211. * Defines the actions happening before evaluate active mesh checks.
  33212. */
  33213. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33214. /**
  33215. * @hidden
  33216. * Defines the actions happening during the evaluate sub mesh checks.
  33217. */
  33218. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33219. /**
  33220. * @hidden
  33221. * Defines the actions happening during the active mesh stage.
  33222. */
  33223. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33224. /**
  33225. * @hidden
  33226. * Defines the actions happening during the per camera render target step.
  33227. */
  33228. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33229. /**
  33230. * @hidden
  33231. * Defines the actions happening just before the active camera is drawing.
  33232. */
  33233. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33234. /**
  33235. * @hidden
  33236. * Defines the actions happening just before a render target is drawing.
  33237. */
  33238. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33239. /**
  33240. * @hidden
  33241. * Defines the actions happening just before a rendering group is drawing.
  33242. */
  33243. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33244. /**
  33245. * @hidden
  33246. * Defines the actions happening just before a mesh is drawing.
  33247. */
  33248. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33249. /**
  33250. * @hidden
  33251. * Defines the actions happening just after a mesh has been drawn.
  33252. */
  33253. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33254. /**
  33255. * @hidden
  33256. * Defines the actions happening just after a rendering group has been drawn.
  33257. */
  33258. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33259. /**
  33260. * @hidden
  33261. * Defines the actions happening just after the active camera has been drawn.
  33262. */
  33263. _afterCameraDrawStage: Stage<CameraStageAction>;
  33264. /**
  33265. * @hidden
  33266. * Defines the actions happening just after a render target has been drawn.
  33267. */
  33268. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33269. /**
  33270. * @hidden
  33271. * Defines the actions happening just after rendering all cameras and computing intersections.
  33272. */
  33273. _afterRenderStage: Stage<SimpleStageAction>;
  33274. /**
  33275. * @hidden
  33276. * Defines the actions happening when a pointer move event happens.
  33277. */
  33278. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33279. /**
  33280. * @hidden
  33281. * Defines the actions happening when a pointer down event happens.
  33282. */
  33283. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33284. /**
  33285. * @hidden
  33286. * Defines the actions happening when a pointer up event happens.
  33287. */
  33288. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33289. /**
  33290. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33291. */
  33292. private geometriesByUniqueId;
  33293. /**
  33294. * Creates a new Scene
  33295. * @param engine defines the engine to use to render this scene
  33296. * @param options defines the scene options
  33297. */
  33298. constructor(engine: Engine, options?: SceneOptions);
  33299. private _defaultMeshCandidates;
  33300. /**
  33301. * @hidden
  33302. */
  33303. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33304. private _defaultSubMeshCandidates;
  33305. /**
  33306. * @hidden
  33307. */
  33308. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33309. /**
  33310. * Sets the default candidate providers for the scene.
  33311. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33312. * and getCollidingSubMeshCandidates to their default function
  33313. */
  33314. setDefaultCandidateProviders(): void;
  33315. /**
  33316. * Gets the mesh that is currently under the pointer
  33317. */
  33318. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33319. /**
  33320. * Gets or sets the current on-screen X position of the pointer
  33321. */
  33322. pointerX: number;
  33323. /**
  33324. * Gets or sets the current on-screen Y position of the pointer
  33325. */
  33326. pointerY: number;
  33327. /**
  33328. * Gets the cached material (ie. the latest rendered one)
  33329. * @returns the cached material
  33330. */
  33331. getCachedMaterial(): Nullable<Material>;
  33332. /**
  33333. * Gets the cached effect (ie. the latest rendered one)
  33334. * @returns the cached effect
  33335. */
  33336. getCachedEffect(): Nullable<Effect>;
  33337. /**
  33338. * Gets the cached visibility state (ie. the latest rendered one)
  33339. * @returns the cached visibility state
  33340. */
  33341. getCachedVisibility(): Nullable<number>;
  33342. /**
  33343. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33344. * @param material defines the current material
  33345. * @param effect defines the current effect
  33346. * @param visibility defines the current visibility state
  33347. * @returns true if one parameter is not cached
  33348. */
  33349. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33350. /**
  33351. * Gets the engine associated with the scene
  33352. * @returns an Engine
  33353. */
  33354. getEngine(): Engine;
  33355. /**
  33356. * Gets the total number of vertices rendered per frame
  33357. * @returns the total number of vertices rendered per frame
  33358. */
  33359. getTotalVertices(): number;
  33360. /**
  33361. * Gets the performance counter for total vertices
  33362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33363. */
  33364. readonly totalVerticesPerfCounter: PerfCounter;
  33365. /**
  33366. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33367. * @returns the total number of active indices rendered per frame
  33368. */
  33369. getActiveIndices(): number;
  33370. /**
  33371. * Gets the performance counter for active indices
  33372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33373. */
  33374. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33375. /**
  33376. * Gets the total number of active particles rendered per frame
  33377. * @returns the total number of active particles rendered per frame
  33378. */
  33379. getActiveParticles(): number;
  33380. /**
  33381. * Gets the performance counter for active particles
  33382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33383. */
  33384. readonly activeParticlesPerfCounter: PerfCounter;
  33385. /**
  33386. * Gets the total number of active bones rendered per frame
  33387. * @returns the total number of active bones rendered per frame
  33388. */
  33389. getActiveBones(): number;
  33390. /**
  33391. * Gets the performance counter for active bones
  33392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33393. */
  33394. readonly activeBonesPerfCounter: PerfCounter;
  33395. /**
  33396. * Gets the array of active meshes
  33397. * @returns an array of AbstractMesh
  33398. */
  33399. getActiveMeshes(): SmartArray<AbstractMesh>;
  33400. /**
  33401. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33402. * @returns a number
  33403. */
  33404. getAnimationRatio(): number;
  33405. /**
  33406. * Gets an unique Id for the current render phase
  33407. * @returns a number
  33408. */
  33409. getRenderId(): number;
  33410. /**
  33411. * Gets an unique Id for the current frame
  33412. * @returns a number
  33413. */
  33414. getFrameId(): number;
  33415. /** Call this function if you want to manually increment the render Id*/
  33416. incrementRenderId(): void;
  33417. private _updatePointerPosition;
  33418. private _createUbo;
  33419. private _createMultiviewUbo;
  33420. private _setRayOnPointerInfo;
  33421. /**
  33422. * Use this method to simulate a pointer move on a mesh
  33423. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33424. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33425. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33426. * @returns the current scene
  33427. */
  33428. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33429. private _processPointerMove;
  33430. private _checkPrePointerObservable;
  33431. /**
  33432. * Use this method to simulate a pointer down on a mesh
  33433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33436. * @returns the current scene
  33437. */
  33438. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33439. private _processPointerDown;
  33440. /**
  33441. * Use this method to simulate a pointer up on a mesh
  33442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33445. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33446. * @returns the current scene
  33447. */
  33448. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33449. private _processPointerUp;
  33450. /**
  33451. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33452. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33453. * @returns true if the pointer was captured
  33454. */
  33455. isPointerCaptured(pointerId?: number): boolean;
  33456. /** @hidden */
  33457. _isPointerSwiping(): boolean;
  33458. /**
  33459. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33460. * @param attachUp defines if you want to attach events to pointerup
  33461. * @param attachDown defines if you want to attach events to pointerdown
  33462. * @param attachMove defines if you want to attach events to pointermove
  33463. */
  33464. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33465. /** Detaches all event handlers*/
  33466. detachControl(): void;
  33467. /**
  33468. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33469. * Delay loaded resources are not taking in account
  33470. * @return true if all required resources are ready
  33471. */
  33472. isReady(): boolean;
  33473. /** Resets all cached information relative to material (including effect and visibility) */
  33474. resetCachedMaterial(): void;
  33475. /**
  33476. * Registers a function to be called before every frame render
  33477. * @param func defines the function to register
  33478. */
  33479. registerBeforeRender(func: () => void): void;
  33480. /**
  33481. * Unregisters a function called before every frame render
  33482. * @param func defines the function to unregister
  33483. */
  33484. unregisterBeforeRender(func: () => void): void;
  33485. /**
  33486. * Registers a function to be called after every frame render
  33487. * @param func defines the function to register
  33488. */
  33489. registerAfterRender(func: () => void): void;
  33490. /**
  33491. * Unregisters a function called after every frame render
  33492. * @param func defines the function to unregister
  33493. */
  33494. unregisterAfterRender(func: () => void): void;
  33495. private _executeOnceBeforeRender;
  33496. /**
  33497. * The provided function will run before render once and will be disposed afterwards.
  33498. * A timeout delay can be provided so that the function will be executed in N ms.
  33499. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33500. * @param func The function to be executed.
  33501. * @param timeout optional delay in ms
  33502. */
  33503. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33504. /** @hidden */
  33505. _addPendingData(data: any): void;
  33506. /** @hidden */
  33507. _removePendingData(data: any): void;
  33508. /**
  33509. * Returns the number of items waiting to be loaded
  33510. * @returns the number of items waiting to be loaded
  33511. */
  33512. getWaitingItemsCount(): number;
  33513. /**
  33514. * Returns a boolean indicating if the scene is still loading data
  33515. */
  33516. readonly isLoading: boolean;
  33517. /**
  33518. * Registers a function to be executed when the scene is ready
  33519. * @param {Function} func - the function to be executed
  33520. */
  33521. executeWhenReady(func: () => void): void;
  33522. /**
  33523. * Returns a promise that resolves when the scene is ready
  33524. * @returns A promise that resolves when the scene is ready
  33525. */
  33526. whenReadyAsync(): Promise<void>;
  33527. /** @hidden */
  33528. _checkIsReady(): void;
  33529. /**
  33530. * Gets all animatable attached to the scene
  33531. */
  33532. readonly animatables: Animatable[];
  33533. /**
  33534. * Resets the last animation time frame.
  33535. * Useful to override when animations start running when loading a scene for the first time.
  33536. */
  33537. resetLastAnimationTimeFrame(): void;
  33538. /**
  33539. * Gets the current view matrix
  33540. * @returns a Matrix
  33541. */
  33542. getViewMatrix(): Matrix;
  33543. /**
  33544. * Gets the current projection matrix
  33545. * @returns a Matrix
  33546. */
  33547. getProjectionMatrix(): Matrix;
  33548. /**
  33549. * Gets the current transform matrix
  33550. * @returns a Matrix made of View * Projection
  33551. */
  33552. getTransformMatrix(): Matrix;
  33553. /**
  33554. * Sets the current transform matrix
  33555. * @param viewL defines the View matrix to use
  33556. * @param projectionL defines the Projection matrix to use
  33557. * @param viewR defines the right View matrix to use (if provided)
  33558. * @param projectionR defines the right Projection matrix to use (if provided)
  33559. */
  33560. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33561. /**
  33562. * Gets the uniform buffer used to store scene data
  33563. * @returns a UniformBuffer
  33564. */
  33565. getSceneUniformBuffer(): UniformBuffer;
  33566. /**
  33567. * Gets an unique (relatively to the current scene) Id
  33568. * @returns an unique number for the scene
  33569. */
  33570. getUniqueId(): number;
  33571. /**
  33572. * Add a mesh to the list of scene's meshes
  33573. * @param newMesh defines the mesh to add
  33574. * @param recursive if all child meshes should also be added to the scene
  33575. */
  33576. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33577. /**
  33578. * Remove a mesh for the list of scene's meshes
  33579. * @param toRemove defines the mesh to remove
  33580. * @param recursive if all child meshes should also be removed from the scene
  33581. * @returns the index where the mesh was in the mesh list
  33582. */
  33583. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33584. /**
  33585. * Add a transform node to the list of scene's transform nodes
  33586. * @param newTransformNode defines the transform node to add
  33587. */
  33588. addTransformNode(newTransformNode: TransformNode): void;
  33589. /**
  33590. * Remove a transform node for the list of scene's transform nodes
  33591. * @param toRemove defines the transform node to remove
  33592. * @returns the index where the transform node was in the transform node list
  33593. */
  33594. removeTransformNode(toRemove: TransformNode): number;
  33595. /**
  33596. * Remove a skeleton for the list of scene's skeletons
  33597. * @param toRemove defines the skeleton to remove
  33598. * @returns the index where the skeleton was in the skeleton list
  33599. */
  33600. removeSkeleton(toRemove: Skeleton): number;
  33601. /**
  33602. * Remove a morph target for the list of scene's morph targets
  33603. * @param toRemove defines the morph target to remove
  33604. * @returns the index where the morph target was in the morph target list
  33605. */
  33606. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33607. /**
  33608. * Remove a light for the list of scene's lights
  33609. * @param toRemove defines the light to remove
  33610. * @returns the index where the light was in the light list
  33611. */
  33612. removeLight(toRemove: Light): number;
  33613. /**
  33614. * Remove a camera for the list of scene's cameras
  33615. * @param toRemove defines the camera to remove
  33616. * @returns the index where the camera was in the camera list
  33617. */
  33618. removeCamera(toRemove: Camera): number;
  33619. /**
  33620. * Remove a particle system for the list of scene's particle systems
  33621. * @param toRemove defines the particle system to remove
  33622. * @returns the index where the particle system was in the particle system list
  33623. */
  33624. removeParticleSystem(toRemove: IParticleSystem): number;
  33625. /**
  33626. * Remove a animation for the list of scene's animations
  33627. * @param toRemove defines the animation to remove
  33628. * @returns the index where the animation was in the animation list
  33629. */
  33630. removeAnimation(toRemove: Animation): number;
  33631. /**
  33632. * Removes the given animation group from this scene.
  33633. * @param toRemove The animation group to remove
  33634. * @returns The index of the removed animation group
  33635. */
  33636. removeAnimationGroup(toRemove: AnimationGroup): number;
  33637. /**
  33638. * Removes the given multi-material from this scene.
  33639. * @param toRemove The multi-material to remove
  33640. * @returns The index of the removed multi-material
  33641. */
  33642. removeMultiMaterial(toRemove: MultiMaterial): number;
  33643. /**
  33644. * Removes the given material from this scene.
  33645. * @param toRemove The material to remove
  33646. * @returns The index of the removed material
  33647. */
  33648. removeMaterial(toRemove: Material): number;
  33649. /**
  33650. * Removes the given action manager from this scene.
  33651. * @param toRemove The action manager to remove
  33652. * @returns The index of the removed action manager
  33653. */
  33654. removeActionManager(toRemove: AbstractActionManager): number;
  33655. /**
  33656. * Removes the given texture from this scene.
  33657. * @param toRemove The texture to remove
  33658. * @returns The index of the removed texture
  33659. */
  33660. removeTexture(toRemove: BaseTexture): number;
  33661. /**
  33662. * Adds the given light to this scene
  33663. * @param newLight The light to add
  33664. */
  33665. addLight(newLight: Light): void;
  33666. /**
  33667. * Sorts the list list based on light priorities
  33668. */
  33669. sortLightsByPriority(): void;
  33670. /**
  33671. * Adds the given camera to this scene
  33672. * @param newCamera The camera to add
  33673. */
  33674. addCamera(newCamera: Camera): void;
  33675. /**
  33676. * Adds the given skeleton to this scene
  33677. * @param newSkeleton The skeleton to add
  33678. */
  33679. addSkeleton(newSkeleton: Skeleton): void;
  33680. /**
  33681. * Adds the given particle system to this scene
  33682. * @param newParticleSystem The particle system to add
  33683. */
  33684. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33685. /**
  33686. * Adds the given animation to this scene
  33687. * @param newAnimation The animation to add
  33688. */
  33689. addAnimation(newAnimation: Animation): void;
  33690. /**
  33691. * Adds the given animation group to this scene.
  33692. * @param newAnimationGroup The animation group to add
  33693. */
  33694. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33695. /**
  33696. * Adds the given multi-material to this scene
  33697. * @param newMultiMaterial The multi-material to add
  33698. */
  33699. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33700. /**
  33701. * Adds the given material to this scene
  33702. * @param newMaterial The material to add
  33703. */
  33704. addMaterial(newMaterial: Material): void;
  33705. /**
  33706. * Adds the given morph target to this scene
  33707. * @param newMorphTargetManager The morph target to add
  33708. */
  33709. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33710. /**
  33711. * Adds the given geometry to this scene
  33712. * @param newGeometry The geometry to add
  33713. */
  33714. addGeometry(newGeometry: Geometry): void;
  33715. /**
  33716. * Adds the given action manager to this scene
  33717. * @param newActionManager The action manager to add
  33718. */
  33719. addActionManager(newActionManager: AbstractActionManager): void;
  33720. /**
  33721. * Adds the given texture to this scene.
  33722. * @param newTexture The texture to add
  33723. */
  33724. addTexture(newTexture: BaseTexture): void;
  33725. /**
  33726. * Switch active camera
  33727. * @param newCamera defines the new active camera
  33728. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33729. */
  33730. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33731. /**
  33732. * sets the active camera of the scene using its ID
  33733. * @param id defines the camera's ID
  33734. * @return the new active camera or null if none found.
  33735. */
  33736. setActiveCameraByID(id: string): Nullable<Camera>;
  33737. /**
  33738. * sets the active camera of the scene using its name
  33739. * @param name defines the camera's name
  33740. * @returns the new active camera or null if none found.
  33741. */
  33742. setActiveCameraByName(name: string): Nullable<Camera>;
  33743. /**
  33744. * get an animation group using its name
  33745. * @param name defines the material's name
  33746. * @return the animation group or null if none found.
  33747. */
  33748. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33749. /**
  33750. * Get a material using its unique id
  33751. * @param uniqueId defines the material's unique id
  33752. * @return the material or null if none found.
  33753. */
  33754. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33755. /**
  33756. * get a material using its id
  33757. * @param id defines the material's ID
  33758. * @return the material or null if none found.
  33759. */
  33760. getMaterialByID(id: string): Nullable<Material>;
  33761. /**
  33762. * Gets a material using its name
  33763. * @param name defines the material's name
  33764. * @return the material or null if none found.
  33765. */
  33766. getMaterialByName(name: string): Nullable<Material>;
  33767. /**
  33768. * Gets a camera using its id
  33769. * @param id defines the id to look for
  33770. * @returns the camera or null if not found
  33771. */
  33772. getCameraByID(id: string): Nullable<Camera>;
  33773. /**
  33774. * Gets a camera using its unique id
  33775. * @param uniqueId defines the unique id to look for
  33776. * @returns the camera or null if not found
  33777. */
  33778. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33779. /**
  33780. * Gets a camera using its name
  33781. * @param name defines the camera's name
  33782. * @return the camera or null if none found.
  33783. */
  33784. getCameraByName(name: string): Nullable<Camera>;
  33785. /**
  33786. * Gets a bone using its id
  33787. * @param id defines the bone's id
  33788. * @return the bone or null if not found
  33789. */
  33790. getBoneByID(id: string): Nullable<Bone>;
  33791. /**
  33792. * Gets a bone using its id
  33793. * @param name defines the bone's name
  33794. * @return the bone or null if not found
  33795. */
  33796. getBoneByName(name: string): Nullable<Bone>;
  33797. /**
  33798. * Gets a light node using its name
  33799. * @param name defines the the light's name
  33800. * @return the light or null if none found.
  33801. */
  33802. getLightByName(name: string): Nullable<Light>;
  33803. /**
  33804. * Gets a light node using its id
  33805. * @param id defines the light's id
  33806. * @return the light or null if none found.
  33807. */
  33808. getLightByID(id: string): Nullable<Light>;
  33809. /**
  33810. * Gets a light node using its scene-generated unique ID
  33811. * @param uniqueId defines the light's unique id
  33812. * @return the light or null if none found.
  33813. */
  33814. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33815. /**
  33816. * Gets a particle system by id
  33817. * @param id defines the particle system id
  33818. * @return the corresponding system or null if none found
  33819. */
  33820. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33821. /**
  33822. * Gets a geometry using its ID
  33823. * @param id defines the geometry's id
  33824. * @return the geometry or null if none found.
  33825. */
  33826. getGeometryByID(id: string): Nullable<Geometry>;
  33827. private _getGeometryByUniqueID;
  33828. /**
  33829. * Add a new geometry to this scene
  33830. * @param geometry defines the geometry to be added to the scene.
  33831. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33832. * @return a boolean defining if the geometry was added or not
  33833. */
  33834. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33835. /**
  33836. * Removes an existing geometry
  33837. * @param geometry defines the geometry to be removed from the scene
  33838. * @return a boolean defining if the geometry was removed or not
  33839. */
  33840. removeGeometry(geometry: Geometry): boolean;
  33841. /**
  33842. * Gets the list of geometries attached to the scene
  33843. * @returns an array of Geometry
  33844. */
  33845. getGeometries(): Geometry[];
  33846. /**
  33847. * Gets the first added mesh found of a given ID
  33848. * @param id defines the id to search for
  33849. * @return the mesh found or null if not found at all
  33850. */
  33851. getMeshByID(id: string): Nullable<AbstractMesh>;
  33852. /**
  33853. * Gets a list of meshes using their id
  33854. * @param id defines the id to search for
  33855. * @returns a list of meshes
  33856. */
  33857. getMeshesByID(id: string): Array<AbstractMesh>;
  33858. /**
  33859. * Gets the first added transform node found of a given ID
  33860. * @param id defines the id to search for
  33861. * @return the found transform node or null if not found at all.
  33862. */
  33863. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33864. /**
  33865. * Gets a transform node with its auto-generated unique id
  33866. * @param uniqueId efines the unique id to search for
  33867. * @return the found transform node or null if not found at all.
  33868. */
  33869. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33870. /**
  33871. * Gets a list of transform nodes using their id
  33872. * @param id defines the id to search for
  33873. * @returns a list of transform nodes
  33874. */
  33875. getTransformNodesByID(id: string): Array<TransformNode>;
  33876. /**
  33877. * Gets a mesh with its auto-generated unique id
  33878. * @param uniqueId defines the unique id to search for
  33879. * @return the found mesh or null if not found at all.
  33880. */
  33881. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33882. /**
  33883. * Gets a the last added mesh using a given id
  33884. * @param id defines the id to search for
  33885. * @return the found mesh or null if not found at all.
  33886. */
  33887. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33888. /**
  33889. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33890. * @param id defines the id to search for
  33891. * @return the found node or null if not found at all
  33892. */
  33893. getLastEntryByID(id: string): Nullable<Node>;
  33894. /**
  33895. * Gets a node (Mesh, Camera, Light) using a given id
  33896. * @param id defines the id to search for
  33897. * @return the found node or null if not found at all
  33898. */
  33899. getNodeByID(id: string): Nullable<Node>;
  33900. /**
  33901. * Gets a node (Mesh, Camera, Light) using a given name
  33902. * @param name defines the name to search for
  33903. * @return the found node or null if not found at all.
  33904. */
  33905. getNodeByName(name: string): Nullable<Node>;
  33906. /**
  33907. * Gets a mesh using a given name
  33908. * @param name defines the name to search for
  33909. * @return the found mesh or null if not found at all.
  33910. */
  33911. getMeshByName(name: string): Nullable<AbstractMesh>;
  33912. /**
  33913. * Gets a transform node using a given name
  33914. * @param name defines the name to search for
  33915. * @return the found transform node or null if not found at all.
  33916. */
  33917. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33918. /**
  33919. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33920. * @param id defines the id to search for
  33921. * @return the found skeleton or null if not found at all.
  33922. */
  33923. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33924. /**
  33925. * Gets a skeleton using a given auto generated unique id
  33926. * @param uniqueId defines the unique id to search for
  33927. * @return the found skeleton or null if not found at all.
  33928. */
  33929. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33930. /**
  33931. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33932. * @param id defines the id to search for
  33933. * @return the found skeleton or null if not found at all.
  33934. */
  33935. getSkeletonById(id: string): Nullable<Skeleton>;
  33936. /**
  33937. * Gets a skeleton using a given name
  33938. * @param name defines the name to search for
  33939. * @return the found skeleton or null if not found at all.
  33940. */
  33941. getSkeletonByName(name: string): Nullable<Skeleton>;
  33942. /**
  33943. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33944. * @param id defines the id to search for
  33945. * @return the found morph target manager or null if not found at all.
  33946. */
  33947. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33948. /**
  33949. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33950. * @param id defines the id to search for
  33951. * @return the found morph target or null if not found at all.
  33952. */
  33953. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33954. /**
  33955. * Gets a boolean indicating if the given mesh is active
  33956. * @param mesh defines the mesh to look for
  33957. * @returns true if the mesh is in the active list
  33958. */
  33959. isActiveMesh(mesh: AbstractMesh): boolean;
  33960. /**
  33961. * Return a unique id as a string which can serve as an identifier for the scene
  33962. */
  33963. readonly uid: string;
  33964. /**
  33965. * Add an externaly attached data from its key.
  33966. * This method call will fail and return false, if such key already exists.
  33967. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33968. * @param key the unique key that identifies the data
  33969. * @param data the data object to associate to the key for this Engine instance
  33970. * @return true if no such key were already present and the data was added successfully, false otherwise
  33971. */
  33972. addExternalData<T>(key: string, data: T): boolean;
  33973. /**
  33974. * Get an externaly attached data from its key
  33975. * @param key the unique key that identifies the data
  33976. * @return the associated data, if present (can be null), or undefined if not present
  33977. */
  33978. getExternalData<T>(key: string): Nullable<T>;
  33979. /**
  33980. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33981. * @param key the unique key that identifies the data
  33982. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33983. * @return the associated data, can be null if the factory returned null.
  33984. */
  33985. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33986. /**
  33987. * Remove an externaly attached data from the Engine instance
  33988. * @param key the unique key that identifies the data
  33989. * @return true if the data was successfully removed, false if it doesn't exist
  33990. */
  33991. removeExternalData(key: string): boolean;
  33992. private _evaluateSubMesh;
  33993. /**
  33994. * Clear the processed materials smart array preventing retention point in material dispose.
  33995. */
  33996. freeProcessedMaterials(): void;
  33997. private _preventFreeActiveMeshesAndRenderingGroups;
  33998. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33999. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34000. * when disposing several meshes in a row or a hierarchy of meshes.
  34001. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34002. */
  34003. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34004. /**
  34005. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34006. */
  34007. freeActiveMeshes(): void;
  34008. /**
  34009. * Clear the info related to rendering groups preventing retention points during dispose.
  34010. */
  34011. freeRenderingGroups(): void;
  34012. /** @hidden */
  34013. _isInIntermediateRendering(): boolean;
  34014. /**
  34015. * Lambda returning the list of potentially active meshes.
  34016. */
  34017. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34018. /**
  34019. * Lambda returning the list of potentially active sub meshes.
  34020. */
  34021. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34022. /**
  34023. * Lambda returning the list of potentially intersecting sub meshes.
  34024. */
  34025. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34026. /**
  34027. * Lambda returning the list of potentially colliding sub meshes.
  34028. */
  34029. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34030. private _activeMeshesFrozen;
  34031. /**
  34032. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34033. * @returns the current scene
  34034. */
  34035. freezeActiveMeshes(): Scene;
  34036. /**
  34037. * Use this function to restart evaluating active meshes on every frame
  34038. * @returns the current scene
  34039. */
  34040. unfreezeActiveMeshes(): Scene;
  34041. private _evaluateActiveMeshes;
  34042. private _activeMesh;
  34043. /**
  34044. * Update the transform matrix to update from the current active camera
  34045. * @param force defines a boolean used to force the update even if cache is up to date
  34046. */
  34047. updateTransformMatrix(force?: boolean): void;
  34048. private _bindFrameBuffer;
  34049. /** @hidden */
  34050. _allowPostProcessClearColor: boolean;
  34051. private _renderForCamera;
  34052. private _processSubCameras;
  34053. private _checkIntersections;
  34054. /** @hidden */
  34055. _advancePhysicsEngineStep(step: number): void;
  34056. /**
  34057. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34058. */
  34059. getDeterministicFrameTime: () => number;
  34060. /** @hidden */
  34061. _animate(): void;
  34062. /**
  34063. * Render the scene
  34064. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34065. */
  34066. render(updateCameras?: boolean): void;
  34067. /**
  34068. * Freeze all materials
  34069. * A frozen material will not be updatable but should be faster to render
  34070. */
  34071. freezeMaterials(): void;
  34072. /**
  34073. * Unfreeze all materials
  34074. * A frozen material will not be updatable but should be faster to render
  34075. */
  34076. unfreezeMaterials(): void;
  34077. /**
  34078. * Releases all held ressources
  34079. */
  34080. dispose(): void;
  34081. /**
  34082. * Gets if the scene is already disposed
  34083. */
  34084. readonly isDisposed: boolean;
  34085. /**
  34086. * Call this function to reduce memory footprint of the scene.
  34087. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34088. */
  34089. clearCachedVertexData(): void;
  34090. /**
  34091. * This function will remove the local cached buffer data from texture.
  34092. * It will save memory but will prevent the texture from being rebuilt
  34093. */
  34094. cleanCachedTextureBuffer(): void;
  34095. /**
  34096. * Get the world extend vectors with an optional filter
  34097. *
  34098. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34099. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34100. */
  34101. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34102. min: Vector3;
  34103. max: Vector3;
  34104. };
  34105. /**
  34106. * Creates a ray that can be used to pick in the scene
  34107. * @param x defines the x coordinate of the origin (on-screen)
  34108. * @param y defines the y coordinate of the origin (on-screen)
  34109. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34110. * @param camera defines the camera to use for the picking
  34111. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34112. * @returns a Ray
  34113. */
  34114. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34115. /**
  34116. * Creates a ray that can be used to pick in the scene
  34117. * @param x defines the x coordinate of the origin (on-screen)
  34118. * @param y defines the y coordinate of the origin (on-screen)
  34119. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34120. * @param result defines the ray where to store the picking ray
  34121. * @param camera defines the camera to use for the picking
  34122. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34123. * @returns the current scene
  34124. */
  34125. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34126. /**
  34127. * Creates a ray that can be used to pick in the scene
  34128. * @param x defines the x coordinate of the origin (on-screen)
  34129. * @param y defines the y coordinate of the origin (on-screen)
  34130. * @param camera defines the camera to use for the picking
  34131. * @returns a Ray
  34132. */
  34133. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34134. /**
  34135. * Creates a ray that can be used to pick in the scene
  34136. * @param x defines the x coordinate of the origin (on-screen)
  34137. * @param y defines the y coordinate of the origin (on-screen)
  34138. * @param result defines the ray where to store the picking ray
  34139. * @param camera defines the camera to use for the picking
  34140. * @returns the current scene
  34141. */
  34142. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34143. /** Launch a ray to try to pick a mesh in the scene
  34144. * @param x position on screen
  34145. * @param y position on screen
  34146. * @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
  34147. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34148. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34149. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34150. * @returns a PickingInfo
  34151. */
  34152. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34153. /** Use the given ray to pick a mesh in the scene
  34154. * @param ray The ray to use to pick meshes
  34155. * @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
  34156. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34158. * @returns a PickingInfo
  34159. */
  34160. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34161. /**
  34162. * Launch a ray to try to pick a mesh in the scene
  34163. * @param x X position on screen
  34164. * @param y Y position on screen
  34165. * @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
  34166. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34167. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34168. * @returns an array of PickingInfo
  34169. */
  34170. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34171. /**
  34172. * Launch a ray to try to pick a mesh in the scene
  34173. * @param ray Ray to use
  34174. * @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
  34175. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34176. * @returns an array of PickingInfo
  34177. */
  34178. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34179. /**
  34180. * Force the value of meshUnderPointer
  34181. * @param mesh defines the mesh to use
  34182. */
  34183. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34184. /**
  34185. * Gets the mesh under the pointer
  34186. * @returns a Mesh or null if no mesh is under the pointer
  34187. */
  34188. getPointerOverMesh(): Nullable<AbstractMesh>;
  34189. /** @hidden */
  34190. _rebuildGeometries(): void;
  34191. /** @hidden */
  34192. _rebuildTextures(): void;
  34193. private _getByTags;
  34194. /**
  34195. * Get a list of meshes by tags
  34196. * @param tagsQuery defines the tags query to use
  34197. * @param forEach defines a predicate used to filter results
  34198. * @returns an array of Mesh
  34199. */
  34200. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34201. /**
  34202. * Get a list of cameras by tags
  34203. * @param tagsQuery defines the tags query to use
  34204. * @param forEach defines a predicate used to filter results
  34205. * @returns an array of Camera
  34206. */
  34207. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34208. /**
  34209. * Get a list of lights by tags
  34210. * @param tagsQuery defines the tags query to use
  34211. * @param forEach defines a predicate used to filter results
  34212. * @returns an array of Light
  34213. */
  34214. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34215. /**
  34216. * Get a list of materials by tags
  34217. * @param tagsQuery defines the tags query to use
  34218. * @param forEach defines a predicate used to filter results
  34219. * @returns an array of Material
  34220. */
  34221. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34222. /**
  34223. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34224. * This allowed control for front to back rendering or reversly depending of the special needs.
  34225. *
  34226. * @param renderingGroupId The rendering group id corresponding to its index
  34227. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34228. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34229. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34230. */
  34231. 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;
  34232. /**
  34233. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34234. *
  34235. * @param renderingGroupId The rendering group id corresponding to its index
  34236. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34237. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34238. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34239. */
  34240. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34241. /**
  34242. * Gets the current auto clear configuration for one rendering group of the rendering
  34243. * manager.
  34244. * @param index the rendering group index to get the information for
  34245. * @returns The auto clear setup for the requested rendering group
  34246. */
  34247. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34248. private _blockMaterialDirtyMechanism;
  34249. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34250. blockMaterialDirtyMechanism: boolean;
  34251. /**
  34252. * Will flag all materials as dirty to trigger new shader compilation
  34253. * @param flag defines the flag used to specify which material part must be marked as dirty
  34254. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34255. */
  34256. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34257. /** @hidden */
  34258. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34259. /** @hidden */
  34260. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34261. }
  34262. }
  34263. declare module "babylonjs/assetContainer" {
  34264. import { AbstractScene } from "babylonjs/abstractScene";
  34265. import { Scene } from "babylonjs/scene";
  34266. import { Mesh } from "babylonjs/Meshes/mesh";
  34267. /**
  34268. * Set of assets to keep when moving a scene into an asset container.
  34269. */
  34270. export class KeepAssets extends AbstractScene {
  34271. }
  34272. /**
  34273. * Container with a set of assets that can be added or removed from a scene.
  34274. */
  34275. export class AssetContainer extends AbstractScene {
  34276. /**
  34277. * The scene the AssetContainer belongs to.
  34278. */
  34279. scene: Scene;
  34280. /**
  34281. * Instantiates an AssetContainer.
  34282. * @param scene The scene the AssetContainer belongs to.
  34283. */
  34284. constructor(scene: Scene);
  34285. /**
  34286. * Adds all the assets from the container to the scene.
  34287. */
  34288. addAllToScene(): void;
  34289. /**
  34290. * Removes all the assets in the container from the scene
  34291. */
  34292. removeAllFromScene(): void;
  34293. /**
  34294. * Disposes all the assets in the container
  34295. */
  34296. dispose(): void;
  34297. private _moveAssets;
  34298. /**
  34299. * Removes all the assets contained in the scene and adds them to the container.
  34300. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34301. */
  34302. moveAllFromScene(keepAssets?: KeepAssets): void;
  34303. /**
  34304. * 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.
  34305. * @returns the root mesh
  34306. */
  34307. createRootMesh(): Mesh;
  34308. }
  34309. }
  34310. declare module "babylonjs/abstractScene" {
  34311. import { Scene } from "babylonjs/scene";
  34312. import { Nullable } from "babylonjs/types";
  34313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34314. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34315. import { Geometry } from "babylonjs/Meshes/geometry";
  34316. import { Skeleton } from "babylonjs/Bones/skeleton";
  34317. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34318. import { AssetContainer } from "babylonjs/assetContainer";
  34319. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34320. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34322. import { Material } from "babylonjs/Materials/material";
  34323. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34324. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34325. import { Camera } from "babylonjs/Cameras/camera";
  34326. import { Light } from "babylonjs/Lights/light";
  34327. import { Node } from "babylonjs/node";
  34328. import { Animation } from "babylonjs/Animations/animation";
  34329. /**
  34330. * Defines how the parser contract is defined.
  34331. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34332. */
  34333. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34334. /**
  34335. * Defines how the individual parser contract is defined.
  34336. * These parser can parse an individual asset
  34337. */
  34338. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34339. /**
  34340. * Base class of the scene acting as a container for the different elements composing a scene.
  34341. * This class is dynamically extended by the different components of the scene increasing
  34342. * flexibility and reducing coupling
  34343. */
  34344. export abstract class AbstractScene {
  34345. /**
  34346. * Stores the list of available parsers in the application.
  34347. */
  34348. private static _BabylonFileParsers;
  34349. /**
  34350. * Stores the list of available individual parsers in the application.
  34351. */
  34352. private static _IndividualBabylonFileParsers;
  34353. /**
  34354. * Adds a parser in the list of available ones
  34355. * @param name Defines the name of the parser
  34356. * @param parser Defines the parser to add
  34357. */
  34358. static AddParser(name: string, parser: BabylonFileParser): void;
  34359. /**
  34360. * Gets a general parser from the list of avaialble ones
  34361. * @param name Defines the name of the parser
  34362. * @returns the requested parser or null
  34363. */
  34364. static GetParser(name: string): Nullable<BabylonFileParser>;
  34365. /**
  34366. * Adds n individual parser in the list of available ones
  34367. * @param name Defines the name of the parser
  34368. * @param parser Defines the parser to add
  34369. */
  34370. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34371. /**
  34372. * Gets an individual parser from the list of avaialble ones
  34373. * @param name Defines the name of the parser
  34374. * @returns the requested parser or null
  34375. */
  34376. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34377. /**
  34378. * Parser json data and populate both a scene and its associated container object
  34379. * @param jsonData Defines the data to parse
  34380. * @param scene Defines the scene to parse the data for
  34381. * @param container Defines the container attached to the parsing sequence
  34382. * @param rootUrl Defines the root url of the data
  34383. */
  34384. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34385. /**
  34386. * Gets the list of root nodes (ie. nodes with no parent)
  34387. */
  34388. rootNodes: Node[];
  34389. /** All of the cameras added to this scene
  34390. * @see http://doc.babylonjs.com/babylon101/cameras
  34391. */
  34392. cameras: Camera[];
  34393. /**
  34394. * All of the lights added to this scene
  34395. * @see http://doc.babylonjs.com/babylon101/lights
  34396. */
  34397. lights: Light[];
  34398. /**
  34399. * All of the (abstract) meshes added to this scene
  34400. */
  34401. meshes: AbstractMesh[];
  34402. /**
  34403. * The list of skeletons added to the scene
  34404. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34405. */
  34406. skeletons: Skeleton[];
  34407. /**
  34408. * All of the particle systems added to this scene
  34409. * @see http://doc.babylonjs.com/babylon101/particles
  34410. */
  34411. particleSystems: IParticleSystem[];
  34412. /**
  34413. * Gets a list of Animations associated with the scene
  34414. */
  34415. animations: Animation[];
  34416. /**
  34417. * All of the animation groups added to this scene
  34418. * @see http://doc.babylonjs.com/how_to/group
  34419. */
  34420. animationGroups: AnimationGroup[];
  34421. /**
  34422. * All of the multi-materials added to this scene
  34423. * @see http://doc.babylonjs.com/how_to/multi_materials
  34424. */
  34425. multiMaterials: MultiMaterial[];
  34426. /**
  34427. * All of the materials added to this scene
  34428. * In the context of a Scene, it is not supposed to be modified manually.
  34429. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34430. * Note also that the order of the Material wihin the array is not significant and might change.
  34431. * @see http://doc.babylonjs.com/babylon101/materials
  34432. */
  34433. materials: Material[];
  34434. /**
  34435. * The list of morph target managers added to the scene
  34436. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34437. */
  34438. morphTargetManagers: MorphTargetManager[];
  34439. /**
  34440. * The list of geometries used in the scene.
  34441. */
  34442. geometries: Geometry[];
  34443. /**
  34444. * All of the tranform nodes added to this scene
  34445. * In the context of a Scene, it is not supposed to be modified manually.
  34446. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34447. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34448. * @see http://doc.babylonjs.com/how_to/transformnode
  34449. */
  34450. transformNodes: TransformNode[];
  34451. /**
  34452. * ActionManagers available on the scene.
  34453. */
  34454. actionManagers: AbstractActionManager[];
  34455. /**
  34456. * Textures to keep.
  34457. */
  34458. textures: BaseTexture[];
  34459. /**
  34460. * Environment texture for the scene
  34461. */
  34462. environmentTexture: Nullable<BaseTexture>;
  34463. }
  34464. }
  34465. declare module "babylonjs/Audio/sound" {
  34466. import { Observable } from "babylonjs/Misc/observable";
  34467. import { Vector3 } from "babylonjs/Maths/math";
  34468. import { Nullable } from "babylonjs/types";
  34469. import { Scene } from "babylonjs/scene";
  34470. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34471. /**
  34472. * Defines a sound that can be played in the application.
  34473. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34475. */
  34476. export class Sound {
  34477. /**
  34478. * The name of the sound in the scene.
  34479. */
  34480. name: string;
  34481. /**
  34482. * Does the sound autoplay once loaded.
  34483. */
  34484. autoplay: boolean;
  34485. /**
  34486. * Does the sound loop after it finishes playing once.
  34487. */
  34488. loop: boolean;
  34489. /**
  34490. * Does the sound use a custom attenuation curve to simulate the falloff
  34491. * happening when the source gets further away from the camera.
  34492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34493. */
  34494. useCustomAttenuation: boolean;
  34495. /**
  34496. * The sound track id this sound belongs to.
  34497. */
  34498. soundTrackId: number;
  34499. /**
  34500. * Is this sound currently played.
  34501. */
  34502. isPlaying: boolean;
  34503. /**
  34504. * Is this sound currently paused.
  34505. */
  34506. isPaused: boolean;
  34507. /**
  34508. * Does this sound enables spatial sound.
  34509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34510. */
  34511. spatialSound: boolean;
  34512. /**
  34513. * Define the reference distance the sound should be heard perfectly.
  34514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34515. */
  34516. refDistance: number;
  34517. /**
  34518. * Define the roll off factor of spatial sounds.
  34519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34520. */
  34521. rolloffFactor: number;
  34522. /**
  34523. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34525. */
  34526. maxDistance: number;
  34527. /**
  34528. * Define the distance attenuation model the sound will follow.
  34529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34530. */
  34531. distanceModel: string;
  34532. /**
  34533. * @hidden
  34534. * Back Compat
  34535. **/
  34536. onended: () => any;
  34537. /**
  34538. * Observable event when the current playing sound finishes.
  34539. */
  34540. onEndedObservable: Observable<Sound>;
  34541. private _panningModel;
  34542. private _playbackRate;
  34543. private _streaming;
  34544. private _startTime;
  34545. private _startOffset;
  34546. private _position;
  34547. /** @hidden */
  34548. _positionInEmitterSpace: boolean;
  34549. private _localDirection;
  34550. private _volume;
  34551. private _isReadyToPlay;
  34552. private _isDirectional;
  34553. private _readyToPlayCallback;
  34554. private _audioBuffer;
  34555. private _soundSource;
  34556. private _streamingSource;
  34557. private _soundPanner;
  34558. private _soundGain;
  34559. private _inputAudioNode;
  34560. private _outputAudioNode;
  34561. private _coneInnerAngle;
  34562. private _coneOuterAngle;
  34563. private _coneOuterGain;
  34564. private _scene;
  34565. private _connectedTransformNode;
  34566. private _customAttenuationFunction;
  34567. private _registerFunc;
  34568. private _isOutputConnected;
  34569. private _htmlAudioElement;
  34570. private _urlType;
  34571. /** @hidden */
  34572. static _SceneComponentInitialization: (scene: Scene) => void;
  34573. /**
  34574. * Create a sound and attach it to a scene
  34575. * @param name Name of your sound
  34576. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34577. * @param scene defines the scene the sound belongs to
  34578. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34579. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34580. */
  34581. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34582. /**
  34583. * Release the sound and its associated resources
  34584. */
  34585. dispose(): void;
  34586. /**
  34587. * Gets if the sounds is ready to be played or not.
  34588. * @returns true if ready, otherwise false
  34589. */
  34590. isReady(): boolean;
  34591. private _soundLoaded;
  34592. /**
  34593. * Sets the data of the sound from an audiobuffer
  34594. * @param audioBuffer The audioBuffer containing the data
  34595. */
  34596. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34597. /**
  34598. * Updates the current sounds options such as maxdistance, loop...
  34599. * @param options A JSON object containing values named as the object properties
  34600. */
  34601. updateOptions(options: any): void;
  34602. private _createSpatialParameters;
  34603. private _updateSpatialParameters;
  34604. /**
  34605. * Switch the panning model to HRTF:
  34606. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34608. */
  34609. switchPanningModelToHRTF(): void;
  34610. /**
  34611. * Switch the panning model to Equal Power:
  34612. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34614. */
  34615. switchPanningModelToEqualPower(): void;
  34616. private _switchPanningModel;
  34617. /**
  34618. * Connect this sound to a sound track audio node like gain...
  34619. * @param soundTrackAudioNode the sound track audio node to connect to
  34620. */
  34621. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34622. /**
  34623. * Transform this sound into a directional source
  34624. * @param coneInnerAngle Size of the inner cone in degree
  34625. * @param coneOuterAngle Size of the outer cone in degree
  34626. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34627. */
  34628. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34629. /**
  34630. * Gets or sets the inner angle for the directional cone.
  34631. */
  34632. /**
  34633. * Gets or sets the inner angle for the directional cone.
  34634. */
  34635. directionalConeInnerAngle: number;
  34636. /**
  34637. * Gets or sets the outer angle for the directional cone.
  34638. */
  34639. /**
  34640. * Gets or sets the outer angle for the directional cone.
  34641. */
  34642. directionalConeOuterAngle: number;
  34643. /**
  34644. * Sets the position of the emitter if spatial sound is enabled
  34645. * @param newPosition Defines the new posisiton
  34646. */
  34647. setPosition(newPosition: Vector3): void;
  34648. /**
  34649. * Sets the local direction of the emitter if spatial sound is enabled
  34650. * @param newLocalDirection Defines the new local direction
  34651. */
  34652. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34653. private _updateDirection;
  34654. /** @hidden */
  34655. updateDistanceFromListener(): void;
  34656. /**
  34657. * Sets a new custom attenuation function for the sound.
  34658. * @param callback Defines the function used for the attenuation
  34659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34660. */
  34661. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34662. /**
  34663. * Play the sound
  34664. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34665. * @param offset (optional) Start the sound setting it at a specific time
  34666. */
  34667. play(time?: number, offset?: number): void;
  34668. private _onended;
  34669. /**
  34670. * Stop the sound
  34671. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34672. */
  34673. stop(time?: number): void;
  34674. /**
  34675. * Put the sound in pause
  34676. */
  34677. pause(): void;
  34678. /**
  34679. * Sets a dedicated volume for this sounds
  34680. * @param newVolume Define the new volume of the sound
  34681. * @param time Define in how long the sound should be at this value
  34682. */
  34683. setVolume(newVolume: number, time?: number): void;
  34684. /**
  34685. * Set the sound play back rate
  34686. * @param newPlaybackRate Define the playback rate the sound should be played at
  34687. */
  34688. setPlaybackRate(newPlaybackRate: number): void;
  34689. /**
  34690. * Gets the volume of the sound.
  34691. * @returns the volume of the sound
  34692. */
  34693. getVolume(): number;
  34694. /**
  34695. * Attach the sound to a dedicated mesh
  34696. * @param transformNode The transform node to connect the sound with
  34697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34698. */
  34699. attachToMesh(transformNode: TransformNode): void;
  34700. /**
  34701. * Detach the sound from the previously attached mesh
  34702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34703. */
  34704. detachFromMesh(): void;
  34705. private _onRegisterAfterWorldMatrixUpdate;
  34706. /**
  34707. * Clone the current sound in the scene.
  34708. * @returns the new sound clone
  34709. */
  34710. clone(): Nullable<Sound>;
  34711. /**
  34712. * Gets the current underlying audio buffer containing the data
  34713. * @returns the audio buffer
  34714. */
  34715. getAudioBuffer(): Nullable<AudioBuffer>;
  34716. /**
  34717. * Serializes the Sound in a JSON representation
  34718. * @returns the JSON representation of the sound
  34719. */
  34720. serialize(): any;
  34721. /**
  34722. * Parse a JSON representation of a sound to innstantiate in a given scene
  34723. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34724. * @param scene Define the scene the new parsed sound should be created in
  34725. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34726. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34727. * @returns the newly parsed sound
  34728. */
  34729. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34730. }
  34731. }
  34732. declare module "babylonjs/Actions/directAudioActions" {
  34733. import { Action } from "babylonjs/Actions/action";
  34734. import { Condition } from "babylonjs/Actions/condition";
  34735. import { Sound } from "babylonjs/Audio/sound";
  34736. /**
  34737. * This defines an action helpful to play a defined sound on a triggered action.
  34738. */
  34739. export class PlaySoundAction extends Action {
  34740. private _sound;
  34741. /**
  34742. * Instantiate the action
  34743. * @param triggerOptions defines the trigger options
  34744. * @param sound defines the sound to play
  34745. * @param condition defines the trigger related conditions
  34746. */
  34747. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34748. /** @hidden */
  34749. _prepare(): void;
  34750. /**
  34751. * Execute the action and play the sound.
  34752. */
  34753. execute(): void;
  34754. /**
  34755. * Serializes the actions and its related information.
  34756. * @param parent defines the object to serialize in
  34757. * @returns the serialized object
  34758. */
  34759. serialize(parent: any): any;
  34760. }
  34761. /**
  34762. * This defines an action helpful to stop a defined sound on a triggered action.
  34763. */
  34764. export class StopSoundAction extends Action {
  34765. private _sound;
  34766. /**
  34767. * Instantiate the action
  34768. * @param triggerOptions defines the trigger options
  34769. * @param sound defines the sound to stop
  34770. * @param condition defines the trigger related conditions
  34771. */
  34772. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34773. /** @hidden */
  34774. _prepare(): void;
  34775. /**
  34776. * Execute the action and stop the sound.
  34777. */
  34778. execute(): void;
  34779. /**
  34780. * Serializes the actions and its related information.
  34781. * @param parent defines the object to serialize in
  34782. * @returns the serialized object
  34783. */
  34784. serialize(parent: any): any;
  34785. }
  34786. }
  34787. declare module "babylonjs/Actions/interpolateValueAction" {
  34788. import { Action } from "babylonjs/Actions/action";
  34789. import { Condition } from "babylonjs/Actions/condition";
  34790. import { Observable } from "babylonjs/Misc/observable";
  34791. /**
  34792. * This defines an action responsible to change the value of a property
  34793. * by interpolating between its current value and the newly set one once triggered.
  34794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34795. */
  34796. export class InterpolateValueAction extends Action {
  34797. /**
  34798. * Defines the path of the property where the value should be interpolated
  34799. */
  34800. propertyPath: string;
  34801. /**
  34802. * Defines the target value at the end of the interpolation.
  34803. */
  34804. value: any;
  34805. /**
  34806. * Defines the time it will take for the property to interpolate to the value.
  34807. */
  34808. duration: number;
  34809. /**
  34810. * Defines if the other scene animations should be stopped when the action has been triggered
  34811. */
  34812. stopOtherAnimations?: boolean;
  34813. /**
  34814. * Defines a callback raised once the interpolation animation has been done.
  34815. */
  34816. onInterpolationDone?: () => void;
  34817. /**
  34818. * Observable triggered once the interpolation animation has been done.
  34819. */
  34820. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34821. private _target;
  34822. private _effectiveTarget;
  34823. private _property;
  34824. /**
  34825. * Instantiate the action
  34826. * @param triggerOptions defines the trigger options
  34827. * @param target defines the object containing the value to interpolate
  34828. * @param propertyPath defines the path to the property in the target object
  34829. * @param value defines the target value at the end of the interpolation
  34830. * @param duration deines the time it will take for the property to interpolate to the value.
  34831. * @param condition defines the trigger related conditions
  34832. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34833. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34834. */
  34835. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34836. /** @hidden */
  34837. _prepare(): void;
  34838. /**
  34839. * Execute the action starts the value interpolation.
  34840. */
  34841. execute(): void;
  34842. /**
  34843. * Serializes the actions and its related information.
  34844. * @param parent defines the object to serialize in
  34845. * @returns the serialized object
  34846. */
  34847. serialize(parent: any): any;
  34848. }
  34849. }
  34850. declare module "babylonjs/Actions/index" {
  34851. export * from "babylonjs/Actions/action";
  34852. export * from "babylonjs/Actions/actionEvent";
  34853. export * from "babylonjs/Actions/actionManager";
  34854. export * from "babylonjs/Actions/condition";
  34855. export * from "babylonjs/Actions/directActions";
  34856. export * from "babylonjs/Actions/directAudioActions";
  34857. export * from "babylonjs/Actions/interpolateValueAction";
  34858. }
  34859. declare module "babylonjs/Animations/index" {
  34860. export * from "babylonjs/Animations/animatable";
  34861. export * from "babylonjs/Animations/animation";
  34862. export * from "babylonjs/Animations/animationGroup";
  34863. export * from "babylonjs/Animations/animationPropertiesOverride";
  34864. export * from "babylonjs/Animations/easing";
  34865. export * from "babylonjs/Animations/runtimeAnimation";
  34866. export * from "babylonjs/Animations/animationEvent";
  34867. export * from "babylonjs/Animations/animationGroup";
  34868. export * from "babylonjs/Animations/animationKey";
  34869. export * from "babylonjs/Animations/animationRange";
  34870. }
  34871. declare module "babylonjs/Audio/soundTrack" {
  34872. import { Sound } from "babylonjs/Audio/sound";
  34873. import { Analyser } from "babylonjs/Audio/analyser";
  34874. import { Scene } from "babylonjs/scene";
  34875. /**
  34876. * Options allowed during the creation of a sound track.
  34877. */
  34878. export interface ISoundTrackOptions {
  34879. /**
  34880. * The volume the sound track should take during creation
  34881. */
  34882. volume?: number;
  34883. /**
  34884. * Define if the sound track is the main sound track of the scene
  34885. */
  34886. mainTrack?: boolean;
  34887. }
  34888. /**
  34889. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34890. * It will be also used in a future release to apply effects on a specific track.
  34891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34892. */
  34893. export class SoundTrack {
  34894. /**
  34895. * The unique identifier of the sound track in the scene.
  34896. */
  34897. id: number;
  34898. /**
  34899. * The list of sounds included in the sound track.
  34900. */
  34901. soundCollection: Array<Sound>;
  34902. private _outputAudioNode;
  34903. private _scene;
  34904. private _isMainTrack;
  34905. private _connectedAnalyser;
  34906. private _options;
  34907. private _isInitialized;
  34908. /**
  34909. * Creates a new sound track.
  34910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34911. * @param scene Define the scene the sound track belongs to
  34912. * @param options
  34913. */
  34914. constructor(scene: Scene, options?: ISoundTrackOptions);
  34915. private _initializeSoundTrackAudioGraph;
  34916. /**
  34917. * Release the sound track and its associated resources
  34918. */
  34919. dispose(): void;
  34920. /**
  34921. * Adds a sound to this sound track
  34922. * @param sound define the cound to add
  34923. * @ignoreNaming
  34924. */
  34925. AddSound(sound: Sound): void;
  34926. /**
  34927. * Removes a sound to this sound track
  34928. * @param sound define the cound to remove
  34929. * @ignoreNaming
  34930. */
  34931. RemoveSound(sound: Sound): void;
  34932. /**
  34933. * Set a global volume for the full sound track.
  34934. * @param newVolume Define the new volume of the sound track
  34935. */
  34936. setVolume(newVolume: number): void;
  34937. /**
  34938. * Switch the panning model to HRTF:
  34939. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34941. */
  34942. switchPanningModelToHRTF(): void;
  34943. /**
  34944. * Switch the panning model to Equal Power:
  34945. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34947. */
  34948. switchPanningModelToEqualPower(): void;
  34949. /**
  34950. * Connect the sound track to an audio analyser allowing some amazing
  34951. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34953. * @param analyser The analyser to connect to the engine
  34954. */
  34955. connectToAnalyser(analyser: Analyser): void;
  34956. }
  34957. }
  34958. declare module "babylonjs/Audio/audioSceneComponent" {
  34959. import { Sound } from "babylonjs/Audio/sound";
  34960. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34961. import { Nullable } from "babylonjs/types";
  34962. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34963. import { Scene } from "babylonjs/scene";
  34964. import { AbstractScene } from "babylonjs/abstractScene";
  34965. module "babylonjs/abstractScene" {
  34966. interface AbstractScene {
  34967. /**
  34968. * The list of sounds used in the scene.
  34969. */
  34970. sounds: Nullable<Array<Sound>>;
  34971. }
  34972. }
  34973. module "babylonjs/scene" {
  34974. interface Scene {
  34975. /**
  34976. * @hidden
  34977. * Backing field
  34978. */
  34979. _mainSoundTrack: SoundTrack;
  34980. /**
  34981. * The main sound track played by the scene.
  34982. * It cotains your primary collection of sounds.
  34983. */
  34984. mainSoundTrack: SoundTrack;
  34985. /**
  34986. * The list of sound tracks added to the scene
  34987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34988. */
  34989. soundTracks: Nullable<Array<SoundTrack>>;
  34990. /**
  34991. * Gets a sound using a given name
  34992. * @param name defines the name to search for
  34993. * @return the found sound or null if not found at all.
  34994. */
  34995. getSoundByName(name: string): Nullable<Sound>;
  34996. /**
  34997. * Gets or sets if audio support is enabled
  34998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34999. */
  35000. audioEnabled: boolean;
  35001. /**
  35002. * Gets or sets if audio will be output to headphones
  35003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35004. */
  35005. headphone: boolean;
  35006. }
  35007. }
  35008. /**
  35009. * Defines the sound scene component responsible to manage any sounds
  35010. * in a given scene.
  35011. */
  35012. export class AudioSceneComponent implements ISceneSerializableComponent {
  35013. /**
  35014. * The component name helpfull to identify the component in the list of scene components.
  35015. */
  35016. readonly name: string;
  35017. /**
  35018. * The scene the component belongs to.
  35019. */
  35020. scene: Scene;
  35021. private _audioEnabled;
  35022. /**
  35023. * Gets whether audio is enabled or not.
  35024. * Please use related enable/disable method to switch state.
  35025. */
  35026. readonly audioEnabled: boolean;
  35027. private _headphone;
  35028. /**
  35029. * Gets whether audio is outputing to headphone or not.
  35030. * Please use the according Switch methods to change output.
  35031. */
  35032. readonly headphone: boolean;
  35033. /**
  35034. * Creates a new instance of the component for the given scene
  35035. * @param scene Defines the scene to register the component in
  35036. */
  35037. constructor(scene: Scene);
  35038. /**
  35039. * Registers the component in a given scene
  35040. */
  35041. register(): void;
  35042. /**
  35043. * Rebuilds the elements related to this component in case of
  35044. * context lost for instance.
  35045. */
  35046. rebuild(): void;
  35047. /**
  35048. * Serializes the component data to the specified json object
  35049. * @param serializationObject The object to serialize to
  35050. */
  35051. serialize(serializationObject: any): void;
  35052. /**
  35053. * Adds all the element from the container to the scene
  35054. * @param container the container holding the elements
  35055. */
  35056. addFromContainer(container: AbstractScene): void;
  35057. /**
  35058. * Removes all the elements in the container from the scene
  35059. * @param container contains the elements to remove
  35060. * @param dispose if the removed element should be disposed (default: false)
  35061. */
  35062. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35063. /**
  35064. * Disposes the component and the associated ressources.
  35065. */
  35066. dispose(): void;
  35067. /**
  35068. * Disables audio in the associated scene.
  35069. */
  35070. disableAudio(): void;
  35071. /**
  35072. * Enables audio in the associated scene.
  35073. */
  35074. enableAudio(): void;
  35075. /**
  35076. * Switch audio to headphone output.
  35077. */
  35078. switchAudioModeForHeadphones(): void;
  35079. /**
  35080. * Switch audio to normal speakers.
  35081. */
  35082. switchAudioModeForNormalSpeakers(): void;
  35083. private _afterRender;
  35084. }
  35085. }
  35086. declare module "babylonjs/Audio/weightedsound" {
  35087. import { Sound } from "babylonjs/Audio/sound";
  35088. /**
  35089. * Wraps one or more Sound objects and selects one with random weight for playback.
  35090. */
  35091. export class WeightedSound {
  35092. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35093. loop: boolean;
  35094. private _coneInnerAngle;
  35095. private _coneOuterAngle;
  35096. private _volume;
  35097. /** A Sound is currently playing. */
  35098. isPlaying: boolean;
  35099. /** A Sound is currently paused. */
  35100. isPaused: boolean;
  35101. private _sounds;
  35102. private _weights;
  35103. private _currentIndex?;
  35104. /**
  35105. * Creates a new WeightedSound from the list of sounds given.
  35106. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35107. * @param sounds Array of Sounds that will be selected from.
  35108. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35109. */
  35110. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35111. /**
  35112. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35113. */
  35114. /**
  35115. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35116. */
  35117. directionalConeInnerAngle: number;
  35118. /**
  35119. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35120. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35121. */
  35122. /**
  35123. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35124. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35125. */
  35126. directionalConeOuterAngle: number;
  35127. /**
  35128. * Playback volume.
  35129. */
  35130. /**
  35131. * Playback volume.
  35132. */
  35133. volume: number;
  35134. private _onended;
  35135. /**
  35136. * Suspend playback
  35137. */
  35138. pause(): void;
  35139. /**
  35140. * Stop playback
  35141. */
  35142. stop(): void;
  35143. /**
  35144. * Start playback.
  35145. * @param startOffset Position the clip head at a specific time in seconds.
  35146. */
  35147. play(startOffset?: number): void;
  35148. }
  35149. }
  35150. declare module "babylonjs/Audio/index" {
  35151. export * from "babylonjs/Audio/analyser";
  35152. export * from "babylonjs/Audio/audioEngine";
  35153. export * from "babylonjs/Audio/audioSceneComponent";
  35154. export * from "babylonjs/Audio/sound";
  35155. export * from "babylonjs/Audio/soundTrack";
  35156. export * from "babylonjs/Audio/weightedsound";
  35157. }
  35158. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35159. import { Behavior } from "babylonjs/Behaviors/behavior";
  35160. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35161. import { BackEase } from "babylonjs/Animations/easing";
  35162. /**
  35163. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35164. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35165. */
  35166. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35167. /**
  35168. * Gets the name of the behavior.
  35169. */
  35170. readonly name: string;
  35171. /**
  35172. * The easing function used by animations
  35173. */
  35174. static EasingFunction: BackEase;
  35175. /**
  35176. * The easing mode used by animations
  35177. */
  35178. static EasingMode: number;
  35179. /**
  35180. * The duration of the animation, in milliseconds
  35181. */
  35182. transitionDuration: number;
  35183. /**
  35184. * Length of the distance animated by the transition when lower radius is reached
  35185. */
  35186. lowerRadiusTransitionRange: number;
  35187. /**
  35188. * Length of the distance animated by the transition when upper radius is reached
  35189. */
  35190. upperRadiusTransitionRange: number;
  35191. private _autoTransitionRange;
  35192. /**
  35193. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35194. */
  35195. /**
  35196. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35197. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35198. */
  35199. autoTransitionRange: boolean;
  35200. private _attachedCamera;
  35201. private _onAfterCheckInputsObserver;
  35202. private _onMeshTargetChangedObserver;
  35203. /**
  35204. * Initializes the behavior.
  35205. */
  35206. init(): void;
  35207. /**
  35208. * Attaches the behavior to its arc rotate camera.
  35209. * @param camera Defines the camera to attach the behavior to
  35210. */
  35211. attach(camera: ArcRotateCamera): void;
  35212. /**
  35213. * Detaches the behavior from its current arc rotate camera.
  35214. */
  35215. detach(): void;
  35216. private _radiusIsAnimating;
  35217. private _radiusBounceTransition;
  35218. private _animatables;
  35219. private _cachedWheelPrecision;
  35220. /**
  35221. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35222. * @param radiusLimit The limit to check against.
  35223. * @return Bool to indicate if at limit.
  35224. */
  35225. private _isRadiusAtLimit;
  35226. /**
  35227. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35228. * @param radiusDelta The delta by which to animate to. Can be negative.
  35229. */
  35230. private _applyBoundRadiusAnimation;
  35231. /**
  35232. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35233. */
  35234. protected _clearAnimationLocks(): void;
  35235. /**
  35236. * Stops and removes all animations that have been applied to the camera
  35237. */
  35238. stopAllAnimations(): void;
  35239. }
  35240. }
  35241. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35242. import { Behavior } from "babylonjs/Behaviors/behavior";
  35243. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35244. import { ExponentialEase } from "babylonjs/Animations/easing";
  35245. import { Nullable } from "babylonjs/types";
  35246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35247. import { Vector3 } from "babylonjs/Maths/math";
  35248. /**
  35249. * 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.
  35250. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35251. */
  35252. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35253. /**
  35254. * Gets the name of the behavior.
  35255. */
  35256. readonly name: string;
  35257. private _mode;
  35258. private _radiusScale;
  35259. private _positionScale;
  35260. private _defaultElevation;
  35261. private _elevationReturnTime;
  35262. private _elevationReturnWaitTime;
  35263. private _zoomStopsAnimation;
  35264. private _framingTime;
  35265. /**
  35266. * The easing function used by animations
  35267. */
  35268. static EasingFunction: ExponentialEase;
  35269. /**
  35270. * The easing mode used by animations
  35271. */
  35272. static EasingMode: number;
  35273. /**
  35274. * Sets the current mode used by the behavior
  35275. */
  35276. /**
  35277. * Gets current mode used by the behavior.
  35278. */
  35279. mode: number;
  35280. /**
  35281. * Sets the scale applied to the radius (1 by default)
  35282. */
  35283. /**
  35284. * Gets the scale applied to the radius
  35285. */
  35286. radiusScale: number;
  35287. /**
  35288. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35289. */
  35290. /**
  35291. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35292. */
  35293. positionScale: number;
  35294. /**
  35295. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35296. * behaviour is triggered, in radians.
  35297. */
  35298. /**
  35299. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35300. * behaviour is triggered, in radians.
  35301. */
  35302. defaultElevation: number;
  35303. /**
  35304. * Sets the time (in milliseconds) taken to return to the default beta position.
  35305. * Negative value indicates camera should not return to default.
  35306. */
  35307. /**
  35308. * Gets the time (in milliseconds) taken to return to the default beta position.
  35309. * Negative value indicates camera should not return to default.
  35310. */
  35311. elevationReturnTime: number;
  35312. /**
  35313. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35314. */
  35315. /**
  35316. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35317. */
  35318. elevationReturnWaitTime: number;
  35319. /**
  35320. * Sets the flag that indicates if user zooming should stop animation.
  35321. */
  35322. /**
  35323. * Gets the flag that indicates if user zooming should stop animation.
  35324. */
  35325. zoomStopsAnimation: boolean;
  35326. /**
  35327. * Sets the transition time when framing the mesh, in milliseconds
  35328. */
  35329. /**
  35330. * Gets the transition time when framing the mesh, in milliseconds
  35331. */
  35332. framingTime: number;
  35333. /**
  35334. * Define if the behavior should automatically change the configured
  35335. * camera limits and sensibilities.
  35336. */
  35337. autoCorrectCameraLimitsAndSensibility: boolean;
  35338. private _onPrePointerObservableObserver;
  35339. private _onAfterCheckInputsObserver;
  35340. private _onMeshTargetChangedObserver;
  35341. private _attachedCamera;
  35342. private _isPointerDown;
  35343. private _lastInteractionTime;
  35344. /**
  35345. * Initializes the behavior.
  35346. */
  35347. init(): void;
  35348. /**
  35349. * Attaches the behavior to its arc rotate camera.
  35350. * @param camera Defines the camera to attach the behavior to
  35351. */
  35352. attach(camera: ArcRotateCamera): void;
  35353. /**
  35354. * Detaches the behavior from its current arc rotate camera.
  35355. */
  35356. detach(): void;
  35357. private _animatables;
  35358. private _betaIsAnimating;
  35359. private _betaTransition;
  35360. private _radiusTransition;
  35361. private _vectorTransition;
  35362. /**
  35363. * Targets the given mesh and updates zoom level accordingly.
  35364. * @param mesh The mesh to target.
  35365. * @param radius Optional. If a cached radius position already exists, overrides default.
  35366. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35367. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35368. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35369. */
  35370. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35371. /**
  35372. * Targets the given mesh with its children and updates zoom level accordingly.
  35373. * @param mesh The mesh to target.
  35374. * @param radius Optional. If a cached radius position already exists, overrides default.
  35375. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35376. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35377. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35378. */
  35379. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35380. /**
  35381. * Targets the given meshes with their children and updates zoom level accordingly.
  35382. * @param meshes The mesh to target.
  35383. * @param radius Optional. If a cached radius position already exists, overrides default.
  35384. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35385. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35386. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35387. */
  35388. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35389. /**
  35390. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35391. * @param minimumWorld Determines the smaller position of the bounding box extend
  35392. * @param maximumWorld Determines the bigger position of the bounding box extend
  35393. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35394. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35395. */
  35396. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35397. /**
  35398. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35399. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35400. * frustum width.
  35401. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35402. * to fully enclose the mesh in the viewing frustum.
  35403. */
  35404. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35405. /**
  35406. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35407. * is automatically returned to its default position (expected to be above ground plane).
  35408. */
  35409. private _maintainCameraAboveGround;
  35410. /**
  35411. * Returns the frustum slope based on the canvas ratio and camera FOV
  35412. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35413. */
  35414. private _getFrustumSlope;
  35415. /**
  35416. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35417. */
  35418. private _clearAnimationLocks;
  35419. /**
  35420. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35421. */
  35422. private _applyUserInteraction;
  35423. /**
  35424. * Stops and removes all animations that have been applied to the camera
  35425. */
  35426. stopAllAnimations(): void;
  35427. /**
  35428. * Gets a value indicating if the user is moving the camera
  35429. */
  35430. readonly isUserIsMoving: boolean;
  35431. /**
  35432. * The camera can move all the way towards the mesh.
  35433. */
  35434. static IgnoreBoundsSizeMode: number;
  35435. /**
  35436. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35437. */
  35438. static FitFrustumSidesMode: number;
  35439. }
  35440. }
  35441. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35442. import { Nullable } from "babylonjs/types";
  35443. import { Camera } from "babylonjs/Cameras/camera";
  35444. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35445. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35446. /**
  35447. * Base class for Camera Pointer Inputs.
  35448. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35449. * for example usage.
  35450. */
  35451. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35452. /**
  35453. * Defines the camera the input is attached to.
  35454. */
  35455. abstract camera: Camera;
  35456. /**
  35457. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35458. */
  35459. protected _altKey: boolean;
  35460. protected _ctrlKey: boolean;
  35461. protected _metaKey: boolean;
  35462. protected _shiftKey: boolean;
  35463. /**
  35464. * Which mouse buttons were pressed at time of last mouse event.
  35465. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35466. */
  35467. protected _buttonsPressed: number;
  35468. /**
  35469. * Defines the buttons associated with the input to handle camera move.
  35470. */
  35471. buttons: number[];
  35472. /**
  35473. * Attach the input controls to a specific dom element to get the input from.
  35474. * @param element Defines the element the controls should be listened from
  35475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35476. */
  35477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35478. /**
  35479. * Detach the current controls from the specified dom element.
  35480. * @param element Defines the element to stop listening the inputs from
  35481. */
  35482. detachControl(element: Nullable<HTMLElement>): void;
  35483. /**
  35484. * Gets the class name of the current input.
  35485. * @returns the class name
  35486. */
  35487. getClassName(): string;
  35488. /**
  35489. * Get the friendly name associated with the input class.
  35490. * @returns the input friendly name
  35491. */
  35492. getSimpleName(): string;
  35493. /**
  35494. * Called on pointer POINTERDOUBLETAP event.
  35495. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35496. */
  35497. protected onDoubleTap(type: string): void;
  35498. /**
  35499. * Called on pointer POINTERMOVE event if only a single touch is active.
  35500. * Override this method to provide functionality.
  35501. */
  35502. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35503. /**
  35504. * Called on pointer POINTERMOVE event if multiple touches are active.
  35505. * Override this method to provide functionality.
  35506. */
  35507. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35508. /**
  35509. * Called on JS contextmenu event.
  35510. * Override this method to provide functionality.
  35511. */
  35512. protected onContextMenu(evt: PointerEvent): void;
  35513. /**
  35514. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35515. * press.
  35516. * Override this method to provide functionality.
  35517. */
  35518. protected onButtonDown(evt: PointerEvent): void;
  35519. /**
  35520. * Called each time a new POINTERUP event occurs. Ie, for each button
  35521. * release.
  35522. * Override this method to provide functionality.
  35523. */
  35524. protected onButtonUp(evt: PointerEvent): void;
  35525. /**
  35526. * Called when window becomes inactive.
  35527. * Override this method to provide functionality.
  35528. */
  35529. protected onLostFocus(): void;
  35530. private _pointerInput;
  35531. private _observer;
  35532. private _onLostFocus;
  35533. private pointA;
  35534. private pointB;
  35535. }
  35536. }
  35537. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35538. import { Nullable } from "babylonjs/types";
  35539. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35540. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35541. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35542. /**
  35543. * Manage the pointers inputs to control an arc rotate camera.
  35544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35545. */
  35546. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35547. /**
  35548. * Defines the camera the input is attached to.
  35549. */
  35550. camera: ArcRotateCamera;
  35551. /**
  35552. * Gets the class name of the current input.
  35553. * @returns the class name
  35554. */
  35555. getClassName(): string;
  35556. /**
  35557. * Defines the buttons associated with the input to handle camera move.
  35558. */
  35559. buttons: number[];
  35560. /**
  35561. * Defines the pointer angular sensibility along the X axis or how fast is
  35562. * the camera rotating.
  35563. */
  35564. angularSensibilityX: number;
  35565. /**
  35566. * Defines the pointer angular sensibility along the Y axis or how fast is
  35567. * the camera rotating.
  35568. */
  35569. angularSensibilityY: number;
  35570. /**
  35571. * Defines the pointer pinch precision or how fast is the camera zooming.
  35572. */
  35573. pinchPrecision: number;
  35574. /**
  35575. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35576. * from 0.
  35577. * It defines the percentage of current camera.radius to use as delta when
  35578. * pinch zoom is used.
  35579. */
  35580. pinchDeltaPercentage: number;
  35581. /**
  35582. * Defines the pointer panning sensibility or how fast is the camera moving.
  35583. */
  35584. panningSensibility: number;
  35585. /**
  35586. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35587. */
  35588. multiTouchPanning: boolean;
  35589. /**
  35590. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35591. * zoom (pinch) through multitouch.
  35592. */
  35593. multiTouchPanAndZoom: boolean;
  35594. /**
  35595. * Revers pinch action direction.
  35596. */
  35597. pinchInwards: boolean;
  35598. private _isPanClick;
  35599. private _twoFingerActivityCount;
  35600. private _isPinching;
  35601. /**
  35602. * Called on pointer POINTERMOVE event if only a single touch is active.
  35603. */
  35604. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35605. /**
  35606. * Called on pointer POINTERDOUBLETAP event.
  35607. */
  35608. protected onDoubleTap(type: string): void;
  35609. /**
  35610. * Called on pointer POINTERMOVE event if multiple touches are active.
  35611. */
  35612. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35613. /**
  35614. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35615. * press.
  35616. */
  35617. protected onButtonDown(evt: PointerEvent): void;
  35618. /**
  35619. * Called each time a new POINTERUP event occurs. Ie, for each button
  35620. * release.
  35621. */
  35622. protected onButtonUp(evt: PointerEvent): void;
  35623. /**
  35624. * Called when window becomes inactive.
  35625. */
  35626. protected onLostFocus(): void;
  35627. }
  35628. }
  35629. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35630. import { Nullable } from "babylonjs/types";
  35631. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35632. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35633. /**
  35634. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35636. */
  35637. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35638. /**
  35639. * Defines the camera the input is attached to.
  35640. */
  35641. camera: ArcRotateCamera;
  35642. /**
  35643. * Defines the list of key codes associated with the up action (increase alpha)
  35644. */
  35645. keysUp: number[];
  35646. /**
  35647. * Defines the list of key codes associated with the down action (decrease alpha)
  35648. */
  35649. keysDown: number[];
  35650. /**
  35651. * Defines the list of key codes associated with the left action (increase beta)
  35652. */
  35653. keysLeft: number[];
  35654. /**
  35655. * Defines the list of key codes associated with the right action (decrease beta)
  35656. */
  35657. keysRight: number[];
  35658. /**
  35659. * Defines the list of key codes associated with the reset action.
  35660. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35661. */
  35662. keysReset: number[];
  35663. /**
  35664. * Defines the panning sensibility of the inputs.
  35665. * (How fast is the camera paning)
  35666. */
  35667. panningSensibility: number;
  35668. /**
  35669. * Defines the zooming sensibility of the inputs.
  35670. * (How fast is the camera zooming)
  35671. */
  35672. zoomingSensibility: number;
  35673. /**
  35674. * Defines wether maintaining the alt key down switch the movement mode from
  35675. * orientation to zoom.
  35676. */
  35677. useAltToZoom: boolean;
  35678. /**
  35679. * Rotation speed of the camera
  35680. */
  35681. angularSpeed: number;
  35682. private _keys;
  35683. private _ctrlPressed;
  35684. private _altPressed;
  35685. private _onCanvasBlurObserver;
  35686. private _onKeyboardObserver;
  35687. private _engine;
  35688. private _scene;
  35689. /**
  35690. * Attach the input controls to a specific dom element to get the input from.
  35691. * @param element Defines the element the controls should be listened from
  35692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35693. */
  35694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35695. /**
  35696. * Detach the current controls from the specified dom element.
  35697. * @param element Defines the element to stop listening the inputs from
  35698. */
  35699. detachControl(element: Nullable<HTMLElement>): void;
  35700. /**
  35701. * Update the current camera state depending on the inputs that have been used this frame.
  35702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35703. */
  35704. checkInputs(): void;
  35705. /**
  35706. * Gets the class name of the current intput.
  35707. * @returns the class name
  35708. */
  35709. getClassName(): string;
  35710. /**
  35711. * Get the friendly name associated with the input class.
  35712. * @returns the input friendly name
  35713. */
  35714. getSimpleName(): string;
  35715. }
  35716. }
  35717. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35718. import { Nullable } from "babylonjs/types";
  35719. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35720. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35721. /**
  35722. * Manage the mouse wheel inputs to control an arc rotate camera.
  35723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35724. */
  35725. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35726. /**
  35727. * Defines the camera the input is attached to.
  35728. */
  35729. camera: ArcRotateCamera;
  35730. /**
  35731. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35732. */
  35733. wheelPrecision: number;
  35734. /**
  35735. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35736. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35737. */
  35738. wheelDeltaPercentage: number;
  35739. private _wheel;
  35740. private _observer;
  35741. /**
  35742. * Attach the input controls to a specific dom element to get the input from.
  35743. * @param element Defines the element the controls should be listened from
  35744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35745. */
  35746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35747. /**
  35748. * Detach the current controls from the specified dom element.
  35749. * @param element Defines the element to stop listening the inputs from
  35750. */
  35751. detachControl(element: Nullable<HTMLElement>): void;
  35752. /**
  35753. * Gets the class name of the current intput.
  35754. * @returns the class name
  35755. */
  35756. getClassName(): string;
  35757. /**
  35758. * Get the friendly name associated with the input class.
  35759. * @returns the input friendly name
  35760. */
  35761. getSimpleName(): string;
  35762. }
  35763. }
  35764. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35765. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35766. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35767. /**
  35768. * Default Inputs manager for the ArcRotateCamera.
  35769. * It groups all the default supported inputs for ease of use.
  35770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35771. */
  35772. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35773. /**
  35774. * Instantiates a new ArcRotateCameraInputsManager.
  35775. * @param camera Defines the camera the inputs belong to
  35776. */
  35777. constructor(camera: ArcRotateCamera);
  35778. /**
  35779. * Add mouse wheel input support to the input manager.
  35780. * @returns the current input manager
  35781. */
  35782. addMouseWheel(): ArcRotateCameraInputsManager;
  35783. /**
  35784. * Add pointers input support to the input manager.
  35785. * @returns the current input manager
  35786. */
  35787. addPointers(): ArcRotateCameraInputsManager;
  35788. /**
  35789. * Add keyboard input support to the input manager.
  35790. * @returns the current input manager
  35791. */
  35792. addKeyboard(): ArcRotateCameraInputsManager;
  35793. }
  35794. }
  35795. declare module "babylonjs/Cameras/arcRotateCamera" {
  35796. import { Observable } from "babylonjs/Misc/observable";
  35797. import { Nullable } from "babylonjs/types";
  35798. import { Scene } from "babylonjs/scene";
  35799. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35801. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35802. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35803. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35804. import { Camera } from "babylonjs/Cameras/camera";
  35805. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35806. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35807. import { Collider } from "babylonjs/Collisions/collider";
  35808. /**
  35809. * This represents an orbital type of camera.
  35810. *
  35811. * 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.
  35812. * 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.
  35813. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35814. */
  35815. export class ArcRotateCamera extends TargetCamera {
  35816. /**
  35817. * Defines the rotation angle of the camera along the longitudinal axis.
  35818. */
  35819. alpha: number;
  35820. /**
  35821. * Defines the rotation angle of the camera along the latitudinal axis.
  35822. */
  35823. beta: number;
  35824. /**
  35825. * Defines the radius of the camera from it s target point.
  35826. */
  35827. radius: number;
  35828. protected _target: Vector3;
  35829. protected _targetHost: Nullable<AbstractMesh>;
  35830. /**
  35831. * Defines the target point of the camera.
  35832. * The camera looks towards it form the radius distance.
  35833. */
  35834. target: Vector3;
  35835. /**
  35836. * Define the current local position of the camera in the scene
  35837. */
  35838. position: Vector3;
  35839. /**
  35840. * Current inertia value on the longitudinal axis.
  35841. * The bigger this number the longer it will take for the camera to stop.
  35842. */
  35843. inertialAlphaOffset: number;
  35844. /**
  35845. * Current inertia value on the latitudinal axis.
  35846. * The bigger this number the longer it will take for the camera to stop.
  35847. */
  35848. inertialBetaOffset: number;
  35849. /**
  35850. * Current inertia value on the radius axis.
  35851. * The bigger this number the longer it will take for the camera to stop.
  35852. */
  35853. inertialRadiusOffset: number;
  35854. /**
  35855. * Minimum allowed angle on the longitudinal axis.
  35856. * This can help limiting how the Camera is able to move in the scene.
  35857. */
  35858. lowerAlphaLimit: Nullable<number>;
  35859. /**
  35860. * Maximum allowed angle on the longitudinal axis.
  35861. * This can help limiting how the Camera is able to move in the scene.
  35862. */
  35863. upperAlphaLimit: Nullable<number>;
  35864. /**
  35865. * Minimum allowed angle on the latitudinal axis.
  35866. * This can help limiting how the Camera is able to move in the scene.
  35867. */
  35868. lowerBetaLimit: number;
  35869. /**
  35870. * Maximum allowed angle on the latitudinal axis.
  35871. * This can help limiting how the Camera is able to move in the scene.
  35872. */
  35873. upperBetaLimit: number;
  35874. /**
  35875. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35876. * This can help limiting how the Camera is able to move in the scene.
  35877. */
  35878. lowerRadiusLimit: Nullable<number>;
  35879. /**
  35880. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35881. * This can help limiting how the Camera is able to move in the scene.
  35882. */
  35883. upperRadiusLimit: Nullable<number>;
  35884. /**
  35885. * Defines the current inertia value used during panning of the camera along the X axis.
  35886. */
  35887. inertialPanningX: number;
  35888. /**
  35889. * Defines the current inertia value used during panning of the camera along the Y axis.
  35890. */
  35891. inertialPanningY: number;
  35892. /**
  35893. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35894. * Basically if your fingers moves away from more than this distance you will be considered
  35895. * in pinch mode.
  35896. */
  35897. pinchToPanMaxDistance: number;
  35898. /**
  35899. * Defines the maximum distance the camera can pan.
  35900. * This could help keeping the cammera always in your scene.
  35901. */
  35902. panningDistanceLimit: Nullable<number>;
  35903. /**
  35904. * Defines the target of the camera before paning.
  35905. */
  35906. panningOriginTarget: Vector3;
  35907. /**
  35908. * Defines the value of the inertia used during panning.
  35909. * 0 would mean stop inertia and one would mean no decelleration at all.
  35910. */
  35911. panningInertia: number;
  35912. /**
  35913. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35914. */
  35915. angularSensibilityX: number;
  35916. /**
  35917. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35918. */
  35919. angularSensibilityY: number;
  35920. /**
  35921. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35922. */
  35923. pinchPrecision: number;
  35924. /**
  35925. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35926. * It will be used instead of pinchDeltaPrecision if different from 0.
  35927. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35928. */
  35929. pinchDeltaPercentage: number;
  35930. /**
  35931. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35932. */
  35933. panningSensibility: number;
  35934. /**
  35935. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35936. */
  35937. keysUp: number[];
  35938. /**
  35939. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35940. */
  35941. keysDown: number[];
  35942. /**
  35943. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35944. */
  35945. keysLeft: number[];
  35946. /**
  35947. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35948. */
  35949. keysRight: number[];
  35950. /**
  35951. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35952. */
  35953. wheelPrecision: number;
  35954. /**
  35955. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35956. * It will be used instead of pinchDeltaPrecision if different from 0.
  35957. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35958. */
  35959. wheelDeltaPercentage: number;
  35960. /**
  35961. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35962. */
  35963. zoomOnFactor: number;
  35964. /**
  35965. * Defines a screen offset for the camera position.
  35966. */
  35967. targetScreenOffset: Vector2;
  35968. /**
  35969. * Allows the camera to be completely reversed.
  35970. * If false the camera can not arrive upside down.
  35971. */
  35972. allowUpsideDown: boolean;
  35973. /**
  35974. * Define if double tap/click is used to restore the previously saved state of the camera.
  35975. */
  35976. useInputToRestoreState: boolean;
  35977. /** @hidden */
  35978. _viewMatrix: Matrix;
  35979. /** @hidden */
  35980. _useCtrlForPanning: boolean;
  35981. /** @hidden */
  35982. _panningMouseButton: number;
  35983. /**
  35984. * Defines the input associated to the camera.
  35985. */
  35986. inputs: ArcRotateCameraInputsManager;
  35987. /** @hidden */
  35988. _reset: () => void;
  35989. /**
  35990. * Defines the allowed panning axis.
  35991. */
  35992. panningAxis: Vector3;
  35993. protected _localDirection: Vector3;
  35994. protected _transformedDirection: Vector3;
  35995. private _bouncingBehavior;
  35996. /**
  35997. * Gets the bouncing behavior of the camera if it has been enabled.
  35998. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35999. */
  36000. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36001. /**
  36002. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36003. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36004. */
  36005. useBouncingBehavior: boolean;
  36006. private _framingBehavior;
  36007. /**
  36008. * Gets the framing behavior of the camera if it has been enabled.
  36009. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36010. */
  36011. readonly framingBehavior: Nullable<FramingBehavior>;
  36012. /**
  36013. * Defines if the framing behavior of the camera is enabled on the camera.
  36014. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36015. */
  36016. useFramingBehavior: boolean;
  36017. private _autoRotationBehavior;
  36018. /**
  36019. * Gets the auto rotation behavior of the camera if it has been enabled.
  36020. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36021. */
  36022. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36023. /**
  36024. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36025. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36026. */
  36027. useAutoRotationBehavior: boolean;
  36028. /**
  36029. * Observable triggered when the mesh target has been changed on the camera.
  36030. */
  36031. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36032. /**
  36033. * Event raised when the camera is colliding with a mesh.
  36034. */
  36035. onCollide: (collidedMesh: AbstractMesh) => void;
  36036. /**
  36037. * Defines whether the camera should check collision with the objects oh the scene.
  36038. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36039. */
  36040. checkCollisions: boolean;
  36041. /**
  36042. * Defines the collision radius of the camera.
  36043. * This simulates a sphere around the camera.
  36044. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36045. */
  36046. collisionRadius: Vector3;
  36047. protected _collider: Collider;
  36048. protected _previousPosition: Vector3;
  36049. protected _collisionVelocity: Vector3;
  36050. protected _newPosition: Vector3;
  36051. protected _previousAlpha: number;
  36052. protected _previousBeta: number;
  36053. protected _previousRadius: number;
  36054. protected _collisionTriggered: boolean;
  36055. protected _targetBoundingCenter: Nullable<Vector3>;
  36056. private _computationVector;
  36057. private _tempAxisVector;
  36058. private _tempAxisRotationMatrix;
  36059. /**
  36060. * Instantiates a new ArcRotateCamera in a given scene
  36061. * @param name Defines the name of the camera
  36062. * @param alpha Defines the camera rotation along the logitudinal axis
  36063. * @param beta Defines the camera rotation along the latitudinal axis
  36064. * @param radius Defines the camera distance from its target
  36065. * @param target Defines the camera target
  36066. * @param scene Defines the scene the camera belongs to
  36067. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36068. */
  36069. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36070. /** @hidden */
  36071. _initCache(): void;
  36072. /** @hidden */
  36073. _updateCache(ignoreParentClass?: boolean): void;
  36074. protected _getTargetPosition(): Vector3;
  36075. private _storedAlpha;
  36076. private _storedBeta;
  36077. private _storedRadius;
  36078. private _storedTarget;
  36079. /**
  36080. * Stores the current state of the camera (alpha, beta, radius and target)
  36081. * @returns the camera itself
  36082. */
  36083. storeState(): Camera;
  36084. /**
  36085. * @hidden
  36086. * Restored camera state. You must call storeState() first
  36087. */
  36088. _restoreStateValues(): boolean;
  36089. /** @hidden */
  36090. _isSynchronizedViewMatrix(): boolean;
  36091. /**
  36092. * Attached controls to the current camera.
  36093. * @param element Defines the element the controls should be listened from
  36094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36095. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36096. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36097. */
  36098. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36099. /**
  36100. * Detach the current controls from the camera.
  36101. * The camera will stop reacting to inputs.
  36102. * @param element Defines the element to stop listening the inputs from
  36103. */
  36104. detachControl(element: HTMLElement): void;
  36105. /** @hidden */
  36106. _checkInputs(): void;
  36107. protected _checkLimits(): void;
  36108. /**
  36109. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36110. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  36111. */
  36112. rebuildAnglesAndRadius(updateView?: boolean): void;
  36113. /**
  36114. * Use a position to define the current camera related information like aplha, beta and radius
  36115. * @param position Defines the position to set the camera at
  36116. */
  36117. setPosition(position: Vector3): void;
  36118. /**
  36119. * Defines the target the camera should look at.
  36120. * This will automatically adapt alpha beta and radius to fit within the new target.
  36121. * @param target Defines the new target as a Vector or a mesh
  36122. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36123. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36124. */
  36125. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36126. /** @hidden */
  36127. _getViewMatrix(): Matrix;
  36128. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36129. /**
  36130. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36131. * @param meshes Defines the mesh to zoom on
  36132. * @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)
  36133. */
  36134. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36135. /**
  36136. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36137. * The target will be changed but the radius
  36138. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36139. * @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)
  36140. */
  36141. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36142. min: Vector3;
  36143. max: Vector3;
  36144. distance: number;
  36145. }, doNotUpdateMaxZ?: boolean): void;
  36146. /**
  36147. * @override
  36148. * Override Camera.createRigCamera
  36149. */
  36150. createRigCamera(name: string, cameraIndex: number): Camera;
  36151. /**
  36152. * @hidden
  36153. * @override
  36154. * Override Camera._updateRigCameras
  36155. */
  36156. _updateRigCameras(): void;
  36157. /**
  36158. * Destroy the camera and release the current resources hold by it.
  36159. */
  36160. dispose(): void;
  36161. /**
  36162. * Gets the current object class name.
  36163. * @return the class name
  36164. */
  36165. getClassName(): string;
  36166. }
  36167. }
  36168. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36169. import { Behavior } from "babylonjs/Behaviors/behavior";
  36170. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36171. /**
  36172. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36174. */
  36175. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36176. /**
  36177. * Gets the name of the behavior.
  36178. */
  36179. readonly name: string;
  36180. private _zoomStopsAnimation;
  36181. private _idleRotationSpeed;
  36182. private _idleRotationWaitTime;
  36183. private _idleRotationSpinupTime;
  36184. /**
  36185. * Sets the flag that indicates if user zooming should stop animation.
  36186. */
  36187. /**
  36188. * Gets the flag that indicates if user zooming should stop animation.
  36189. */
  36190. zoomStopsAnimation: boolean;
  36191. /**
  36192. * Sets the default speed at which the camera rotates around the model.
  36193. */
  36194. /**
  36195. * Gets the default speed at which the camera rotates around the model.
  36196. */
  36197. idleRotationSpeed: number;
  36198. /**
  36199. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36200. */
  36201. /**
  36202. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36203. */
  36204. idleRotationWaitTime: number;
  36205. /**
  36206. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36207. */
  36208. /**
  36209. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36210. */
  36211. idleRotationSpinupTime: number;
  36212. /**
  36213. * Gets a value indicating if the camera is currently rotating because of this behavior
  36214. */
  36215. readonly rotationInProgress: boolean;
  36216. private _onPrePointerObservableObserver;
  36217. private _onAfterCheckInputsObserver;
  36218. private _attachedCamera;
  36219. private _isPointerDown;
  36220. private _lastFrameTime;
  36221. private _lastInteractionTime;
  36222. private _cameraRotationSpeed;
  36223. /**
  36224. * Initializes the behavior.
  36225. */
  36226. init(): void;
  36227. /**
  36228. * Attaches the behavior to its arc rotate camera.
  36229. * @param camera Defines the camera to attach the behavior to
  36230. */
  36231. attach(camera: ArcRotateCamera): void;
  36232. /**
  36233. * Detaches the behavior from its current arc rotate camera.
  36234. */
  36235. detach(): void;
  36236. /**
  36237. * Returns true if user is scrolling.
  36238. * @return true if user is scrolling.
  36239. */
  36240. private _userIsZooming;
  36241. private _lastFrameRadius;
  36242. private _shouldAnimationStopForInteraction;
  36243. /**
  36244. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36245. */
  36246. private _applyUserInteraction;
  36247. private _userIsMoving;
  36248. }
  36249. }
  36250. declare module "babylonjs/Behaviors/Cameras/index" {
  36251. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36252. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36253. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36254. }
  36255. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36256. import { Mesh } from "babylonjs/Meshes/mesh";
  36257. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36258. import { Behavior } from "babylonjs/Behaviors/behavior";
  36259. /**
  36260. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36261. */
  36262. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36263. private ui;
  36264. /**
  36265. * The name of the behavior
  36266. */
  36267. name: string;
  36268. /**
  36269. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36270. */
  36271. distanceAwayFromFace: number;
  36272. /**
  36273. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36274. */
  36275. distanceAwayFromBottomOfFace: number;
  36276. private _faceVectors;
  36277. private _target;
  36278. private _scene;
  36279. private _onRenderObserver;
  36280. private _tmpMatrix;
  36281. private _tmpVector;
  36282. /**
  36283. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36284. * @param ui The transform node that should be attched to the mesh
  36285. */
  36286. constructor(ui: TransformNode);
  36287. /**
  36288. * Initializes the behavior
  36289. */
  36290. init(): void;
  36291. private _closestFace;
  36292. private _zeroVector;
  36293. private _lookAtTmpMatrix;
  36294. private _lookAtToRef;
  36295. /**
  36296. * Attaches the AttachToBoxBehavior to the passed in mesh
  36297. * @param target The mesh that the specified node will be attached to
  36298. */
  36299. attach(target: Mesh): void;
  36300. /**
  36301. * Detaches the behavior from the mesh
  36302. */
  36303. detach(): void;
  36304. }
  36305. }
  36306. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36307. import { Behavior } from "babylonjs/Behaviors/behavior";
  36308. import { Mesh } from "babylonjs/Meshes/mesh";
  36309. /**
  36310. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36311. */
  36312. export class FadeInOutBehavior implements Behavior<Mesh> {
  36313. /**
  36314. * Time in milliseconds to delay before fading in (Default: 0)
  36315. */
  36316. delay: number;
  36317. /**
  36318. * Time in milliseconds for the mesh to fade in (Default: 300)
  36319. */
  36320. fadeInTime: number;
  36321. private _millisecondsPerFrame;
  36322. private _hovered;
  36323. private _hoverValue;
  36324. private _ownerNode;
  36325. /**
  36326. * Instatiates the FadeInOutBehavior
  36327. */
  36328. constructor();
  36329. /**
  36330. * The name of the behavior
  36331. */
  36332. readonly name: string;
  36333. /**
  36334. * Initializes the behavior
  36335. */
  36336. init(): void;
  36337. /**
  36338. * Attaches the fade behavior on the passed in mesh
  36339. * @param ownerNode The mesh that will be faded in/out once attached
  36340. */
  36341. attach(ownerNode: Mesh): void;
  36342. /**
  36343. * Detaches the behavior from the mesh
  36344. */
  36345. detach(): void;
  36346. /**
  36347. * Triggers the mesh to begin fading in or out
  36348. * @param value if the object should fade in or out (true to fade in)
  36349. */
  36350. fadeIn(value: boolean): void;
  36351. private _update;
  36352. private _setAllVisibility;
  36353. }
  36354. }
  36355. declare module "babylonjs/Misc/pivotTools" {
  36356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36357. /**
  36358. * Class containing a set of static utilities functions for managing Pivots
  36359. * @hidden
  36360. */
  36361. export class PivotTools {
  36362. private static _PivotCached;
  36363. private static _OldPivotPoint;
  36364. private static _PivotTranslation;
  36365. private static _PivotTmpVector;
  36366. /** @hidden */
  36367. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36368. /** @hidden */
  36369. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36370. }
  36371. }
  36372. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36373. import { Scene } from "babylonjs/scene";
  36374. import { Vector4, Plane } from "babylonjs/Maths/math";
  36375. import { Mesh } from "babylonjs/Meshes/mesh";
  36376. /**
  36377. * Class containing static functions to help procedurally build meshes
  36378. */
  36379. export class PlaneBuilder {
  36380. /**
  36381. * Creates a plane mesh
  36382. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36383. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36384. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36388. * @param name defines the name of the mesh
  36389. * @param options defines the options used to create the mesh
  36390. * @param scene defines the hosting scene
  36391. * @returns the plane mesh
  36392. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36393. */
  36394. static CreatePlane(name: string, options: {
  36395. size?: number;
  36396. width?: number;
  36397. height?: number;
  36398. sideOrientation?: number;
  36399. frontUVs?: Vector4;
  36400. backUVs?: Vector4;
  36401. updatable?: boolean;
  36402. sourcePlane?: Plane;
  36403. }, scene: Scene): Mesh;
  36404. }
  36405. }
  36406. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36407. import { Behavior } from "babylonjs/Behaviors/behavior";
  36408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36409. import { Observable } from "babylonjs/Misc/observable";
  36410. import { Vector3 } from "babylonjs/Maths/math";
  36411. import { Ray } from "babylonjs/Culling/ray";
  36412. import "babylonjs/Meshes/Builders/planeBuilder";
  36413. /**
  36414. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36415. */
  36416. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36417. private static _AnyMouseID;
  36418. private _attachedNode;
  36419. private _dragPlane;
  36420. private _scene;
  36421. private _pointerObserver;
  36422. private _beforeRenderObserver;
  36423. private static _planeScene;
  36424. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36425. /**
  36426. * 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)
  36427. */
  36428. maxDragAngle: number;
  36429. /**
  36430. * @hidden
  36431. */
  36432. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36433. /**
  36434. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36435. */
  36436. currentDraggingPointerID: number;
  36437. /**
  36438. * The last position where the pointer hit the drag plane in world space
  36439. */
  36440. lastDragPosition: Vector3;
  36441. /**
  36442. * If the behavior is currently in a dragging state
  36443. */
  36444. dragging: boolean;
  36445. /**
  36446. * 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)
  36447. */
  36448. dragDeltaRatio: number;
  36449. /**
  36450. * If the drag plane orientation should be updated during the dragging (Default: true)
  36451. */
  36452. updateDragPlane: boolean;
  36453. private _debugMode;
  36454. private _moving;
  36455. /**
  36456. * Fires each time the attached mesh is dragged with the pointer
  36457. * * delta between last drag position and current drag position in world space
  36458. * * dragDistance along the drag axis
  36459. * * dragPlaneNormal normal of the current drag plane used during the drag
  36460. * * dragPlanePoint in world space where the drag intersects the drag plane
  36461. */
  36462. onDragObservable: Observable<{
  36463. delta: Vector3;
  36464. dragPlanePoint: Vector3;
  36465. dragPlaneNormal: Vector3;
  36466. dragDistance: number;
  36467. pointerId: number;
  36468. }>;
  36469. /**
  36470. * Fires each time a drag begins (eg. mouse down on mesh)
  36471. */
  36472. onDragStartObservable: Observable<{
  36473. dragPlanePoint: Vector3;
  36474. pointerId: number;
  36475. }>;
  36476. /**
  36477. * Fires each time a drag ends (eg. mouse release after drag)
  36478. */
  36479. onDragEndObservable: Observable<{
  36480. dragPlanePoint: Vector3;
  36481. pointerId: number;
  36482. }>;
  36483. /**
  36484. * If the attached mesh should be moved when dragged
  36485. */
  36486. moveAttached: boolean;
  36487. /**
  36488. * If the drag behavior will react to drag events (Default: true)
  36489. */
  36490. enabled: boolean;
  36491. /**
  36492. * If camera controls should be detached during the drag
  36493. */
  36494. detachCameraControls: boolean;
  36495. /**
  36496. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36497. */
  36498. useObjectOrienationForDragging: boolean;
  36499. private _options;
  36500. /**
  36501. * Creates a pointer drag behavior that can be attached to a mesh
  36502. * @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)
  36503. */
  36504. constructor(options?: {
  36505. dragAxis?: Vector3;
  36506. dragPlaneNormal?: Vector3;
  36507. });
  36508. /**
  36509. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36510. */
  36511. validateDrag: (targetPosition: Vector3) => boolean;
  36512. /**
  36513. * The name of the behavior
  36514. */
  36515. readonly name: string;
  36516. /**
  36517. * Initializes the behavior
  36518. */
  36519. init(): void;
  36520. private _tmpVector;
  36521. private _alternatePickedPoint;
  36522. private _worldDragAxis;
  36523. private _targetPosition;
  36524. private _attachedElement;
  36525. /**
  36526. * Attaches the drag behavior the passed in mesh
  36527. * @param ownerNode The mesh that will be dragged around once attached
  36528. */
  36529. attach(ownerNode: AbstractMesh): void;
  36530. /**
  36531. * Force relase the drag action by code.
  36532. */
  36533. releaseDrag(): void;
  36534. private _startDragRay;
  36535. private _lastPointerRay;
  36536. /**
  36537. * Simulates the start of a pointer drag event on the behavior
  36538. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36539. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36540. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36541. */
  36542. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36543. private _startDrag;
  36544. private _dragDelta;
  36545. private _moveDrag;
  36546. private _pickWithRayOnDragPlane;
  36547. private _pointA;
  36548. private _pointB;
  36549. private _pointC;
  36550. private _lineA;
  36551. private _lineB;
  36552. private _localAxis;
  36553. private _lookAt;
  36554. private _updateDragPlanePosition;
  36555. /**
  36556. * Detaches the behavior from the mesh
  36557. */
  36558. detach(): void;
  36559. }
  36560. }
  36561. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36562. import { Mesh } from "babylonjs/Meshes/mesh";
  36563. import { Behavior } from "babylonjs/Behaviors/behavior";
  36564. /**
  36565. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36566. */
  36567. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36568. private _dragBehaviorA;
  36569. private _dragBehaviorB;
  36570. private _startDistance;
  36571. private _initialScale;
  36572. private _targetScale;
  36573. private _ownerNode;
  36574. private _sceneRenderObserver;
  36575. /**
  36576. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36577. */
  36578. constructor();
  36579. /**
  36580. * The name of the behavior
  36581. */
  36582. readonly name: string;
  36583. /**
  36584. * Initializes the behavior
  36585. */
  36586. init(): void;
  36587. private _getCurrentDistance;
  36588. /**
  36589. * Attaches the scale behavior the passed in mesh
  36590. * @param ownerNode The mesh that will be scaled around once attached
  36591. */
  36592. attach(ownerNode: Mesh): void;
  36593. /**
  36594. * Detaches the behavior from the mesh
  36595. */
  36596. detach(): void;
  36597. }
  36598. }
  36599. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36600. import { Behavior } from "babylonjs/Behaviors/behavior";
  36601. import { Mesh } from "babylonjs/Meshes/mesh";
  36602. import { Observable } from "babylonjs/Misc/observable";
  36603. /**
  36604. * 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
  36605. */
  36606. export class SixDofDragBehavior implements Behavior<Mesh> {
  36607. private static _virtualScene;
  36608. private _ownerNode;
  36609. private _sceneRenderObserver;
  36610. private _scene;
  36611. private _targetPosition;
  36612. private _virtualOriginMesh;
  36613. private _virtualDragMesh;
  36614. private _pointerObserver;
  36615. private _moving;
  36616. private _startingOrientation;
  36617. /**
  36618. * 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)
  36619. */
  36620. private zDragFactor;
  36621. /**
  36622. * If the object should rotate to face the drag origin
  36623. */
  36624. rotateDraggedObject: boolean;
  36625. /**
  36626. * If the behavior is currently in a dragging state
  36627. */
  36628. dragging: boolean;
  36629. /**
  36630. * 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)
  36631. */
  36632. dragDeltaRatio: number;
  36633. /**
  36634. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36635. */
  36636. currentDraggingPointerID: number;
  36637. /**
  36638. * If camera controls should be detached during the drag
  36639. */
  36640. detachCameraControls: boolean;
  36641. /**
  36642. * Fires each time a drag starts
  36643. */
  36644. onDragStartObservable: Observable<{}>;
  36645. /**
  36646. * Fires each time a drag ends (eg. mouse release after drag)
  36647. */
  36648. onDragEndObservable: Observable<{}>;
  36649. /**
  36650. * 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
  36651. */
  36652. constructor();
  36653. /**
  36654. * The name of the behavior
  36655. */
  36656. readonly name: string;
  36657. /**
  36658. * Initializes the behavior
  36659. */
  36660. init(): void;
  36661. /**
  36662. * Attaches the scale behavior the passed in mesh
  36663. * @param ownerNode The mesh that will be scaled around once attached
  36664. */
  36665. attach(ownerNode: Mesh): void;
  36666. /**
  36667. * Detaches the behavior from the mesh
  36668. */
  36669. detach(): void;
  36670. }
  36671. }
  36672. declare module "babylonjs/Behaviors/Meshes/index" {
  36673. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36674. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36675. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36676. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36677. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36678. }
  36679. declare module "babylonjs/Behaviors/index" {
  36680. export * from "babylonjs/Behaviors/behavior";
  36681. export * from "babylonjs/Behaviors/Cameras/index";
  36682. export * from "babylonjs/Behaviors/Meshes/index";
  36683. }
  36684. declare module "babylonjs/Bones/boneIKController" {
  36685. import { Bone } from "babylonjs/Bones/bone";
  36686. import { Vector3 } from "babylonjs/Maths/math";
  36687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36688. import { Nullable } from "babylonjs/types";
  36689. /**
  36690. * Class used to apply inverse kinematics to bones
  36691. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36692. */
  36693. export class BoneIKController {
  36694. private static _tmpVecs;
  36695. private static _tmpQuat;
  36696. private static _tmpMats;
  36697. /**
  36698. * Gets or sets the target mesh
  36699. */
  36700. targetMesh: AbstractMesh;
  36701. /** Gets or sets the mesh used as pole */
  36702. poleTargetMesh: AbstractMesh;
  36703. /**
  36704. * Gets or sets the bone used as pole
  36705. */
  36706. poleTargetBone: Nullable<Bone>;
  36707. /**
  36708. * Gets or sets the target position
  36709. */
  36710. targetPosition: Vector3;
  36711. /**
  36712. * Gets or sets the pole target position
  36713. */
  36714. poleTargetPosition: Vector3;
  36715. /**
  36716. * Gets or sets the pole target local offset
  36717. */
  36718. poleTargetLocalOffset: Vector3;
  36719. /**
  36720. * Gets or sets the pole angle
  36721. */
  36722. poleAngle: number;
  36723. /**
  36724. * Gets or sets the mesh associated with the controller
  36725. */
  36726. mesh: AbstractMesh;
  36727. /**
  36728. * 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)
  36729. */
  36730. slerpAmount: number;
  36731. private _bone1Quat;
  36732. private _bone1Mat;
  36733. private _bone2Ang;
  36734. private _bone1;
  36735. private _bone2;
  36736. private _bone1Length;
  36737. private _bone2Length;
  36738. private _maxAngle;
  36739. private _maxReach;
  36740. private _rightHandedSystem;
  36741. private _bendAxis;
  36742. private _slerping;
  36743. private _adjustRoll;
  36744. /**
  36745. * Gets or sets maximum allowed angle
  36746. */
  36747. maxAngle: number;
  36748. /**
  36749. * Creates a new BoneIKController
  36750. * @param mesh defines the mesh to control
  36751. * @param bone defines the bone to control
  36752. * @param options defines options to set up the controller
  36753. */
  36754. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36755. targetMesh?: AbstractMesh;
  36756. poleTargetMesh?: AbstractMesh;
  36757. poleTargetBone?: Bone;
  36758. poleTargetLocalOffset?: Vector3;
  36759. poleAngle?: number;
  36760. bendAxis?: Vector3;
  36761. maxAngle?: number;
  36762. slerpAmount?: number;
  36763. });
  36764. private _setMaxAngle;
  36765. /**
  36766. * Force the controller to update the bones
  36767. */
  36768. update(): void;
  36769. }
  36770. }
  36771. declare module "babylonjs/Bones/boneLookController" {
  36772. import { Vector3, Space } from "babylonjs/Maths/math";
  36773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36774. import { Bone } from "babylonjs/Bones/bone";
  36775. /**
  36776. * Class used to make a bone look toward a point in space
  36777. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36778. */
  36779. export class BoneLookController {
  36780. private static _tmpVecs;
  36781. private static _tmpQuat;
  36782. private static _tmpMats;
  36783. /**
  36784. * The target Vector3 that the bone will look at
  36785. */
  36786. target: Vector3;
  36787. /**
  36788. * The mesh that the bone is attached to
  36789. */
  36790. mesh: AbstractMesh;
  36791. /**
  36792. * The bone that will be looking to the target
  36793. */
  36794. bone: Bone;
  36795. /**
  36796. * The up axis of the coordinate system that is used when the bone is rotated
  36797. */
  36798. upAxis: Vector3;
  36799. /**
  36800. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36801. */
  36802. upAxisSpace: Space;
  36803. /**
  36804. * Used to make an adjustment to the yaw of the bone
  36805. */
  36806. adjustYaw: number;
  36807. /**
  36808. * Used to make an adjustment to the pitch of the bone
  36809. */
  36810. adjustPitch: number;
  36811. /**
  36812. * Used to make an adjustment to the roll of the bone
  36813. */
  36814. adjustRoll: number;
  36815. /**
  36816. * 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)
  36817. */
  36818. slerpAmount: number;
  36819. private _minYaw;
  36820. private _maxYaw;
  36821. private _minPitch;
  36822. private _maxPitch;
  36823. private _minYawSin;
  36824. private _minYawCos;
  36825. private _maxYawSin;
  36826. private _maxYawCos;
  36827. private _midYawConstraint;
  36828. private _minPitchTan;
  36829. private _maxPitchTan;
  36830. private _boneQuat;
  36831. private _slerping;
  36832. private _transformYawPitch;
  36833. private _transformYawPitchInv;
  36834. private _firstFrameSkipped;
  36835. private _yawRange;
  36836. private _fowardAxis;
  36837. /**
  36838. * Gets or sets the minimum yaw angle that the bone can look to
  36839. */
  36840. minYaw: number;
  36841. /**
  36842. * Gets or sets the maximum yaw angle that the bone can look to
  36843. */
  36844. maxYaw: number;
  36845. /**
  36846. * Gets or sets the minimum pitch angle that the bone can look to
  36847. */
  36848. minPitch: number;
  36849. /**
  36850. * Gets or sets the maximum pitch angle that the bone can look to
  36851. */
  36852. maxPitch: number;
  36853. /**
  36854. * Create a BoneLookController
  36855. * @param mesh the mesh that the bone belongs to
  36856. * @param bone the bone that will be looking to the target
  36857. * @param target the target Vector3 to look at
  36858. * @param options optional settings:
  36859. * * maxYaw: the maximum angle the bone will yaw to
  36860. * * minYaw: the minimum angle the bone will yaw to
  36861. * * maxPitch: the maximum angle the bone will pitch to
  36862. * * minPitch: the minimum angle the bone will yaw to
  36863. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36864. * * upAxis: the up axis of the coordinate system
  36865. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36866. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36867. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36868. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36869. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36870. * * adjustRoll: used to make an adjustment to the roll of the bone
  36871. **/
  36872. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36873. maxYaw?: number;
  36874. minYaw?: number;
  36875. maxPitch?: number;
  36876. minPitch?: number;
  36877. slerpAmount?: number;
  36878. upAxis?: Vector3;
  36879. upAxisSpace?: Space;
  36880. yawAxis?: Vector3;
  36881. pitchAxis?: Vector3;
  36882. adjustYaw?: number;
  36883. adjustPitch?: number;
  36884. adjustRoll?: number;
  36885. });
  36886. /**
  36887. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36888. */
  36889. update(): void;
  36890. private _getAngleDiff;
  36891. private _getAngleBetween;
  36892. private _isAngleBetween;
  36893. }
  36894. }
  36895. declare module "babylonjs/Bones/index" {
  36896. export * from "babylonjs/Bones/bone";
  36897. export * from "babylonjs/Bones/boneIKController";
  36898. export * from "babylonjs/Bones/boneLookController";
  36899. export * from "babylonjs/Bones/skeleton";
  36900. }
  36901. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36902. import { Nullable } from "babylonjs/types";
  36903. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36904. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36905. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36906. /**
  36907. * Manage the gamepad inputs to control an arc rotate camera.
  36908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36909. */
  36910. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36911. /**
  36912. * Defines the camera the input is attached to.
  36913. */
  36914. camera: ArcRotateCamera;
  36915. /**
  36916. * Defines the gamepad the input is gathering event from.
  36917. */
  36918. gamepad: Nullable<Gamepad>;
  36919. /**
  36920. * Defines the gamepad rotation sensiblity.
  36921. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36922. */
  36923. gamepadRotationSensibility: number;
  36924. /**
  36925. * Defines the gamepad move sensiblity.
  36926. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36927. */
  36928. gamepadMoveSensibility: number;
  36929. private _onGamepadConnectedObserver;
  36930. private _onGamepadDisconnectedObserver;
  36931. /**
  36932. * Attach the input controls to a specific dom element to get the input from.
  36933. * @param element Defines the element the controls should be listened from
  36934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36935. */
  36936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36937. /**
  36938. * Detach the current controls from the specified dom element.
  36939. * @param element Defines the element to stop listening the inputs from
  36940. */
  36941. detachControl(element: Nullable<HTMLElement>): void;
  36942. /**
  36943. * Update the current camera state depending on the inputs that have been used this frame.
  36944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36945. */
  36946. checkInputs(): void;
  36947. /**
  36948. * Gets the class name of the current intput.
  36949. * @returns the class name
  36950. */
  36951. getClassName(): string;
  36952. /**
  36953. * Get the friendly name associated with the input class.
  36954. * @returns the input friendly name
  36955. */
  36956. getSimpleName(): string;
  36957. }
  36958. }
  36959. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36960. import { Nullable } from "babylonjs/types";
  36961. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36963. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36964. interface ArcRotateCameraInputsManager {
  36965. /**
  36966. * Add orientation input support to the input manager.
  36967. * @returns the current input manager
  36968. */
  36969. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36970. }
  36971. }
  36972. /**
  36973. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36975. */
  36976. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36977. /**
  36978. * Defines the camera the input is attached to.
  36979. */
  36980. camera: ArcRotateCamera;
  36981. /**
  36982. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36983. */
  36984. alphaCorrection: number;
  36985. /**
  36986. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36987. */
  36988. gammaCorrection: number;
  36989. private _alpha;
  36990. private _gamma;
  36991. private _dirty;
  36992. private _deviceOrientationHandler;
  36993. /**
  36994. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36995. */
  36996. constructor();
  36997. /**
  36998. * Attach the input controls to a specific dom element to get the input from.
  36999. * @param element Defines the element the controls should be listened from
  37000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37001. */
  37002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37003. /** @hidden */
  37004. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37005. /**
  37006. * Update the current camera state depending on the inputs that have been used this frame.
  37007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37008. */
  37009. checkInputs(): void;
  37010. /**
  37011. * Detach the current controls from the specified dom element.
  37012. * @param element Defines the element to stop listening the inputs from
  37013. */
  37014. detachControl(element: Nullable<HTMLElement>): void;
  37015. /**
  37016. * Gets the class name of the current intput.
  37017. * @returns the class name
  37018. */
  37019. getClassName(): string;
  37020. /**
  37021. * Get the friendly name associated with the input class.
  37022. * @returns the input friendly name
  37023. */
  37024. getSimpleName(): string;
  37025. }
  37026. }
  37027. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37028. import { Nullable } from "babylonjs/types";
  37029. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37030. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37031. /**
  37032. * Listen to mouse events to control the camera.
  37033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37034. */
  37035. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37036. /**
  37037. * Defines the camera the input is attached to.
  37038. */
  37039. camera: FlyCamera;
  37040. /**
  37041. * Defines if touch is enabled. (Default is true.)
  37042. */
  37043. touchEnabled: boolean;
  37044. /**
  37045. * Defines the buttons associated with the input to handle camera rotation.
  37046. */
  37047. buttons: number[];
  37048. /**
  37049. * Assign buttons for Yaw control.
  37050. */
  37051. buttonsYaw: number[];
  37052. /**
  37053. * Assign buttons for Pitch control.
  37054. */
  37055. buttonsPitch: number[];
  37056. /**
  37057. * Assign buttons for Roll control.
  37058. */
  37059. buttonsRoll: number[];
  37060. /**
  37061. * Detect if any button is being pressed while mouse is moved.
  37062. * -1 = Mouse locked.
  37063. * 0 = Left button.
  37064. * 1 = Middle Button.
  37065. * 2 = Right Button.
  37066. */
  37067. activeButton: number;
  37068. /**
  37069. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37070. * Higher values reduce its sensitivity.
  37071. */
  37072. angularSensibility: number;
  37073. private _mousemoveCallback;
  37074. private _observer;
  37075. private _rollObserver;
  37076. private previousPosition;
  37077. private noPreventDefault;
  37078. private element;
  37079. /**
  37080. * Listen to mouse events to control the camera.
  37081. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37083. */
  37084. constructor(touchEnabled?: boolean);
  37085. /**
  37086. * Attach the mouse control to the HTML DOM element.
  37087. * @param element Defines the element that listens to the input events.
  37088. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37089. */
  37090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37091. /**
  37092. * Detach the current controls from the specified dom element.
  37093. * @param element Defines the element to stop listening the inputs from
  37094. */
  37095. detachControl(element: Nullable<HTMLElement>): void;
  37096. /**
  37097. * Gets the class name of the current input.
  37098. * @returns the class name.
  37099. */
  37100. getClassName(): string;
  37101. /**
  37102. * Get the friendly name associated with the input class.
  37103. * @returns the input's friendly name.
  37104. */
  37105. getSimpleName(): string;
  37106. private _pointerInput;
  37107. private _onMouseMove;
  37108. /**
  37109. * Rotate camera by mouse offset.
  37110. */
  37111. private rotateCamera;
  37112. }
  37113. }
  37114. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37115. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37116. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37117. /**
  37118. * Default Inputs manager for the FlyCamera.
  37119. * It groups all the default supported inputs for ease of use.
  37120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37121. */
  37122. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37123. /**
  37124. * Instantiates a new FlyCameraInputsManager.
  37125. * @param camera Defines the camera the inputs belong to.
  37126. */
  37127. constructor(camera: FlyCamera);
  37128. /**
  37129. * Add keyboard input support to the input manager.
  37130. * @returns the new FlyCameraKeyboardMoveInput().
  37131. */
  37132. addKeyboard(): FlyCameraInputsManager;
  37133. /**
  37134. * Add mouse input support to the input manager.
  37135. * @param touchEnabled Enable touch screen support.
  37136. * @returns the new FlyCameraMouseInput().
  37137. */
  37138. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37139. }
  37140. }
  37141. declare module "babylonjs/Cameras/flyCamera" {
  37142. import { Scene } from "babylonjs/scene";
  37143. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37145. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37146. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37147. /**
  37148. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37149. * such as in a 3D Space Shooter or a Flight Simulator.
  37150. */
  37151. export class FlyCamera extends TargetCamera {
  37152. /**
  37153. * Define the collision ellipsoid of the camera.
  37154. * This is helpful for simulating a camera body, like a player's body.
  37155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37156. */
  37157. ellipsoid: Vector3;
  37158. /**
  37159. * Define an offset for the position of the ellipsoid around the camera.
  37160. * This can be helpful if the camera is attached away from the player's body center,
  37161. * such as at its head.
  37162. */
  37163. ellipsoidOffset: Vector3;
  37164. /**
  37165. * Enable or disable collisions of the camera with the rest of the scene objects.
  37166. */
  37167. checkCollisions: boolean;
  37168. /**
  37169. * Enable or disable gravity on the camera.
  37170. */
  37171. applyGravity: boolean;
  37172. /**
  37173. * Define the current direction the camera is moving to.
  37174. */
  37175. cameraDirection: Vector3;
  37176. /**
  37177. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37178. * This overrides and empties cameraRotation.
  37179. */
  37180. rotationQuaternion: Quaternion;
  37181. /**
  37182. * Track Roll to maintain the wanted Rolling when looking around.
  37183. */
  37184. _trackRoll: number;
  37185. /**
  37186. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37187. */
  37188. rollCorrect: number;
  37189. /**
  37190. * Mimic a banked turn, Rolling the camera when Yawing.
  37191. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37192. */
  37193. bankedTurn: boolean;
  37194. /**
  37195. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37196. */
  37197. bankedTurnLimit: number;
  37198. /**
  37199. * Value of 0 disables the banked Roll.
  37200. * Value of 1 is equal to the Yaw angle in radians.
  37201. */
  37202. bankedTurnMultiplier: number;
  37203. /**
  37204. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37205. */
  37206. inputs: FlyCameraInputsManager;
  37207. /**
  37208. * Gets the input sensibility for mouse input.
  37209. * Higher values reduce sensitivity.
  37210. */
  37211. /**
  37212. * Sets the input sensibility for a mouse input.
  37213. * Higher values reduce sensitivity.
  37214. */
  37215. angularSensibility: number;
  37216. /**
  37217. * Get the keys for camera movement forward.
  37218. */
  37219. /**
  37220. * Set the keys for camera movement forward.
  37221. */
  37222. keysForward: number[];
  37223. /**
  37224. * Get the keys for camera movement backward.
  37225. */
  37226. keysBackward: number[];
  37227. /**
  37228. * Get the keys for camera movement up.
  37229. */
  37230. /**
  37231. * Set the keys for camera movement up.
  37232. */
  37233. keysUp: number[];
  37234. /**
  37235. * Get the keys for camera movement down.
  37236. */
  37237. /**
  37238. * Set the keys for camera movement down.
  37239. */
  37240. keysDown: number[];
  37241. /**
  37242. * Get the keys for camera movement left.
  37243. */
  37244. /**
  37245. * Set the keys for camera movement left.
  37246. */
  37247. keysLeft: number[];
  37248. /**
  37249. * Set the keys for camera movement right.
  37250. */
  37251. /**
  37252. * Set the keys for camera movement right.
  37253. */
  37254. keysRight: number[];
  37255. /**
  37256. * Event raised when the camera collides with a mesh in the scene.
  37257. */
  37258. onCollide: (collidedMesh: AbstractMesh) => void;
  37259. private _collider;
  37260. private _needMoveForGravity;
  37261. private _oldPosition;
  37262. private _diffPosition;
  37263. private _newPosition;
  37264. /** @hidden */
  37265. _localDirection: Vector3;
  37266. /** @hidden */
  37267. _transformedDirection: Vector3;
  37268. /**
  37269. * Instantiates a FlyCamera.
  37270. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37271. * such as in a 3D Space Shooter or a Flight Simulator.
  37272. * @param name Define the name of the camera in the scene.
  37273. * @param position Define the starting position of the camera in the scene.
  37274. * @param scene Define the scene the camera belongs to.
  37275. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37276. */
  37277. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37278. /**
  37279. * Attach a control to the HTML DOM element.
  37280. * @param element Defines the element that listens to the input events.
  37281. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37282. */
  37283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37284. /**
  37285. * Detach a control from the HTML DOM element.
  37286. * The camera will stop reacting to that input.
  37287. * @param element Defines the element that listens to the input events.
  37288. */
  37289. detachControl(element: HTMLElement): void;
  37290. private _collisionMask;
  37291. /**
  37292. * Get the mask that the camera ignores in collision events.
  37293. */
  37294. /**
  37295. * Set the mask that the camera ignores in collision events.
  37296. */
  37297. collisionMask: number;
  37298. /** @hidden */
  37299. _collideWithWorld(displacement: Vector3): void;
  37300. /** @hidden */
  37301. private _onCollisionPositionChange;
  37302. /** @hidden */
  37303. _checkInputs(): void;
  37304. /** @hidden */
  37305. _decideIfNeedsToMove(): boolean;
  37306. /** @hidden */
  37307. _updatePosition(): void;
  37308. /**
  37309. * Restore the Roll to its target value at the rate specified.
  37310. * @param rate - Higher means slower restoring.
  37311. * @hidden
  37312. */
  37313. restoreRoll(rate: number): void;
  37314. /**
  37315. * Destroy the camera and release the current resources held by it.
  37316. */
  37317. dispose(): void;
  37318. /**
  37319. * Get the current object class name.
  37320. * @returns the class name.
  37321. */
  37322. getClassName(): string;
  37323. }
  37324. }
  37325. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37326. import { Nullable } from "babylonjs/types";
  37327. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37328. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37329. /**
  37330. * Listen to keyboard events to control the camera.
  37331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37332. */
  37333. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37334. /**
  37335. * Defines the camera the input is attached to.
  37336. */
  37337. camera: FlyCamera;
  37338. /**
  37339. * The list of keyboard keys used to control the forward move of the camera.
  37340. */
  37341. keysForward: number[];
  37342. /**
  37343. * The list of keyboard keys used to control the backward move of the camera.
  37344. */
  37345. keysBackward: number[];
  37346. /**
  37347. * The list of keyboard keys used to control the forward move of the camera.
  37348. */
  37349. keysUp: number[];
  37350. /**
  37351. * The list of keyboard keys used to control the backward move of the camera.
  37352. */
  37353. keysDown: number[];
  37354. /**
  37355. * The list of keyboard keys used to control the right strafe move of the camera.
  37356. */
  37357. keysRight: number[];
  37358. /**
  37359. * The list of keyboard keys used to control the left strafe move of the camera.
  37360. */
  37361. keysLeft: number[];
  37362. private _keys;
  37363. private _onCanvasBlurObserver;
  37364. private _onKeyboardObserver;
  37365. private _engine;
  37366. private _scene;
  37367. /**
  37368. * Attach the input controls to a specific dom element to get the input from.
  37369. * @param element Defines the element the controls should be listened from
  37370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37371. */
  37372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37373. /**
  37374. * Detach the current controls from the specified dom element.
  37375. * @param element Defines the element to stop listening the inputs from
  37376. */
  37377. detachControl(element: Nullable<HTMLElement>): void;
  37378. /**
  37379. * Gets the class name of the current intput.
  37380. * @returns the class name
  37381. */
  37382. getClassName(): string;
  37383. /** @hidden */
  37384. _onLostFocus(e: FocusEvent): void;
  37385. /**
  37386. * Get the friendly name associated with the input class.
  37387. * @returns the input friendly name
  37388. */
  37389. getSimpleName(): string;
  37390. /**
  37391. * Update the current camera state depending on the inputs that have been used this frame.
  37392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37393. */
  37394. checkInputs(): void;
  37395. }
  37396. }
  37397. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37398. import { Nullable } from "babylonjs/types";
  37399. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37400. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37401. /**
  37402. * Manage the mouse wheel inputs to control a follow camera.
  37403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37404. */
  37405. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37406. /**
  37407. * Defines the camera the input is attached to.
  37408. */
  37409. camera: FollowCamera;
  37410. /**
  37411. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37412. */
  37413. axisControlRadius: boolean;
  37414. /**
  37415. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37416. */
  37417. axisControlHeight: boolean;
  37418. /**
  37419. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37420. */
  37421. axisControlRotation: boolean;
  37422. /**
  37423. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37424. * relation to mouseWheel events.
  37425. */
  37426. wheelPrecision: number;
  37427. /**
  37428. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37429. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37430. */
  37431. wheelDeltaPercentage: number;
  37432. private _wheel;
  37433. private _observer;
  37434. /**
  37435. * Attach the input controls to a specific dom element to get the input from.
  37436. * @param element Defines the element the controls should be listened from
  37437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37438. */
  37439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37440. /**
  37441. * Detach the current controls from the specified dom element.
  37442. * @param element Defines the element to stop listening the inputs from
  37443. */
  37444. detachControl(element: Nullable<HTMLElement>): void;
  37445. /**
  37446. * Gets the class name of the current intput.
  37447. * @returns the class name
  37448. */
  37449. getClassName(): string;
  37450. /**
  37451. * Get the friendly name associated with the input class.
  37452. * @returns the input friendly name
  37453. */
  37454. getSimpleName(): string;
  37455. }
  37456. }
  37457. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37458. import { Nullable } from "babylonjs/types";
  37459. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37460. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37461. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37462. /**
  37463. * Manage the pointers inputs to control an follow camera.
  37464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37465. */
  37466. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37467. /**
  37468. * Defines the camera the input is attached to.
  37469. */
  37470. camera: FollowCamera;
  37471. /**
  37472. * Gets the class name of the current input.
  37473. * @returns the class name
  37474. */
  37475. getClassName(): string;
  37476. /**
  37477. * Defines the pointer angular sensibility along the X axis or how fast is
  37478. * the camera rotating.
  37479. * A negative number will reverse the axis direction.
  37480. */
  37481. angularSensibilityX: number;
  37482. /**
  37483. * Defines the pointer angular sensibility along the Y axis or how fast is
  37484. * the camera rotating.
  37485. * A negative number will reverse the axis direction.
  37486. */
  37487. angularSensibilityY: number;
  37488. /**
  37489. * Defines the pointer pinch precision or how fast is the camera zooming.
  37490. * A negative number will reverse the axis direction.
  37491. */
  37492. pinchPrecision: number;
  37493. /**
  37494. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37495. * from 0.
  37496. * It defines the percentage of current camera.radius to use as delta when
  37497. * pinch zoom is used.
  37498. */
  37499. pinchDeltaPercentage: number;
  37500. /**
  37501. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37502. */
  37503. axisXControlRadius: boolean;
  37504. /**
  37505. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37506. */
  37507. axisXControlHeight: boolean;
  37508. /**
  37509. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37510. */
  37511. axisXControlRotation: boolean;
  37512. /**
  37513. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37514. */
  37515. axisYControlRadius: boolean;
  37516. /**
  37517. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37518. */
  37519. axisYControlHeight: boolean;
  37520. /**
  37521. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37522. */
  37523. axisYControlRotation: boolean;
  37524. /**
  37525. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37526. */
  37527. axisPinchControlRadius: boolean;
  37528. /**
  37529. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37530. */
  37531. axisPinchControlHeight: boolean;
  37532. /**
  37533. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37534. */
  37535. axisPinchControlRotation: boolean;
  37536. /**
  37537. * Log error messages if basic misconfiguration has occurred.
  37538. */
  37539. warningEnable: boolean;
  37540. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37541. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37542. private _warningCounter;
  37543. private _warning;
  37544. }
  37545. }
  37546. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37547. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37548. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37549. /**
  37550. * Default Inputs manager for the FollowCamera.
  37551. * It groups all the default supported inputs for ease of use.
  37552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37553. */
  37554. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37555. /**
  37556. * Instantiates a new FollowCameraInputsManager.
  37557. * @param camera Defines the camera the inputs belong to
  37558. */
  37559. constructor(camera: FollowCamera);
  37560. /**
  37561. * Add keyboard input support to the input manager.
  37562. * @returns the current input manager
  37563. */
  37564. addKeyboard(): FollowCameraInputsManager;
  37565. /**
  37566. * Add mouse wheel input support to the input manager.
  37567. * @returns the current input manager
  37568. */
  37569. addMouseWheel(): FollowCameraInputsManager;
  37570. /**
  37571. * Add pointers input support to the input manager.
  37572. * @returns the current input manager
  37573. */
  37574. addPointers(): FollowCameraInputsManager;
  37575. /**
  37576. * Add orientation input support to the input manager.
  37577. * @returns the current input manager
  37578. */
  37579. addVRDeviceOrientation(): FollowCameraInputsManager;
  37580. }
  37581. }
  37582. declare module "babylonjs/Cameras/followCamera" {
  37583. import { Nullable } from "babylonjs/types";
  37584. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37585. import { Scene } from "babylonjs/scene";
  37586. import { Vector3 } from "babylonjs/Maths/math";
  37587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37588. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37589. /**
  37590. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37591. * an arc rotate version arcFollowCamera are available.
  37592. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37593. */
  37594. export class FollowCamera extends TargetCamera {
  37595. /**
  37596. * Distance the follow camera should follow an object at
  37597. */
  37598. radius: number;
  37599. /**
  37600. * Minimum allowed distance of the camera to the axis of rotation
  37601. * (The camera can not get closer).
  37602. * This can help limiting how the Camera is able to move in the scene.
  37603. */
  37604. lowerRadiusLimit: Nullable<number>;
  37605. /**
  37606. * Maximum allowed distance of the camera to the axis of rotation
  37607. * (The camera can not get further).
  37608. * This can help limiting how the Camera is able to move in the scene.
  37609. */
  37610. upperRadiusLimit: Nullable<number>;
  37611. /**
  37612. * Define a rotation offset between the camera and the object it follows
  37613. */
  37614. rotationOffset: number;
  37615. /**
  37616. * Minimum allowed angle to camera position relative to target object.
  37617. * This can help limiting how the Camera is able to move in the scene.
  37618. */
  37619. lowerRotationOffsetLimit: Nullable<number>;
  37620. /**
  37621. * Maximum allowed angle to camera position relative to target object.
  37622. * This can help limiting how the Camera is able to move in the scene.
  37623. */
  37624. upperRotationOffsetLimit: Nullable<number>;
  37625. /**
  37626. * Define a height offset between the camera and the object it follows.
  37627. * It can help following an object from the top (like a car chaing a plane)
  37628. */
  37629. heightOffset: number;
  37630. /**
  37631. * Minimum allowed height of camera position relative to target object.
  37632. * This can help limiting how the Camera is able to move in the scene.
  37633. */
  37634. lowerHeightOffsetLimit: Nullable<number>;
  37635. /**
  37636. * Maximum allowed height of camera position relative to target object.
  37637. * This can help limiting how the Camera is able to move in the scene.
  37638. */
  37639. upperHeightOffsetLimit: Nullable<number>;
  37640. /**
  37641. * Define how fast the camera can accelerate to follow it s target.
  37642. */
  37643. cameraAcceleration: number;
  37644. /**
  37645. * Define the speed limit of the camera following an object.
  37646. */
  37647. maxCameraSpeed: number;
  37648. /**
  37649. * Define the target of the camera.
  37650. */
  37651. lockedTarget: Nullable<AbstractMesh>;
  37652. /**
  37653. * Defines the input associated with the camera.
  37654. */
  37655. inputs: FollowCameraInputsManager;
  37656. /**
  37657. * Instantiates the follow camera.
  37658. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37659. * @param name Define the name of the camera in the scene
  37660. * @param position Define the position of the camera
  37661. * @param scene Define the scene the camera belong to
  37662. * @param lockedTarget Define the target of the camera
  37663. */
  37664. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37665. private _follow;
  37666. /**
  37667. * Attached controls to the current camera.
  37668. * @param element Defines the element the controls should be listened from
  37669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37670. */
  37671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37672. /**
  37673. * Detach the current controls from the camera.
  37674. * The camera will stop reacting to inputs.
  37675. * @param element Defines the element to stop listening the inputs from
  37676. */
  37677. detachControl(element: HTMLElement): void;
  37678. /** @hidden */
  37679. _checkInputs(): void;
  37680. private _checkLimits;
  37681. /**
  37682. * Gets the camera class name.
  37683. * @returns the class name
  37684. */
  37685. getClassName(): string;
  37686. }
  37687. /**
  37688. * Arc Rotate version of the follow camera.
  37689. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37690. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37691. */
  37692. export class ArcFollowCamera extends TargetCamera {
  37693. /** The longitudinal angle of the camera */
  37694. alpha: number;
  37695. /** The latitudinal angle of the camera */
  37696. beta: number;
  37697. /** The radius of the camera from its target */
  37698. radius: number;
  37699. /** Define the camera target (the messh it should follow) */
  37700. target: Nullable<AbstractMesh>;
  37701. private _cartesianCoordinates;
  37702. /**
  37703. * Instantiates a new ArcFollowCamera
  37704. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37705. * @param name Define the name of the camera
  37706. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37707. * @param beta Define the rotation angle of the camera around the elevation axis
  37708. * @param radius Define the radius of the camera from its target point
  37709. * @param target Define the target of the camera
  37710. * @param scene Define the scene the camera belongs to
  37711. */
  37712. constructor(name: string,
  37713. /** The longitudinal angle of the camera */
  37714. alpha: number,
  37715. /** The latitudinal angle of the camera */
  37716. beta: number,
  37717. /** The radius of the camera from its target */
  37718. radius: number,
  37719. /** Define the camera target (the messh it should follow) */
  37720. target: Nullable<AbstractMesh>, scene: Scene);
  37721. private _follow;
  37722. /** @hidden */
  37723. _checkInputs(): void;
  37724. /**
  37725. * Returns the class name of the object.
  37726. * It is mostly used internally for serialization purposes.
  37727. */
  37728. getClassName(): string;
  37729. }
  37730. }
  37731. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37732. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37733. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37734. import { Nullable } from "babylonjs/types";
  37735. /**
  37736. * Manage the keyboard inputs to control the movement of a follow camera.
  37737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37738. */
  37739. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37740. /**
  37741. * Defines the camera the input is attached to.
  37742. */
  37743. camera: FollowCamera;
  37744. /**
  37745. * Defines the list of key codes associated with the up action (increase heightOffset)
  37746. */
  37747. keysHeightOffsetIncr: number[];
  37748. /**
  37749. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37750. */
  37751. keysHeightOffsetDecr: number[];
  37752. /**
  37753. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37754. */
  37755. keysHeightOffsetModifierAlt: boolean;
  37756. /**
  37757. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37758. */
  37759. keysHeightOffsetModifierCtrl: boolean;
  37760. /**
  37761. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37762. */
  37763. keysHeightOffsetModifierShift: boolean;
  37764. /**
  37765. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37766. */
  37767. keysRotationOffsetIncr: number[];
  37768. /**
  37769. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37770. */
  37771. keysRotationOffsetDecr: number[];
  37772. /**
  37773. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37774. */
  37775. keysRotationOffsetModifierAlt: boolean;
  37776. /**
  37777. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37778. */
  37779. keysRotationOffsetModifierCtrl: boolean;
  37780. /**
  37781. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37782. */
  37783. keysRotationOffsetModifierShift: boolean;
  37784. /**
  37785. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37786. */
  37787. keysRadiusIncr: number[];
  37788. /**
  37789. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37790. */
  37791. keysRadiusDecr: number[];
  37792. /**
  37793. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37794. */
  37795. keysRadiusModifierAlt: boolean;
  37796. /**
  37797. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37798. */
  37799. keysRadiusModifierCtrl: boolean;
  37800. /**
  37801. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37802. */
  37803. keysRadiusModifierShift: boolean;
  37804. /**
  37805. * Defines the rate of change of heightOffset.
  37806. */
  37807. heightSensibility: number;
  37808. /**
  37809. * Defines the rate of change of rotationOffset.
  37810. */
  37811. rotationSensibility: number;
  37812. /**
  37813. * Defines the rate of change of radius.
  37814. */
  37815. radiusSensibility: number;
  37816. private _keys;
  37817. private _ctrlPressed;
  37818. private _altPressed;
  37819. private _shiftPressed;
  37820. private _onCanvasBlurObserver;
  37821. private _onKeyboardObserver;
  37822. private _engine;
  37823. private _scene;
  37824. /**
  37825. * Attach the input controls to a specific dom element to get the input from.
  37826. * @param element Defines the element the controls should be listened from
  37827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37828. */
  37829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37830. /**
  37831. * Detach the current controls from the specified dom element.
  37832. * @param element Defines the element to stop listening the inputs from
  37833. */
  37834. detachControl(element: Nullable<HTMLElement>): void;
  37835. /**
  37836. * Update the current camera state depending on the inputs that have been used this frame.
  37837. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37838. */
  37839. checkInputs(): void;
  37840. /**
  37841. * Gets the class name of the current input.
  37842. * @returns the class name
  37843. */
  37844. getClassName(): string;
  37845. /**
  37846. * Get the friendly name associated with the input class.
  37847. * @returns the input friendly name
  37848. */
  37849. getSimpleName(): string;
  37850. /**
  37851. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37852. * allow modification of the heightOffset value.
  37853. */
  37854. private _modifierHeightOffset;
  37855. /**
  37856. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37857. * allow modification of the rotationOffset value.
  37858. */
  37859. private _modifierRotationOffset;
  37860. /**
  37861. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37862. * allow modification of the radius value.
  37863. */
  37864. private _modifierRadius;
  37865. }
  37866. }
  37867. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37868. import { Nullable } from "babylonjs/types";
  37869. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37870. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37871. module "babylonjs/Cameras/freeCameraInputsManager" {
  37872. interface FreeCameraInputsManager {
  37873. /**
  37874. * Add orientation input support to the input manager.
  37875. * @returns the current input manager
  37876. */
  37877. addDeviceOrientation(): FreeCameraInputsManager;
  37878. }
  37879. }
  37880. /**
  37881. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37882. * Screen rotation is taken into account.
  37883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37884. */
  37885. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37886. private _camera;
  37887. private _screenOrientationAngle;
  37888. private _constantTranform;
  37889. private _screenQuaternion;
  37890. private _alpha;
  37891. private _beta;
  37892. private _gamma;
  37893. /**
  37894. * Instantiates a new input
  37895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37896. */
  37897. constructor();
  37898. /**
  37899. * Define the camera controlled by the input.
  37900. */
  37901. camera: FreeCamera;
  37902. /**
  37903. * Attach the input controls to a specific dom element to get the input from.
  37904. * @param element Defines the element the controls should be listened from
  37905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37906. */
  37907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37908. private _orientationChanged;
  37909. private _deviceOrientation;
  37910. /**
  37911. * Detach the current controls from the specified dom element.
  37912. * @param element Defines the element to stop listening the inputs from
  37913. */
  37914. detachControl(element: Nullable<HTMLElement>): void;
  37915. /**
  37916. * Update the current camera state depending on the inputs that have been used this frame.
  37917. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37918. */
  37919. checkInputs(): void;
  37920. /**
  37921. * Gets the class name of the current intput.
  37922. * @returns the class name
  37923. */
  37924. getClassName(): string;
  37925. /**
  37926. * Get the friendly name associated with the input class.
  37927. * @returns the input friendly name
  37928. */
  37929. getSimpleName(): string;
  37930. }
  37931. }
  37932. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37933. import { Nullable } from "babylonjs/types";
  37934. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37935. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37936. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37937. /**
  37938. * Manage the gamepad inputs to control a free camera.
  37939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37940. */
  37941. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37942. /**
  37943. * Define the camera the input is attached to.
  37944. */
  37945. camera: FreeCamera;
  37946. /**
  37947. * Define the Gamepad controlling the input
  37948. */
  37949. gamepad: Nullable<Gamepad>;
  37950. /**
  37951. * Defines the gamepad rotation sensiblity.
  37952. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37953. */
  37954. gamepadAngularSensibility: number;
  37955. /**
  37956. * Defines the gamepad move sensiblity.
  37957. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37958. */
  37959. gamepadMoveSensibility: number;
  37960. private _onGamepadConnectedObserver;
  37961. private _onGamepadDisconnectedObserver;
  37962. private _cameraTransform;
  37963. private _deltaTransform;
  37964. private _vector3;
  37965. private _vector2;
  37966. /**
  37967. * Attach the input controls to a specific dom element to get the input from.
  37968. * @param element Defines the element the controls should be listened from
  37969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37970. */
  37971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37972. /**
  37973. * Detach the current controls from the specified dom element.
  37974. * @param element Defines the element to stop listening the inputs from
  37975. */
  37976. detachControl(element: Nullable<HTMLElement>): void;
  37977. /**
  37978. * Update the current camera state depending on the inputs that have been used this frame.
  37979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37980. */
  37981. checkInputs(): void;
  37982. /**
  37983. * Gets the class name of the current intput.
  37984. * @returns the class name
  37985. */
  37986. getClassName(): string;
  37987. /**
  37988. * Get the friendly name associated with the input class.
  37989. * @returns the input friendly name
  37990. */
  37991. getSimpleName(): string;
  37992. }
  37993. }
  37994. declare module "babylonjs/Misc/virtualJoystick" {
  37995. import { Nullable } from "babylonjs/types";
  37996. import { Vector3 } from "babylonjs/Maths/math";
  37997. /**
  37998. * Defines the potential axis of a Joystick
  37999. */
  38000. export enum JoystickAxis {
  38001. /** X axis */
  38002. X = 0,
  38003. /** Y axis */
  38004. Y = 1,
  38005. /** Z axis */
  38006. Z = 2
  38007. }
  38008. /**
  38009. * Class used to define virtual joystick (used in touch mode)
  38010. */
  38011. export class VirtualJoystick {
  38012. /**
  38013. * Gets or sets a boolean indicating that left and right values must be inverted
  38014. */
  38015. reverseLeftRight: boolean;
  38016. /**
  38017. * Gets or sets a boolean indicating that up and down values must be inverted
  38018. */
  38019. reverseUpDown: boolean;
  38020. /**
  38021. * Gets the offset value for the position (ie. the change of the position value)
  38022. */
  38023. deltaPosition: Vector3;
  38024. /**
  38025. * Gets a boolean indicating if the virtual joystick was pressed
  38026. */
  38027. pressed: boolean;
  38028. /**
  38029. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38030. */
  38031. static Canvas: Nullable<HTMLCanvasElement>;
  38032. private static _globalJoystickIndex;
  38033. private static vjCanvasContext;
  38034. private static vjCanvasWidth;
  38035. private static vjCanvasHeight;
  38036. private static halfWidth;
  38037. private _action;
  38038. private _axisTargetedByLeftAndRight;
  38039. private _axisTargetedByUpAndDown;
  38040. private _joystickSensibility;
  38041. private _inversedSensibility;
  38042. private _joystickPointerID;
  38043. private _joystickColor;
  38044. private _joystickPointerPos;
  38045. private _joystickPreviousPointerPos;
  38046. private _joystickPointerStartPos;
  38047. private _deltaJoystickVector;
  38048. private _leftJoystick;
  38049. private _touches;
  38050. private _onPointerDownHandlerRef;
  38051. private _onPointerMoveHandlerRef;
  38052. private _onPointerUpHandlerRef;
  38053. private _onResize;
  38054. /**
  38055. * Creates a new virtual joystick
  38056. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38057. */
  38058. constructor(leftJoystick?: boolean);
  38059. /**
  38060. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38061. * @param newJoystickSensibility defines the new sensibility
  38062. */
  38063. setJoystickSensibility(newJoystickSensibility: number): void;
  38064. private _onPointerDown;
  38065. private _onPointerMove;
  38066. private _onPointerUp;
  38067. /**
  38068. * Change the color of the virtual joystick
  38069. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38070. */
  38071. setJoystickColor(newColor: string): void;
  38072. /**
  38073. * Defines a callback to call when the joystick is touched
  38074. * @param action defines the callback
  38075. */
  38076. setActionOnTouch(action: () => any): void;
  38077. /**
  38078. * Defines which axis you'd like to control for left & right
  38079. * @param axis defines the axis to use
  38080. */
  38081. setAxisForLeftRight(axis: JoystickAxis): void;
  38082. /**
  38083. * Defines which axis you'd like to control for up & down
  38084. * @param axis defines the axis to use
  38085. */
  38086. setAxisForUpDown(axis: JoystickAxis): void;
  38087. private _drawVirtualJoystick;
  38088. /**
  38089. * Release internal HTML canvas
  38090. */
  38091. releaseCanvas(): void;
  38092. }
  38093. }
  38094. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38095. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38096. import { Nullable } from "babylonjs/types";
  38097. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38098. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38099. module "babylonjs/Cameras/freeCameraInputsManager" {
  38100. interface FreeCameraInputsManager {
  38101. /**
  38102. * Add virtual joystick input support to the input manager.
  38103. * @returns the current input manager
  38104. */
  38105. addVirtualJoystick(): FreeCameraInputsManager;
  38106. }
  38107. }
  38108. /**
  38109. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38111. */
  38112. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38113. /**
  38114. * Defines the camera the input is attached to.
  38115. */
  38116. camera: FreeCamera;
  38117. private _leftjoystick;
  38118. private _rightjoystick;
  38119. /**
  38120. * Gets the left stick of the virtual joystick.
  38121. * @returns The virtual Joystick
  38122. */
  38123. getLeftJoystick(): VirtualJoystick;
  38124. /**
  38125. * Gets the right stick of the virtual joystick.
  38126. * @returns The virtual Joystick
  38127. */
  38128. getRightJoystick(): VirtualJoystick;
  38129. /**
  38130. * Update the current camera state depending on the inputs that have been used this frame.
  38131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38132. */
  38133. checkInputs(): void;
  38134. /**
  38135. * Attach the input controls to a specific dom element to get the input from.
  38136. * @param element Defines the element the controls should be listened from
  38137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38138. */
  38139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38140. /**
  38141. * Detach the current controls from the specified dom element.
  38142. * @param element Defines the element to stop listening the inputs from
  38143. */
  38144. detachControl(element: Nullable<HTMLElement>): void;
  38145. /**
  38146. * Gets the class name of the current intput.
  38147. * @returns the class name
  38148. */
  38149. getClassName(): string;
  38150. /**
  38151. * Get the friendly name associated with the input class.
  38152. * @returns the input friendly name
  38153. */
  38154. getSimpleName(): string;
  38155. }
  38156. }
  38157. declare module "babylonjs/Cameras/Inputs/index" {
  38158. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38159. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38160. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38161. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38162. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38163. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38164. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38165. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38166. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38167. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38168. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38169. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38170. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38171. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38172. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38173. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38174. }
  38175. declare module "babylonjs/Cameras/touchCamera" {
  38176. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38177. import { Scene } from "babylonjs/scene";
  38178. import { Vector3 } from "babylonjs/Maths/math";
  38179. /**
  38180. * This represents a FPS type of camera controlled by touch.
  38181. * This is like a universal camera minus the Gamepad controls.
  38182. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38183. */
  38184. export class TouchCamera extends FreeCamera {
  38185. /**
  38186. * Defines the touch sensibility for rotation.
  38187. * The higher the faster.
  38188. */
  38189. touchAngularSensibility: number;
  38190. /**
  38191. * Defines the touch sensibility for move.
  38192. * The higher the faster.
  38193. */
  38194. touchMoveSensibility: number;
  38195. /**
  38196. * Instantiates a new touch camera.
  38197. * This represents a FPS type of camera controlled by touch.
  38198. * This is like a universal camera minus the Gamepad controls.
  38199. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38200. * @param name Define the name of the camera in the scene
  38201. * @param position Define the start position of the camera in the scene
  38202. * @param scene Define the scene the camera belongs to
  38203. */
  38204. constructor(name: string, position: Vector3, scene: Scene);
  38205. /**
  38206. * Gets the current object class name.
  38207. * @return the class name
  38208. */
  38209. getClassName(): string;
  38210. /** @hidden */
  38211. _setupInputs(): void;
  38212. }
  38213. }
  38214. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38215. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38216. import { Scene } from "babylonjs/scene";
  38217. import { Vector3, Axis } from "babylonjs/Maths/math";
  38218. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38219. /**
  38220. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38221. * being tilted forward or back and left or right.
  38222. */
  38223. export class DeviceOrientationCamera extends FreeCamera {
  38224. private _initialQuaternion;
  38225. private _quaternionCache;
  38226. /**
  38227. * Creates a new device orientation camera
  38228. * @param name The name of the camera
  38229. * @param position The start position camera
  38230. * @param scene The scene the camera belongs to
  38231. */
  38232. constructor(name: string, position: Vector3, scene: Scene);
  38233. /**
  38234. * Gets the current instance class name ("DeviceOrientationCamera").
  38235. * This helps avoiding instanceof at run time.
  38236. * @returns the class name
  38237. */
  38238. getClassName(): string;
  38239. /**
  38240. * @hidden
  38241. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38242. */
  38243. _checkInputs(): void;
  38244. /**
  38245. * Reset the camera to its default orientation on the specified axis only.
  38246. * @param axis The axis to reset
  38247. */
  38248. resetToCurrentRotation(axis?: Axis): void;
  38249. }
  38250. }
  38251. declare module "babylonjs/Cameras/universalCamera" {
  38252. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38253. import { Scene } from "babylonjs/scene";
  38254. import { Vector3 } from "babylonjs/Maths/math";
  38255. /**
  38256. * 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,
  38257. * which still works and will still be found in many Playgrounds.
  38258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38259. */
  38260. export class UniversalCamera extends TouchCamera {
  38261. /**
  38262. * Defines the gamepad rotation sensiblity.
  38263. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38264. */
  38265. gamepadAngularSensibility: number;
  38266. /**
  38267. * Defines the gamepad move sensiblity.
  38268. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38269. */
  38270. gamepadMoveSensibility: number;
  38271. /**
  38272. * 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,
  38273. * which still works and will still be found in many Playgrounds.
  38274. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38275. * @param name Define the name of the camera in the scene
  38276. * @param position Define the start position of the camera in the scene
  38277. * @param scene Define the scene the camera belongs to
  38278. */
  38279. constructor(name: string, position: Vector3, scene: Scene);
  38280. /**
  38281. * Gets the current object class name.
  38282. * @return the class name
  38283. */
  38284. getClassName(): string;
  38285. }
  38286. }
  38287. declare module "babylonjs/Cameras/gamepadCamera" {
  38288. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38289. import { Scene } from "babylonjs/scene";
  38290. import { Vector3 } from "babylonjs/Maths/math";
  38291. /**
  38292. * This represents a FPS type of camera. This is only here for back compat purpose.
  38293. * Please use the UniversalCamera instead as both are identical.
  38294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38295. */
  38296. export class GamepadCamera extends UniversalCamera {
  38297. /**
  38298. * Instantiates a new Gamepad Camera
  38299. * This represents a FPS type of camera. This is only here for back compat purpose.
  38300. * Please use the UniversalCamera instead as both are identical.
  38301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38302. * @param name Define the name of the camera in the scene
  38303. * @param position Define the start position of the camera in the scene
  38304. * @param scene Define the scene the camera belongs to
  38305. */
  38306. constructor(name: string, position: Vector3, scene: Scene);
  38307. /**
  38308. * Gets the current object class name.
  38309. * @return the class name
  38310. */
  38311. getClassName(): string;
  38312. }
  38313. }
  38314. declare module "babylonjs/Shaders/pass.fragment" {
  38315. /** @hidden */
  38316. export var passPixelShader: {
  38317. name: string;
  38318. shader: string;
  38319. };
  38320. }
  38321. declare module "babylonjs/Shaders/passCube.fragment" {
  38322. /** @hidden */
  38323. export var passCubePixelShader: {
  38324. name: string;
  38325. shader: string;
  38326. };
  38327. }
  38328. declare module "babylonjs/PostProcesses/passPostProcess" {
  38329. import { Nullable } from "babylonjs/types";
  38330. import { Camera } from "babylonjs/Cameras/camera";
  38331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38332. import { Engine } from "babylonjs/Engines/engine";
  38333. import "babylonjs/Shaders/pass.fragment";
  38334. import "babylonjs/Shaders/passCube.fragment";
  38335. /**
  38336. * PassPostProcess which produces an output the same as it's input
  38337. */
  38338. export class PassPostProcess extends PostProcess {
  38339. /**
  38340. * Creates the PassPostProcess
  38341. * @param name The name of the effect.
  38342. * @param options The required width/height ratio to downsize to before computing the render pass.
  38343. * @param camera The camera to apply the render pass to.
  38344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38345. * @param engine The engine which the post process will be applied. (default: current engine)
  38346. * @param reusable If the post process can be reused on the same frame. (default: false)
  38347. * @param textureType The type of texture to be used when performing the post processing.
  38348. * @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)
  38349. */
  38350. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38351. }
  38352. /**
  38353. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38354. */
  38355. export class PassCubePostProcess extends PostProcess {
  38356. private _face;
  38357. /**
  38358. * Gets or sets the cube face to display.
  38359. * * 0 is +X
  38360. * * 1 is -X
  38361. * * 2 is +Y
  38362. * * 3 is -Y
  38363. * * 4 is +Z
  38364. * * 5 is -Z
  38365. */
  38366. face: number;
  38367. /**
  38368. * Creates the PassCubePostProcess
  38369. * @param name The name of the effect.
  38370. * @param options The required width/height ratio to downsize to before computing the render pass.
  38371. * @param camera The camera to apply the render pass to.
  38372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38373. * @param engine The engine which the post process will be applied. (default: current engine)
  38374. * @param reusable If the post process can be reused on the same frame. (default: false)
  38375. * @param textureType The type of texture to be used when performing the post processing.
  38376. * @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)
  38377. */
  38378. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38379. }
  38380. }
  38381. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38382. /** @hidden */
  38383. export var anaglyphPixelShader: {
  38384. name: string;
  38385. shader: string;
  38386. };
  38387. }
  38388. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38389. import { Engine } from "babylonjs/Engines/engine";
  38390. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38391. import { Camera } from "babylonjs/Cameras/camera";
  38392. import "babylonjs/Shaders/anaglyph.fragment";
  38393. /**
  38394. * Postprocess used to generate anaglyphic rendering
  38395. */
  38396. export class AnaglyphPostProcess extends PostProcess {
  38397. private _passedProcess;
  38398. /**
  38399. * Creates a new AnaglyphPostProcess
  38400. * @param name defines postprocess name
  38401. * @param options defines creation options or target ratio scale
  38402. * @param rigCameras defines cameras using this postprocess
  38403. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38404. * @param engine defines hosting engine
  38405. * @param reusable defines if the postprocess will be reused multiple times per frame
  38406. */
  38407. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38408. }
  38409. }
  38410. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38411. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38412. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38413. import { Scene } from "babylonjs/scene";
  38414. import { Vector3 } from "babylonjs/Maths/math";
  38415. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38416. /**
  38417. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38418. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38419. */
  38420. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38421. /**
  38422. * Creates a new AnaglyphArcRotateCamera
  38423. * @param name defines camera name
  38424. * @param alpha defines alpha angle (in radians)
  38425. * @param beta defines beta angle (in radians)
  38426. * @param radius defines radius
  38427. * @param target defines camera target
  38428. * @param interaxialDistance defines distance between each color axis
  38429. * @param scene defines the hosting scene
  38430. */
  38431. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38432. /**
  38433. * Gets camera class name
  38434. * @returns AnaglyphArcRotateCamera
  38435. */
  38436. getClassName(): string;
  38437. }
  38438. }
  38439. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38440. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38441. import { Scene } from "babylonjs/scene";
  38442. import { Vector3 } from "babylonjs/Maths/math";
  38443. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38444. /**
  38445. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38446. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38447. */
  38448. export class AnaglyphFreeCamera extends FreeCamera {
  38449. /**
  38450. * Creates a new AnaglyphFreeCamera
  38451. * @param name defines camera name
  38452. * @param position defines initial position
  38453. * @param interaxialDistance defines distance between each color axis
  38454. * @param scene defines the hosting scene
  38455. */
  38456. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38457. /**
  38458. * Gets camera class name
  38459. * @returns AnaglyphFreeCamera
  38460. */
  38461. getClassName(): string;
  38462. }
  38463. }
  38464. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38465. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38466. import { Scene } from "babylonjs/scene";
  38467. import { Vector3 } from "babylonjs/Maths/math";
  38468. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38469. /**
  38470. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38471. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38472. */
  38473. export class AnaglyphGamepadCamera extends GamepadCamera {
  38474. /**
  38475. * Creates a new AnaglyphGamepadCamera
  38476. * @param name defines camera name
  38477. * @param position defines initial position
  38478. * @param interaxialDistance defines distance between each color axis
  38479. * @param scene defines the hosting scene
  38480. */
  38481. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38482. /**
  38483. * Gets camera class name
  38484. * @returns AnaglyphGamepadCamera
  38485. */
  38486. getClassName(): string;
  38487. }
  38488. }
  38489. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38490. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38491. import { Scene } from "babylonjs/scene";
  38492. import { Vector3 } from "babylonjs/Maths/math";
  38493. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38494. /**
  38495. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38496. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38497. */
  38498. export class AnaglyphUniversalCamera extends UniversalCamera {
  38499. /**
  38500. * Creates a new AnaglyphUniversalCamera
  38501. * @param name defines camera name
  38502. * @param position defines initial position
  38503. * @param interaxialDistance defines distance between each color axis
  38504. * @param scene defines the hosting scene
  38505. */
  38506. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38507. /**
  38508. * Gets camera class name
  38509. * @returns AnaglyphUniversalCamera
  38510. */
  38511. getClassName(): string;
  38512. }
  38513. }
  38514. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38515. /** @hidden */
  38516. export var stereoscopicInterlacePixelShader: {
  38517. name: string;
  38518. shader: string;
  38519. };
  38520. }
  38521. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38522. import { Camera } from "babylonjs/Cameras/camera";
  38523. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38524. import { Engine } from "babylonjs/Engines/engine";
  38525. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38526. /**
  38527. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38528. */
  38529. export class StereoscopicInterlacePostProcess extends PostProcess {
  38530. private _stepSize;
  38531. private _passedProcess;
  38532. /**
  38533. * Initializes a StereoscopicInterlacePostProcess
  38534. * @param name The name of the effect.
  38535. * @param rigCameras The rig cameras to be appled to the post process
  38536. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38538. * @param engine The engine which the post process will be applied. (default: current engine)
  38539. * @param reusable If the post process can be reused on the same frame. (default: false)
  38540. */
  38541. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38542. }
  38543. }
  38544. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38545. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38546. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38547. import { Scene } from "babylonjs/scene";
  38548. import { Vector3 } from "babylonjs/Maths/math";
  38549. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38550. /**
  38551. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38552. * @see http://doc.babylonjs.com/features/cameras
  38553. */
  38554. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38555. /**
  38556. * Creates a new StereoscopicArcRotateCamera
  38557. * @param name defines camera name
  38558. * @param alpha defines alpha angle (in radians)
  38559. * @param beta defines beta angle (in radians)
  38560. * @param radius defines radius
  38561. * @param target defines camera target
  38562. * @param interaxialDistance defines distance between each color axis
  38563. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38564. * @param scene defines the hosting scene
  38565. */
  38566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38567. /**
  38568. * Gets camera class name
  38569. * @returns StereoscopicArcRotateCamera
  38570. */
  38571. getClassName(): string;
  38572. }
  38573. }
  38574. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38575. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38576. import { Scene } from "babylonjs/scene";
  38577. import { Vector3 } from "babylonjs/Maths/math";
  38578. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38579. /**
  38580. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38581. * @see http://doc.babylonjs.com/features/cameras
  38582. */
  38583. export class StereoscopicFreeCamera extends FreeCamera {
  38584. /**
  38585. * Creates a new StereoscopicFreeCamera
  38586. * @param name defines camera name
  38587. * @param position defines initial position
  38588. * @param interaxialDistance defines distance between each color axis
  38589. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38590. * @param scene defines the hosting scene
  38591. */
  38592. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38593. /**
  38594. * Gets camera class name
  38595. * @returns StereoscopicFreeCamera
  38596. */
  38597. getClassName(): string;
  38598. }
  38599. }
  38600. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38601. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38602. import { Scene } from "babylonjs/scene";
  38603. import { Vector3 } from "babylonjs/Maths/math";
  38604. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38605. /**
  38606. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38607. * @see http://doc.babylonjs.com/features/cameras
  38608. */
  38609. export class StereoscopicGamepadCamera extends GamepadCamera {
  38610. /**
  38611. * Creates a new StereoscopicGamepadCamera
  38612. * @param name defines camera name
  38613. * @param position defines initial position
  38614. * @param interaxialDistance defines distance between each color axis
  38615. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38616. * @param scene defines the hosting scene
  38617. */
  38618. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38619. /**
  38620. * Gets camera class name
  38621. * @returns StereoscopicGamepadCamera
  38622. */
  38623. getClassName(): string;
  38624. }
  38625. }
  38626. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38627. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38628. import { Scene } from "babylonjs/scene";
  38629. import { Vector3 } from "babylonjs/Maths/math";
  38630. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38631. /**
  38632. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38633. * @see http://doc.babylonjs.com/features/cameras
  38634. */
  38635. export class StereoscopicUniversalCamera extends UniversalCamera {
  38636. /**
  38637. * Creates a new StereoscopicUniversalCamera
  38638. * @param name defines camera name
  38639. * @param position defines initial position
  38640. * @param interaxialDistance defines distance between each color axis
  38641. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38642. * @param scene defines the hosting scene
  38643. */
  38644. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38645. /**
  38646. * Gets camera class name
  38647. * @returns StereoscopicUniversalCamera
  38648. */
  38649. getClassName(): string;
  38650. }
  38651. }
  38652. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38653. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38654. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38655. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38656. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38657. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38658. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38659. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38660. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38661. }
  38662. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38663. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38664. import { Scene } from "babylonjs/scene";
  38665. import { Vector3 } from "babylonjs/Maths/math";
  38666. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38667. /**
  38668. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38669. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38670. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38671. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38672. */
  38673. export class VirtualJoysticksCamera extends FreeCamera {
  38674. /**
  38675. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38676. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38677. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38678. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38679. * @param name Define the name of the camera in the scene
  38680. * @param position Define the start position of the camera in the scene
  38681. * @param scene Define the scene the camera belongs to
  38682. */
  38683. constructor(name: string, position: Vector3, scene: Scene);
  38684. /**
  38685. * Gets the current object class name.
  38686. * @return the class name
  38687. */
  38688. getClassName(): string;
  38689. }
  38690. }
  38691. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38692. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38693. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38694. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38695. import { Scene } from "babylonjs/scene";
  38696. import { Vector3 } from "babylonjs/Maths/math";
  38697. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38698. import "babylonjs/Cameras/RigModes/vrRigMode";
  38699. /**
  38700. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38701. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38702. */
  38703. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38704. /**
  38705. * Creates a new VRDeviceOrientationArcRotateCamera
  38706. * @param name defines camera name
  38707. * @param alpha defines the camera rotation along the logitudinal axis
  38708. * @param beta defines the camera rotation along the latitudinal axis
  38709. * @param radius defines the camera distance from its target
  38710. * @param target defines the camera target
  38711. * @param scene defines the scene the camera belongs to
  38712. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38713. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38714. */
  38715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38716. /**
  38717. * Gets camera class name
  38718. * @returns VRDeviceOrientationArcRotateCamera
  38719. */
  38720. getClassName(): string;
  38721. }
  38722. }
  38723. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38724. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38725. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38726. import { Scene } from "babylonjs/scene";
  38727. import { Vector3 } from "babylonjs/Maths/math";
  38728. import "babylonjs/Cameras/RigModes/vrRigMode";
  38729. /**
  38730. * Camera used to simulate VR rendering (based on FreeCamera)
  38731. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38732. */
  38733. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38734. /**
  38735. * Creates a new VRDeviceOrientationFreeCamera
  38736. * @param name defines camera name
  38737. * @param position defines the start position of the camera
  38738. * @param scene defines the scene the camera belongs to
  38739. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38740. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38741. */
  38742. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38743. /**
  38744. * Gets camera class name
  38745. * @returns VRDeviceOrientationFreeCamera
  38746. */
  38747. getClassName(): string;
  38748. }
  38749. }
  38750. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38751. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38752. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38753. import { Scene } from "babylonjs/scene";
  38754. import { Vector3 } from "babylonjs/Maths/math";
  38755. /**
  38756. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38757. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38758. */
  38759. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38760. /**
  38761. * Creates a new VRDeviceOrientationGamepadCamera
  38762. * @param name defines camera name
  38763. * @param position defines the start position of the camera
  38764. * @param scene defines the scene the camera belongs to
  38765. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38766. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38767. */
  38768. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38769. /**
  38770. * Gets camera class name
  38771. * @returns VRDeviceOrientationGamepadCamera
  38772. */
  38773. getClassName(): string;
  38774. }
  38775. }
  38776. declare module "babylonjs/Gamepads/xboxGamepad" {
  38777. import { Observable } from "babylonjs/Misc/observable";
  38778. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38779. /**
  38780. * Defines supported buttons for XBox360 compatible gamepads
  38781. */
  38782. export enum Xbox360Button {
  38783. /** A */
  38784. A = 0,
  38785. /** B */
  38786. B = 1,
  38787. /** X */
  38788. X = 2,
  38789. /** Y */
  38790. Y = 3,
  38791. /** Start */
  38792. Start = 4,
  38793. /** Back */
  38794. Back = 5,
  38795. /** Left button */
  38796. LB = 6,
  38797. /** Right button */
  38798. RB = 7,
  38799. /** Left stick */
  38800. LeftStick = 8,
  38801. /** Right stick */
  38802. RightStick = 9
  38803. }
  38804. /** Defines values for XBox360 DPad */
  38805. export enum Xbox360Dpad {
  38806. /** Up */
  38807. Up = 0,
  38808. /** Down */
  38809. Down = 1,
  38810. /** Left */
  38811. Left = 2,
  38812. /** Right */
  38813. Right = 3
  38814. }
  38815. /**
  38816. * Defines a XBox360 gamepad
  38817. */
  38818. export class Xbox360Pad extends Gamepad {
  38819. private _leftTrigger;
  38820. private _rightTrigger;
  38821. private _onlefttriggerchanged;
  38822. private _onrighttriggerchanged;
  38823. private _onbuttondown;
  38824. private _onbuttonup;
  38825. private _ondpaddown;
  38826. private _ondpadup;
  38827. /** Observable raised when a button is pressed */
  38828. onButtonDownObservable: Observable<Xbox360Button>;
  38829. /** Observable raised when a button is released */
  38830. onButtonUpObservable: Observable<Xbox360Button>;
  38831. /** Observable raised when a pad is pressed */
  38832. onPadDownObservable: Observable<Xbox360Dpad>;
  38833. /** Observable raised when a pad is released */
  38834. onPadUpObservable: Observable<Xbox360Dpad>;
  38835. private _buttonA;
  38836. private _buttonB;
  38837. private _buttonX;
  38838. private _buttonY;
  38839. private _buttonBack;
  38840. private _buttonStart;
  38841. private _buttonLB;
  38842. private _buttonRB;
  38843. private _buttonLeftStick;
  38844. private _buttonRightStick;
  38845. private _dPadUp;
  38846. private _dPadDown;
  38847. private _dPadLeft;
  38848. private _dPadRight;
  38849. private _isXboxOnePad;
  38850. /**
  38851. * Creates a new XBox360 gamepad object
  38852. * @param id defines the id of this gamepad
  38853. * @param index defines its index
  38854. * @param gamepad defines the internal HTML gamepad object
  38855. * @param xboxOne defines if it is a XBox One gamepad
  38856. */
  38857. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38858. /**
  38859. * Defines the callback to call when left trigger is pressed
  38860. * @param callback defines the callback to use
  38861. */
  38862. onlefttriggerchanged(callback: (value: number) => void): void;
  38863. /**
  38864. * Defines the callback to call when right trigger is pressed
  38865. * @param callback defines the callback to use
  38866. */
  38867. onrighttriggerchanged(callback: (value: number) => void): void;
  38868. /**
  38869. * Gets the left trigger value
  38870. */
  38871. /**
  38872. * Sets the left trigger value
  38873. */
  38874. leftTrigger: number;
  38875. /**
  38876. * Gets the right trigger value
  38877. */
  38878. /**
  38879. * Sets the right trigger value
  38880. */
  38881. rightTrigger: number;
  38882. /**
  38883. * Defines the callback to call when a button is pressed
  38884. * @param callback defines the callback to use
  38885. */
  38886. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38887. /**
  38888. * Defines the callback to call when a button is released
  38889. * @param callback defines the callback to use
  38890. */
  38891. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38892. /**
  38893. * Defines the callback to call when a pad is pressed
  38894. * @param callback defines the callback to use
  38895. */
  38896. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38897. /**
  38898. * Defines the callback to call when a pad is released
  38899. * @param callback defines the callback to use
  38900. */
  38901. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38902. private _setButtonValue;
  38903. private _setDPadValue;
  38904. /**
  38905. * Gets the value of the `A` button
  38906. */
  38907. /**
  38908. * Sets the value of the `A` button
  38909. */
  38910. buttonA: number;
  38911. /**
  38912. * Gets the value of the `B` button
  38913. */
  38914. /**
  38915. * Sets the value of the `B` button
  38916. */
  38917. buttonB: number;
  38918. /**
  38919. * Gets the value of the `X` button
  38920. */
  38921. /**
  38922. * Sets the value of the `X` button
  38923. */
  38924. buttonX: number;
  38925. /**
  38926. * Gets the value of the `Y` button
  38927. */
  38928. /**
  38929. * Sets the value of the `Y` button
  38930. */
  38931. buttonY: number;
  38932. /**
  38933. * Gets the value of the `Start` button
  38934. */
  38935. /**
  38936. * Sets the value of the `Start` button
  38937. */
  38938. buttonStart: number;
  38939. /**
  38940. * Gets the value of the `Back` button
  38941. */
  38942. /**
  38943. * Sets the value of the `Back` button
  38944. */
  38945. buttonBack: number;
  38946. /**
  38947. * Gets the value of the `Left` button
  38948. */
  38949. /**
  38950. * Sets the value of the `Left` button
  38951. */
  38952. buttonLB: number;
  38953. /**
  38954. * Gets the value of the `Right` button
  38955. */
  38956. /**
  38957. * Sets the value of the `Right` button
  38958. */
  38959. buttonRB: number;
  38960. /**
  38961. * Gets the value of the Left joystick
  38962. */
  38963. /**
  38964. * Sets the value of the Left joystick
  38965. */
  38966. buttonLeftStick: number;
  38967. /**
  38968. * Gets the value of the Right joystick
  38969. */
  38970. /**
  38971. * Sets the value of the Right joystick
  38972. */
  38973. buttonRightStick: number;
  38974. /**
  38975. * Gets the value of D-pad up
  38976. */
  38977. /**
  38978. * Sets the value of D-pad up
  38979. */
  38980. dPadUp: number;
  38981. /**
  38982. * Gets the value of D-pad down
  38983. */
  38984. /**
  38985. * Sets the value of D-pad down
  38986. */
  38987. dPadDown: number;
  38988. /**
  38989. * Gets the value of D-pad left
  38990. */
  38991. /**
  38992. * Sets the value of D-pad left
  38993. */
  38994. dPadLeft: number;
  38995. /**
  38996. * Gets the value of D-pad right
  38997. */
  38998. /**
  38999. * Sets the value of D-pad right
  39000. */
  39001. dPadRight: number;
  39002. /**
  39003. * Force the gamepad to synchronize with device values
  39004. */
  39005. update(): void;
  39006. /**
  39007. * Disposes the gamepad
  39008. */
  39009. dispose(): void;
  39010. }
  39011. }
  39012. declare module "babylonjs/Materials/pushMaterial" {
  39013. import { Nullable } from "babylonjs/types";
  39014. import { Scene } from "babylonjs/scene";
  39015. import { Matrix } from "babylonjs/Maths/math";
  39016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39017. import { Mesh } from "babylonjs/Meshes/mesh";
  39018. import { Material } from "babylonjs/Materials/material";
  39019. import { Effect } from "babylonjs/Materials/effect";
  39020. /**
  39021. * Base class of materials working in push mode in babylon JS
  39022. * @hidden
  39023. */
  39024. export class PushMaterial extends Material {
  39025. protected _activeEffect: Effect;
  39026. protected _normalMatrix: Matrix;
  39027. /**
  39028. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39029. * This means that the material can keep using a previous shader while a new one is being compiled.
  39030. * This is mostly used when shader parallel compilation is supported (true by default)
  39031. */
  39032. allowShaderHotSwapping: boolean;
  39033. constructor(name: string, scene: Scene);
  39034. getEffect(): Effect;
  39035. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39036. /**
  39037. * Binds the given world matrix to the active effect
  39038. *
  39039. * @param world the matrix to bind
  39040. */
  39041. bindOnlyWorldMatrix(world: Matrix): void;
  39042. /**
  39043. * Binds the given normal matrix to the active effect
  39044. *
  39045. * @param normalMatrix the matrix to bind
  39046. */
  39047. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39048. bind(world: Matrix, mesh?: Mesh): void;
  39049. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39050. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39051. }
  39052. }
  39053. declare module "babylonjs/Materials/materialFlags" {
  39054. /**
  39055. * This groups all the flags used to control the materials channel.
  39056. */
  39057. export class MaterialFlags {
  39058. private static _DiffuseTextureEnabled;
  39059. /**
  39060. * Are diffuse textures enabled in the application.
  39061. */
  39062. static DiffuseTextureEnabled: boolean;
  39063. private static _AmbientTextureEnabled;
  39064. /**
  39065. * Are ambient textures enabled in the application.
  39066. */
  39067. static AmbientTextureEnabled: boolean;
  39068. private static _OpacityTextureEnabled;
  39069. /**
  39070. * Are opacity textures enabled in the application.
  39071. */
  39072. static OpacityTextureEnabled: boolean;
  39073. private static _ReflectionTextureEnabled;
  39074. /**
  39075. * Are reflection textures enabled in the application.
  39076. */
  39077. static ReflectionTextureEnabled: boolean;
  39078. private static _EmissiveTextureEnabled;
  39079. /**
  39080. * Are emissive textures enabled in the application.
  39081. */
  39082. static EmissiveTextureEnabled: boolean;
  39083. private static _SpecularTextureEnabled;
  39084. /**
  39085. * Are specular textures enabled in the application.
  39086. */
  39087. static SpecularTextureEnabled: boolean;
  39088. private static _BumpTextureEnabled;
  39089. /**
  39090. * Are bump textures enabled in the application.
  39091. */
  39092. static BumpTextureEnabled: boolean;
  39093. private static _LightmapTextureEnabled;
  39094. /**
  39095. * Are lightmap textures enabled in the application.
  39096. */
  39097. static LightmapTextureEnabled: boolean;
  39098. private static _RefractionTextureEnabled;
  39099. /**
  39100. * Are refraction textures enabled in the application.
  39101. */
  39102. static RefractionTextureEnabled: boolean;
  39103. private static _ColorGradingTextureEnabled;
  39104. /**
  39105. * Are color grading textures enabled in the application.
  39106. */
  39107. static ColorGradingTextureEnabled: boolean;
  39108. private static _FresnelEnabled;
  39109. /**
  39110. * Are fresnels enabled in the application.
  39111. */
  39112. static FresnelEnabled: boolean;
  39113. private static _ClearCoatTextureEnabled;
  39114. /**
  39115. * Are clear coat textures enabled in the application.
  39116. */
  39117. static ClearCoatTextureEnabled: boolean;
  39118. private static _ClearCoatBumpTextureEnabled;
  39119. /**
  39120. * Are clear coat bump textures enabled in the application.
  39121. */
  39122. static ClearCoatBumpTextureEnabled: boolean;
  39123. private static _ClearCoatTintTextureEnabled;
  39124. /**
  39125. * Are clear coat tint textures enabled in the application.
  39126. */
  39127. static ClearCoatTintTextureEnabled: boolean;
  39128. private static _SheenTextureEnabled;
  39129. /**
  39130. * Are sheen textures enabled in the application.
  39131. */
  39132. static SheenTextureEnabled: boolean;
  39133. private static _AnisotropicTextureEnabled;
  39134. /**
  39135. * Are anisotropic textures enabled in the application.
  39136. */
  39137. static AnisotropicTextureEnabled: boolean;
  39138. }
  39139. }
  39140. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39141. /** @hidden */
  39142. export var defaultFragmentDeclaration: {
  39143. name: string;
  39144. shader: string;
  39145. };
  39146. }
  39147. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39148. /** @hidden */
  39149. export var defaultUboDeclaration: {
  39150. name: string;
  39151. shader: string;
  39152. };
  39153. }
  39154. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39155. /** @hidden */
  39156. export var lightFragmentDeclaration: {
  39157. name: string;
  39158. shader: string;
  39159. };
  39160. }
  39161. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39162. /** @hidden */
  39163. export var lightUboDeclaration: {
  39164. name: string;
  39165. shader: string;
  39166. };
  39167. }
  39168. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39169. /** @hidden */
  39170. export var lightsFragmentFunctions: {
  39171. name: string;
  39172. shader: string;
  39173. };
  39174. }
  39175. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39176. /** @hidden */
  39177. export var shadowsFragmentFunctions: {
  39178. name: string;
  39179. shader: string;
  39180. };
  39181. }
  39182. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39183. /** @hidden */
  39184. export var fresnelFunction: {
  39185. name: string;
  39186. shader: string;
  39187. };
  39188. }
  39189. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39190. /** @hidden */
  39191. export var reflectionFunction: {
  39192. name: string;
  39193. shader: string;
  39194. };
  39195. }
  39196. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39197. /** @hidden */
  39198. export var bumpFragmentFunctions: {
  39199. name: string;
  39200. shader: string;
  39201. };
  39202. }
  39203. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39204. /** @hidden */
  39205. export var logDepthDeclaration: {
  39206. name: string;
  39207. shader: string;
  39208. };
  39209. }
  39210. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39211. /** @hidden */
  39212. export var bumpFragment: {
  39213. name: string;
  39214. shader: string;
  39215. };
  39216. }
  39217. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39218. /** @hidden */
  39219. export var depthPrePass: {
  39220. name: string;
  39221. shader: string;
  39222. };
  39223. }
  39224. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39225. /** @hidden */
  39226. export var lightFragment: {
  39227. name: string;
  39228. shader: string;
  39229. };
  39230. }
  39231. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39232. /** @hidden */
  39233. export var logDepthFragment: {
  39234. name: string;
  39235. shader: string;
  39236. };
  39237. }
  39238. declare module "babylonjs/Shaders/default.fragment" {
  39239. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39240. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39241. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39242. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39243. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39244. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39245. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39246. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39247. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39248. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39249. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39250. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39251. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39252. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39253. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39254. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39255. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39256. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39257. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39258. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39259. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39260. /** @hidden */
  39261. export var defaultPixelShader: {
  39262. name: string;
  39263. shader: string;
  39264. };
  39265. }
  39266. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39267. /** @hidden */
  39268. export var defaultVertexDeclaration: {
  39269. name: string;
  39270. shader: string;
  39271. };
  39272. }
  39273. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39274. /** @hidden */
  39275. export var bumpVertexDeclaration: {
  39276. name: string;
  39277. shader: string;
  39278. };
  39279. }
  39280. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39281. /** @hidden */
  39282. export var bumpVertex: {
  39283. name: string;
  39284. shader: string;
  39285. };
  39286. }
  39287. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39288. /** @hidden */
  39289. export var fogVertex: {
  39290. name: string;
  39291. shader: string;
  39292. };
  39293. }
  39294. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39295. /** @hidden */
  39296. export var shadowsVertex: {
  39297. name: string;
  39298. shader: string;
  39299. };
  39300. }
  39301. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39302. /** @hidden */
  39303. export var pointCloudVertex: {
  39304. name: string;
  39305. shader: string;
  39306. };
  39307. }
  39308. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39309. /** @hidden */
  39310. export var logDepthVertex: {
  39311. name: string;
  39312. shader: string;
  39313. };
  39314. }
  39315. declare module "babylonjs/Shaders/default.vertex" {
  39316. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39317. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39318. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39319. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39320. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39321. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39322. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39323. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39324. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39325. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39326. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39328. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39329. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39330. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39331. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39332. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39333. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39334. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39335. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39336. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39337. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39338. /** @hidden */
  39339. export var defaultVertexShader: {
  39340. name: string;
  39341. shader: string;
  39342. };
  39343. }
  39344. declare module "babylonjs/Materials/standardMaterial" {
  39345. import { SmartArray } from "babylonjs/Misc/smartArray";
  39346. import { IAnimatable } from "babylonjs/Misc/tools";
  39347. import { Nullable } from "babylonjs/types";
  39348. import { Scene } from "babylonjs/scene";
  39349. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39350. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39352. import { Mesh } from "babylonjs/Meshes/mesh";
  39353. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39354. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39355. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39356. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39357. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39359. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39360. import "babylonjs/Shaders/default.fragment";
  39361. import "babylonjs/Shaders/default.vertex";
  39362. /** @hidden */
  39363. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39364. MAINUV1: boolean;
  39365. MAINUV2: boolean;
  39366. DIFFUSE: boolean;
  39367. DIFFUSEDIRECTUV: number;
  39368. AMBIENT: boolean;
  39369. AMBIENTDIRECTUV: number;
  39370. OPACITY: boolean;
  39371. OPACITYDIRECTUV: number;
  39372. OPACITYRGB: boolean;
  39373. REFLECTION: boolean;
  39374. EMISSIVE: boolean;
  39375. EMISSIVEDIRECTUV: number;
  39376. SPECULAR: boolean;
  39377. SPECULARDIRECTUV: number;
  39378. BUMP: boolean;
  39379. BUMPDIRECTUV: number;
  39380. PARALLAX: boolean;
  39381. PARALLAXOCCLUSION: boolean;
  39382. SPECULAROVERALPHA: boolean;
  39383. CLIPPLANE: boolean;
  39384. CLIPPLANE2: boolean;
  39385. CLIPPLANE3: boolean;
  39386. CLIPPLANE4: boolean;
  39387. ALPHATEST: boolean;
  39388. DEPTHPREPASS: boolean;
  39389. ALPHAFROMDIFFUSE: boolean;
  39390. POINTSIZE: boolean;
  39391. FOG: boolean;
  39392. SPECULARTERM: boolean;
  39393. DIFFUSEFRESNEL: boolean;
  39394. OPACITYFRESNEL: boolean;
  39395. REFLECTIONFRESNEL: boolean;
  39396. REFRACTIONFRESNEL: boolean;
  39397. EMISSIVEFRESNEL: boolean;
  39398. FRESNEL: boolean;
  39399. NORMAL: boolean;
  39400. UV1: boolean;
  39401. UV2: boolean;
  39402. VERTEXCOLOR: boolean;
  39403. VERTEXALPHA: boolean;
  39404. NUM_BONE_INFLUENCERS: number;
  39405. BonesPerMesh: number;
  39406. BONETEXTURE: boolean;
  39407. INSTANCES: boolean;
  39408. GLOSSINESS: boolean;
  39409. ROUGHNESS: boolean;
  39410. EMISSIVEASILLUMINATION: boolean;
  39411. LINKEMISSIVEWITHDIFFUSE: boolean;
  39412. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39413. LIGHTMAP: boolean;
  39414. LIGHTMAPDIRECTUV: number;
  39415. OBJECTSPACE_NORMALMAP: boolean;
  39416. USELIGHTMAPASSHADOWMAP: boolean;
  39417. REFLECTIONMAP_3D: boolean;
  39418. REFLECTIONMAP_SPHERICAL: boolean;
  39419. REFLECTIONMAP_PLANAR: boolean;
  39420. REFLECTIONMAP_CUBIC: boolean;
  39421. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39422. REFLECTIONMAP_PROJECTION: boolean;
  39423. REFLECTIONMAP_SKYBOX: boolean;
  39424. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39425. REFLECTIONMAP_EXPLICIT: boolean;
  39426. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39427. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39428. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39429. INVERTCUBICMAP: boolean;
  39430. LOGARITHMICDEPTH: boolean;
  39431. REFRACTION: boolean;
  39432. REFRACTIONMAP_3D: boolean;
  39433. REFLECTIONOVERALPHA: boolean;
  39434. TWOSIDEDLIGHTING: boolean;
  39435. SHADOWFLOAT: boolean;
  39436. MORPHTARGETS: boolean;
  39437. MORPHTARGETS_NORMAL: boolean;
  39438. MORPHTARGETS_TANGENT: boolean;
  39439. NUM_MORPH_INFLUENCERS: number;
  39440. NONUNIFORMSCALING: boolean;
  39441. PREMULTIPLYALPHA: boolean;
  39442. IMAGEPROCESSING: boolean;
  39443. VIGNETTE: boolean;
  39444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39445. VIGNETTEBLENDMODEOPAQUE: boolean;
  39446. TONEMAPPING: boolean;
  39447. TONEMAPPING_ACES: boolean;
  39448. CONTRAST: boolean;
  39449. COLORCURVES: boolean;
  39450. COLORGRADING: boolean;
  39451. COLORGRADING3D: boolean;
  39452. SAMPLER3DGREENDEPTH: boolean;
  39453. SAMPLER3DBGRMAP: boolean;
  39454. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39455. MULTIVIEW: boolean;
  39456. /**
  39457. * If the reflection texture on this material is in linear color space
  39458. * @hidden
  39459. */
  39460. IS_REFLECTION_LINEAR: boolean;
  39461. /**
  39462. * If the refraction texture on this material is in linear color space
  39463. * @hidden
  39464. */
  39465. IS_REFRACTION_LINEAR: boolean;
  39466. EXPOSURE: boolean;
  39467. constructor();
  39468. setReflectionMode(modeToEnable: string): void;
  39469. }
  39470. /**
  39471. * This is the default material used in Babylon. It is the best trade off between quality
  39472. * and performances.
  39473. * @see http://doc.babylonjs.com/babylon101/materials
  39474. */
  39475. export class StandardMaterial extends PushMaterial {
  39476. private _diffuseTexture;
  39477. /**
  39478. * The basic texture of the material as viewed under a light.
  39479. */
  39480. diffuseTexture: Nullable<BaseTexture>;
  39481. private _ambientTexture;
  39482. /**
  39483. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39484. */
  39485. ambientTexture: Nullable<BaseTexture>;
  39486. private _opacityTexture;
  39487. /**
  39488. * Define the transparency of the material from a texture.
  39489. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39490. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39491. */
  39492. opacityTexture: Nullable<BaseTexture>;
  39493. private _reflectionTexture;
  39494. /**
  39495. * Define the texture used to display the reflection.
  39496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39497. */
  39498. reflectionTexture: Nullable<BaseTexture>;
  39499. private _emissiveTexture;
  39500. /**
  39501. * Define texture of the material as if self lit.
  39502. * This will be mixed in the final result even in the absence of light.
  39503. */
  39504. emissiveTexture: Nullable<BaseTexture>;
  39505. private _specularTexture;
  39506. /**
  39507. * Define how the color and intensity of the highlight given by the light in the material.
  39508. */
  39509. specularTexture: Nullable<BaseTexture>;
  39510. private _bumpTexture;
  39511. /**
  39512. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39513. * 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.
  39514. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39515. */
  39516. bumpTexture: Nullable<BaseTexture>;
  39517. private _lightmapTexture;
  39518. /**
  39519. * Complex lighting can be computationally expensive to compute at runtime.
  39520. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39521. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39522. */
  39523. lightmapTexture: Nullable<BaseTexture>;
  39524. private _refractionTexture;
  39525. /**
  39526. * Define the texture used to display the refraction.
  39527. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39528. */
  39529. refractionTexture: Nullable<BaseTexture>;
  39530. /**
  39531. * The color of the material lit by the environmental background lighting.
  39532. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39533. */
  39534. ambientColor: Color3;
  39535. /**
  39536. * The basic color of the material as viewed under a light.
  39537. */
  39538. diffuseColor: Color3;
  39539. /**
  39540. * Define how the color and intensity of the highlight given by the light in the material.
  39541. */
  39542. specularColor: Color3;
  39543. /**
  39544. * Define the color of the material as if self lit.
  39545. * This will be mixed in the final result even in the absence of light.
  39546. */
  39547. emissiveColor: Color3;
  39548. /**
  39549. * Defines how sharp are the highlights in the material.
  39550. * The bigger the value the sharper giving a more glossy feeling to the result.
  39551. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39552. */
  39553. specularPower: number;
  39554. private _useAlphaFromDiffuseTexture;
  39555. /**
  39556. * Does the transparency come from the diffuse texture alpha channel.
  39557. */
  39558. useAlphaFromDiffuseTexture: boolean;
  39559. private _useEmissiveAsIllumination;
  39560. /**
  39561. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39562. */
  39563. useEmissiveAsIllumination: boolean;
  39564. private _linkEmissiveWithDiffuse;
  39565. /**
  39566. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39567. * the emissive level when the final color is close to one.
  39568. */
  39569. linkEmissiveWithDiffuse: boolean;
  39570. private _useSpecularOverAlpha;
  39571. /**
  39572. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39573. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39574. */
  39575. useSpecularOverAlpha: boolean;
  39576. private _useReflectionOverAlpha;
  39577. /**
  39578. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39579. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39580. */
  39581. useReflectionOverAlpha: boolean;
  39582. private _disableLighting;
  39583. /**
  39584. * Does lights from the scene impacts this material.
  39585. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39586. */
  39587. disableLighting: boolean;
  39588. private _useObjectSpaceNormalMap;
  39589. /**
  39590. * Allows using an object space normal map (instead of tangent space).
  39591. */
  39592. useObjectSpaceNormalMap: boolean;
  39593. private _useParallax;
  39594. /**
  39595. * Is parallax enabled or not.
  39596. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39597. */
  39598. useParallax: boolean;
  39599. private _useParallaxOcclusion;
  39600. /**
  39601. * Is parallax occlusion enabled or not.
  39602. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39603. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39604. */
  39605. useParallaxOcclusion: boolean;
  39606. /**
  39607. * 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.
  39608. */
  39609. parallaxScaleBias: number;
  39610. private _roughness;
  39611. /**
  39612. * Helps to define how blurry the reflections should appears in the material.
  39613. */
  39614. roughness: number;
  39615. /**
  39616. * In case of refraction, define the value of the indice of refraction.
  39617. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39618. */
  39619. indexOfRefraction: number;
  39620. /**
  39621. * Invert the refraction texture alongside the y axis.
  39622. * It can be useful with procedural textures or probe for instance.
  39623. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39624. */
  39625. invertRefractionY: boolean;
  39626. /**
  39627. * Defines the alpha limits in alpha test mode.
  39628. */
  39629. alphaCutOff: number;
  39630. private _useLightmapAsShadowmap;
  39631. /**
  39632. * In case of light mapping, define whether the map contains light or shadow informations.
  39633. */
  39634. useLightmapAsShadowmap: boolean;
  39635. private _diffuseFresnelParameters;
  39636. /**
  39637. * Define the diffuse fresnel parameters of the material.
  39638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39639. */
  39640. diffuseFresnelParameters: FresnelParameters;
  39641. private _opacityFresnelParameters;
  39642. /**
  39643. * Define the opacity fresnel parameters of the material.
  39644. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39645. */
  39646. opacityFresnelParameters: FresnelParameters;
  39647. private _reflectionFresnelParameters;
  39648. /**
  39649. * Define the reflection fresnel parameters of the material.
  39650. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39651. */
  39652. reflectionFresnelParameters: FresnelParameters;
  39653. private _refractionFresnelParameters;
  39654. /**
  39655. * Define the refraction fresnel parameters of the material.
  39656. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39657. */
  39658. refractionFresnelParameters: FresnelParameters;
  39659. private _emissiveFresnelParameters;
  39660. /**
  39661. * Define the emissive fresnel parameters of the material.
  39662. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39663. */
  39664. emissiveFresnelParameters: FresnelParameters;
  39665. private _useReflectionFresnelFromSpecular;
  39666. /**
  39667. * If true automatically deducts the fresnels values from the material specularity.
  39668. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39669. */
  39670. useReflectionFresnelFromSpecular: boolean;
  39671. private _useGlossinessFromSpecularMapAlpha;
  39672. /**
  39673. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39674. */
  39675. useGlossinessFromSpecularMapAlpha: boolean;
  39676. private _maxSimultaneousLights;
  39677. /**
  39678. * Defines the maximum number of lights that can be used in the material
  39679. */
  39680. maxSimultaneousLights: number;
  39681. private _invertNormalMapX;
  39682. /**
  39683. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39684. */
  39685. invertNormalMapX: boolean;
  39686. private _invertNormalMapY;
  39687. /**
  39688. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39689. */
  39690. invertNormalMapY: boolean;
  39691. private _twoSidedLighting;
  39692. /**
  39693. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39694. */
  39695. twoSidedLighting: boolean;
  39696. /**
  39697. * Default configuration related to image processing available in the standard Material.
  39698. */
  39699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39700. /**
  39701. * Gets the image processing configuration used either in this material.
  39702. */
  39703. /**
  39704. * Sets the Default image processing configuration used either in the this material.
  39705. *
  39706. * If sets to null, the scene one is in use.
  39707. */
  39708. imageProcessingConfiguration: ImageProcessingConfiguration;
  39709. /**
  39710. * Keep track of the image processing observer to allow dispose and replace.
  39711. */
  39712. private _imageProcessingObserver;
  39713. /**
  39714. * Attaches a new image processing configuration to the Standard Material.
  39715. * @param configuration
  39716. */
  39717. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39718. /**
  39719. * Gets wether the color curves effect is enabled.
  39720. */
  39721. /**
  39722. * Sets wether the color curves effect is enabled.
  39723. */
  39724. cameraColorCurvesEnabled: boolean;
  39725. /**
  39726. * Gets wether the color grading effect is enabled.
  39727. */
  39728. /**
  39729. * Gets wether the color grading effect is enabled.
  39730. */
  39731. cameraColorGradingEnabled: boolean;
  39732. /**
  39733. * Gets wether tonemapping is enabled or not.
  39734. */
  39735. /**
  39736. * Sets wether tonemapping is enabled or not
  39737. */
  39738. cameraToneMappingEnabled: boolean;
  39739. /**
  39740. * The camera exposure used on this material.
  39741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39742. * This corresponds to a photographic exposure.
  39743. */
  39744. /**
  39745. * The camera exposure used on this material.
  39746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39747. * This corresponds to a photographic exposure.
  39748. */
  39749. cameraExposure: number;
  39750. /**
  39751. * Gets The camera contrast used on this material.
  39752. */
  39753. /**
  39754. * Sets The camera contrast used on this material.
  39755. */
  39756. cameraContrast: number;
  39757. /**
  39758. * Gets the Color Grading 2D Lookup Texture.
  39759. */
  39760. /**
  39761. * Sets the Color Grading 2D Lookup Texture.
  39762. */
  39763. cameraColorGradingTexture: Nullable<BaseTexture>;
  39764. /**
  39765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39767. * 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;
  39768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39769. */
  39770. /**
  39771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39773. * 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;
  39774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39775. */
  39776. cameraColorCurves: Nullable<ColorCurves>;
  39777. /**
  39778. * Custom callback helping to override the default shader used in the material.
  39779. */
  39780. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39781. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39782. protected _worldViewProjectionMatrix: Matrix;
  39783. protected _globalAmbientColor: Color3;
  39784. protected _useLogarithmicDepth: boolean;
  39785. /**
  39786. * Instantiates a new standard material.
  39787. * This is the default material used in Babylon. It is the best trade off between quality
  39788. * and performances.
  39789. * @see http://doc.babylonjs.com/babylon101/materials
  39790. * @param name Define the name of the material in the scene
  39791. * @param scene Define the scene the material belong to
  39792. */
  39793. constructor(name: string, scene: Scene);
  39794. /**
  39795. * Gets a boolean indicating that current material needs to register RTT
  39796. */
  39797. readonly hasRenderTargetTextures: boolean;
  39798. /**
  39799. * Gets the current class name of the material e.g. "StandardMaterial"
  39800. * Mainly use in serialization.
  39801. * @returns the class name
  39802. */
  39803. getClassName(): string;
  39804. /**
  39805. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39806. * You can try switching to logarithmic depth.
  39807. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39808. */
  39809. useLogarithmicDepth: boolean;
  39810. /**
  39811. * Specifies if the material will require alpha blending
  39812. * @returns a boolean specifying if alpha blending is needed
  39813. */
  39814. needAlphaBlending(): boolean;
  39815. /**
  39816. * Specifies if this material should be rendered in alpha test mode
  39817. * @returns a boolean specifying if an alpha test is needed.
  39818. */
  39819. needAlphaTesting(): boolean;
  39820. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39821. /**
  39822. * Get the texture used for alpha test purpose.
  39823. * @returns the diffuse texture in case of the standard material.
  39824. */
  39825. getAlphaTestTexture(): Nullable<BaseTexture>;
  39826. /**
  39827. * Get if the submesh is ready to be used and all its information available.
  39828. * Child classes can use it to update shaders
  39829. * @param mesh defines the mesh to check
  39830. * @param subMesh defines which submesh to check
  39831. * @param useInstances specifies that instances should be used
  39832. * @returns a boolean indicating that the submesh is ready or not
  39833. */
  39834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39835. /**
  39836. * Builds the material UBO layouts.
  39837. * Used internally during the effect preparation.
  39838. */
  39839. buildUniformLayout(): void;
  39840. /**
  39841. * Unbinds the material from the mesh
  39842. */
  39843. unbind(): void;
  39844. /**
  39845. * Binds the submesh to this material by preparing the effect and shader to draw
  39846. * @param world defines the world transformation matrix
  39847. * @param mesh defines the mesh containing the submesh
  39848. * @param subMesh defines the submesh to bind the material to
  39849. */
  39850. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39851. /**
  39852. * Get the list of animatables in the material.
  39853. * @returns the list of animatables object used in the material
  39854. */
  39855. getAnimatables(): IAnimatable[];
  39856. /**
  39857. * Gets the active textures from the material
  39858. * @returns an array of textures
  39859. */
  39860. getActiveTextures(): BaseTexture[];
  39861. /**
  39862. * Specifies if the material uses a texture
  39863. * @param texture defines the texture to check against the material
  39864. * @returns a boolean specifying if the material uses the texture
  39865. */
  39866. hasTexture(texture: BaseTexture): boolean;
  39867. /**
  39868. * Disposes the material
  39869. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39870. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39871. */
  39872. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39873. /**
  39874. * Makes a duplicate of the material, and gives it a new name
  39875. * @param name defines the new name for the duplicated material
  39876. * @returns the cloned material
  39877. */
  39878. clone(name: string): StandardMaterial;
  39879. /**
  39880. * Serializes this material in a JSON representation
  39881. * @returns the serialized material object
  39882. */
  39883. serialize(): any;
  39884. /**
  39885. * Creates a standard material from parsed material data
  39886. * @param source defines the JSON representation of the material
  39887. * @param scene defines the hosting scene
  39888. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39889. * @returns a new standard material
  39890. */
  39891. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39892. /**
  39893. * Are diffuse textures enabled in the application.
  39894. */
  39895. static DiffuseTextureEnabled: boolean;
  39896. /**
  39897. * Are ambient textures enabled in the application.
  39898. */
  39899. static AmbientTextureEnabled: boolean;
  39900. /**
  39901. * Are opacity textures enabled in the application.
  39902. */
  39903. static OpacityTextureEnabled: boolean;
  39904. /**
  39905. * Are reflection textures enabled in the application.
  39906. */
  39907. static ReflectionTextureEnabled: boolean;
  39908. /**
  39909. * Are emissive textures enabled in the application.
  39910. */
  39911. static EmissiveTextureEnabled: boolean;
  39912. /**
  39913. * Are specular textures enabled in the application.
  39914. */
  39915. static SpecularTextureEnabled: boolean;
  39916. /**
  39917. * Are bump textures enabled in the application.
  39918. */
  39919. static BumpTextureEnabled: boolean;
  39920. /**
  39921. * Are lightmap textures enabled in the application.
  39922. */
  39923. static LightmapTextureEnabled: boolean;
  39924. /**
  39925. * Are refraction textures enabled in the application.
  39926. */
  39927. static RefractionTextureEnabled: boolean;
  39928. /**
  39929. * Are color grading textures enabled in the application.
  39930. */
  39931. static ColorGradingTextureEnabled: boolean;
  39932. /**
  39933. * Are fresnels enabled in the application.
  39934. */
  39935. static FresnelEnabled: boolean;
  39936. }
  39937. }
  39938. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39939. import { Scene } from "babylonjs/scene";
  39940. import { Texture } from "babylonjs/Materials/Textures/texture";
  39941. /**
  39942. * A class extending Texture allowing drawing on a texture
  39943. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39944. */
  39945. export class DynamicTexture extends Texture {
  39946. private _generateMipMaps;
  39947. private _canvas;
  39948. private _context;
  39949. private _engine;
  39950. /**
  39951. * Creates a DynamicTexture
  39952. * @param name defines the name of the texture
  39953. * @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
  39954. * @param scene defines the scene where you want the texture
  39955. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39956. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39957. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39958. */
  39959. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39960. /**
  39961. * Get the current class name of the texture useful for serialization or dynamic coding.
  39962. * @returns "DynamicTexture"
  39963. */
  39964. getClassName(): string;
  39965. /**
  39966. * Gets the current state of canRescale
  39967. */
  39968. readonly canRescale: boolean;
  39969. private _recreate;
  39970. /**
  39971. * Scales the texture
  39972. * @param ratio the scale factor to apply to both width and height
  39973. */
  39974. scale(ratio: number): void;
  39975. /**
  39976. * Resizes the texture
  39977. * @param width the new width
  39978. * @param height the new height
  39979. */
  39980. scaleTo(width: number, height: number): void;
  39981. /**
  39982. * Gets the context of the canvas used by the texture
  39983. * @returns the canvas context of the dynamic texture
  39984. */
  39985. getContext(): CanvasRenderingContext2D;
  39986. /**
  39987. * Clears the texture
  39988. */
  39989. clear(): void;
  39990. /**
  39991. * Updates the texture
  39992. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39993. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39994. */
  39995. update(invertY?: boolean, premulAlpha?: boolean): void;
  39996. /**
  39997. * Draws text onto the texture
  39998. * @param text defines the text to be drawn
  39999. * @param x defines the placement of the text from the left
  40000. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40001. * @param font defines the font to be used with font-style, font-size, font-name
  40002. * @param color defines the color used for the text
  40003. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40004. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40005. * @param update defines whether texture is immediately update (default is true)
  40006. */
  40007. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40008. /**
  40009. * Clones the texture
  40010. * @returns the clone of the texture.
  40011. */
  40012. clone(): DynamicTexture;
  40013. /**
  40014. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40015. * @returns a serialized dynamic texture object
  40016. */
  40017. serialize(): any;
  40018. /** @hidden */
  40019. _rebuild(): void;
  40020. }
  40021. }
  40022. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40023. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40024. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40025. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40026. /** @hidden */
  40027. export var imageProcessingPixelShader: {
  40028. name: string;
  40029. shader: string;
  40030. };
  40031. }
  40032. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40033. import { Nullable } from "babylonjs/types";
  40034. import { Color4 } from "babylonjs/Maths/math";
  40035. import { Camera } from "babylonjs/Cameras/camera";
  40036. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40037. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40038. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40040. import { Engine } from "babylonjs/Engines/engine";
  40041. import "babylonjs/Shaders/imageProcessing.fragment";
  40042. import "babylonjs/Shaders/postprocess.vertex";
  40043. /**
  40044. * ImageProcessingPostProcess
  40045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40046. */
  40047. export class ImageProcessingPostProcess extends PostProcess {
  40048. /**
  40049. * Default configuration related to image processing available in the PBR Material.
  40050. */
  40051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40052. /**
  40053. * Gets the image processing configuration used either in this material.
  40054. */
  40055. /**
  40056. * Sets the Default image processing configuration used either in the this material.
  40057. *
  40058. * If sets to null, the scene one is in use.
  40059. */
  40060. imageProcessingConfiguration: ImageProcessingConfiguration;
  40061. /**
  40062. * Keep track of the image processing observer to allow dispose and replace.
  40063. */
  40064. private _imageProcessingObserver;
  40065. /**
  40066. * Attaches a new image processing configuration to the PBR Material.
  40067. * @param configuration
  40068. */
  40069. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40070. /**
  40071. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40072. */
  40073. /**
  40074. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40075. */
  40076. colorCurves: Nullable<ColorCurves>;
  40077. /**
  40078. * Gets wether the color curves effect is enabled.
  40079. */
  40080. /**
  40081. * Sets wether the color curves effect is enabled.
  40082. */
  40083. colorCurvesEnabled: boolean;
  40084. /**
  40085. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40086. */
  40087. /**
  40088. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40089. */
  40090. colorGradingTexture: Nullable<BaseTexture>;
  40091. /**
  40092. * Gets wether the color grading effect is enabled.
  40093. */
  40094. /**
  40095. * Gets wether the color grading effect is enabled.
  40096. */
  40097. colorGradingEnabled: boolean;
  40098. /**
  40099. * Gets exposure used in the effect.
  40100. */
  40101. /**
  40102. * Sets exposure used in the effect.
  40103. */
  40104. exposure: number;
  40105. /**
  40106. * Gets wether tonemapping is enabled or not.
  40107. */
  40108. /**
  40109. * Sets wether tonemapping is enabled or not
  40110. */
  40111. toneMappingEnabled: boolean;
  40112. /**
  40113. * Gets the type of tone mapping effect.
  40114. */
  40115. /**
  40116. * Sets the type of tone mapping effect.
  40117. */
  40118. toneMappingType: number;
  40119. /**
  40120. * Gets contrast used in the effect.
  40121. */
  40122. /**
  40123. * Sets contrast used in the effect.
  40124. */
  40125. contrast: number;
  40126. /**
  40127. * Gets Vignette stretch size.
  40128. */
  40129. /**
  40130. * Sets Vignette stretch size.
  40131. */
  40132. vignetteStretch: number;
  40133. /**
  40134. * Gets Vignette centre X Offset.
  40135. */
  40136. /**
  40137. * Sets Vignette centre X Offset.
  40138. */
  40139. vignetteCentreX: number;
  40140. /**
  40141. * Gets Vignette centre Y Offset.
  40142. */
  40143. /**
  40144. * Sets Vignette centre Y Offset.
  40145. */
  40146. vignetteCentreY: number;
  40147. /**
  40148. * Gets Vignette weight or intensity of the vignette effect.
  40149. */
  40150. /**
  40151. * Sets Vignette weight or intensity of the vignette effect.
  40152. */
  40153. vignetteWeight: number;
  40154. /**
  40155. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40156. * if vignetteEnabled is set to true.
  40157. */
  40158. /**
  40159. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40160. * if vignetteEnabled is set to true.
  40161. */
  40162. vignetteColor: Color4;
  40163. /**
  40164. * Gets Camera field of view used by the Vignette effect.
  40165. */
  40166. /**
  40167. * Sets Camera field of view used by the Vignette effect.
  40168. */
  40169. vignetteCameraFov: number;
  40170. /**
  40171. * Gets the vignette blend mode allowing different kind of effect.
  40172. */
  40173. /**
  40174. * Sets the vignette blend mode allowing different kind of effect.
  40175. */
  40176. vignetteBlendMode: number;
  40177. /**
  40178. * Gets wether the vignette effect is enabled.
  40179. */
  40180. /**
  40181. * Sets wether the vignette effect is enabled.
  40182. */
  40183. vignetteEnabled: boolean;
  40184. private _fromLinearSpace;
  40185. /**
  40186. * Gets wether the input of the processing is in Gamma or Linear Space.
  40187. */
  40188. /**
  40189. * Sets wether the input of the processing is in Gamma or Linear Space.
  40190. */
  40191. fromLinearSpace: boolean;
  40192. /**
  40193. * Defines cache preventing GC.
  40194. */
  40195. private _defines;
  40196. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40197. /**
  40198. * "ImageProcessingPostProcess"
  40199. * @returns "ImageProcessingPostProcess"
  40200. */
  40201. getClassName(): string;
  40202. protected _updateParameters(): void;
  40203. dispose(camera?: Camera): void;
  40204. }
  40205. }
  40206. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40207. import { Scene } from "babylonjs/scene";
  40208. import { Color3 } from "babylonjs/Maths/math";
  40209. import { Mesh } from "babylonjs/Meshes/mesh";
  40210. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40211. /**
  40212. * Class containing static functions to help procedurally build meshes
  40213. */
  40214. export class GroundBuilder {
  40215. /**
  40216. * Creates a ground mesh
  40217. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40218. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40220. * @param name defines the name of the mesh
  40221. * @param options defines the options used to create the mesh
  40222. * @param scene defines the hosting scene
  40223. * @returns the ground mesh
  40224. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40225. */
  40226. static CreateGround(name: string, options: {
  40227. width?: number;
  40228. height?: number;
  40229. subdivisions?: number;
  40230. subdivisionsX?: number;
  40231. subdivisionsY?: number;
  40232. updatable?: boolean;
  40233. }, scene: any): Mesh;
  40234. /**
  40235. * Creates a tiled ground mesh
  40236. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40237. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40238. * * 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
  40239. * * 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
  40240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40241. * @param name defines the name of the mesh
  40242. * @param options defines the options used to create the mesh
  40243. * @param scene defines the hosting scene
  40244. * @returns the tiled ground mesh
  40245. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40246. */
  40247. static CreateTiledGround(name: string, options: {
  40248. xmin: number;
  40249. zmin: number;
  40250. xmax: number;
  40251. zmax: number;
  40252. subdivisions?: {
  40253. w: number;
  40254. h: number;
  40255. };
  40256. precision?: {
  40257. w: number;
  40258. h: number;
  40259. };
  40260. updatable?: boolean;
  40261. }, scene: Scene): Mesh;
  40262. /**
  40263. * Creates a ground mesh from a height map
  40264. * * The parameter `url` sets the URL of the height map image resource.
  40265. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40266. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40267. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40268. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40269. * * 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.
  40270. * * 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).
  40271. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40273. * @param name defines the name of the mesh
  40274. * @param url defines the url to the height map
  40275. * @param options defines the options used to create the mesh
  40276. * @param scene defines the hosting scene
  40277. * @returns the ground mesh
  40278. * @see https://doc.babylonjs.com/babylon101/height_map
  40279. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40280. */
  40281. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40282. width?: number;
  40283. height?: number;
  40284. subdivisions?: number;
  40285. minHeight?: number;
  40286. maxHeight?: number;
  40287. colorFilter?: Color3;
  40288. alphaFilter?: number;
  40289. updatable?: boolean;
  40290. onReady?: (mesh: GroundMesh) => void;
  40291. }, scene: Scene): GroundMesh;
  40292. }
  40293. }
  40294. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40295. import { Vector4 } from "babylonjs/Maths/math";
  40296. import { Mesh } from "babylonjs/Meshes/mesh";
  40297. /**
  40298. * Class containing static functions to help procedurally build meshes
  40299. */
  40300. export class TorusBuilder {
  40301. /**
  40302. * Creates a torus mesh
  40303. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40304. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40305. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40309. * @param name defines the name of the mesh
  40310. * @param options defines the options used to create the mesh
  40311. * @param scene defines the hosting scene
  40312. * @returns the torus mesh
  40313. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40314. */
  40315. static CreateTorus(name: string, options: {
  40316. diameter?: number;
  40317. thickness?: number;
  40318. tessellation?: number;
  40319. updatable?: boolean;
  40320. sideOrientation?: number;
  40321. frontUVs?: Vector4;
  40322. backUVs?: Vector4;
  40323. }, scene: any): Mesh;
  40324. }
  40325. }
  40326. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40327. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40328. import { Mesh } from "babylonjs/Meshes/mesh";
  40329. /**
  40330. * Class containing static functions to help procedurally build meshes
  40331. */
  40332. export class CylinderBuilder {
  40333. /**
  40334. * Creates a cylinder or a cone mesh
  40335. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40336. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40337. * * 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.
  40338. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40339. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40340. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40341. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40342. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40343. * * 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).
  40344. * * 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
  40345. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40346. * * 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
  40347. * * 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.
  40348. * * If `enclose` is false, a ring surface is one element.
  40349. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40350. * * 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
  40351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40354. * @param name defines the name of the mesh
  40355. * @param options defines the options used to create the mesh
  40356. * @param scene defines the hosting scene
  40357. * @returns the cylinder mesh
  40358. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40359. */
  40360. static CreateCylinder(name: string, options: {
  40361. height?: number;
  40362. diameterTop?: number;
  40363. diameterBottom?: number;
  40364. diameter?: number;
  40365. tessellation?: number;
  40366. subdivisions?: number;
  40367. arc?: number;
  40368. faceColors?: Color4[];
  40369. faceUV?: Vector4[];
  40370. updatable?: boolean;
  40371. hasRings?: boolean;
  40372. enclose?: boolean;
  40373. sideOrientation?: number;
  40374. frontUVs?: Vector4;
  40375. backUVs?: Vector4;
  40376. }, scene: any): Mesh;
  40377. }
  40378. }
  40379. declare module "babylonjs/Gamepads/gamepadManager" {
  40380. import { Observable } from "babylonjs/Misc/observable";
  40381. import { Nullable } from "babylonjs/types";
  40382. import { Scene } from "babylonjs/scene";
  40383. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40384. /**
  40385. * Manager for handling gamepads
  40386. */
  40387. export class GamepadManager {
  40388. private _scene?;
  40389. private _babylonGamepads;
  40390. private _oneGamepadConnected;
  40391. /** @hidden */
  40392. _isMonitoring: boolean;
  40393. private _gamepadEventSupported;
  40394. private _gamepadSupport;
  40395. /**
  40396. * observable to be triggered when the gamepad controller has been connected
  40397. */
  40398. onGamepadConnectedObservable: Observable<Gamepad>;
  40399. /**
  40400. * observable to be triggered when the gamepad controller has been disconnected
  40401. */
  40402. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40403. private _onGamepadConnectedEvent;
  40404. private _onGamepadDisconnectedEvent;
  40405. /**
  40406. * Initializes the gamepad manager
  40407. * @param _scene BabylonJS scene
  40408. */
  40409. constructor(_scene?: Scene | undefined);
  40410. /**
  40411. * The gamepads in the game pad manager
  40412. */
  40413. readonly gamepads: Gamepad[];
  40414. /**
  40415. * Get the gamepad controllers based on type
  40416. * @param type The type of gamepad controller
  40417. * @returns Nullable gamepad
  40418. */
  40419. getGamepadByType(type?: number): Nullable<Gamepad>;
  40420. /**
  40421. * Disposes the gamepad manager
  40422. */
  40423. dispose(): void;
  40424. private _addNewGamepad;
  40425. private _startMonitoringGamepads;
  40426. private _stopMonitoringGamepads;
  40427. /** @hidden */
  40428. _checkGamepadsStatus(): void;
  40429. private _updateGamepadObjects;
  40430. }
  40431. }
  40432. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40433. import { Nullable } from "babylonjs/types";
  40434. import { Scene } from "babylonjs/scene";
  40435. import { ISceneComponent } from "babylonjs/sceneComponent";
  40436. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40437. module "babylonjs/scene" {
  40438. interface Scene {
  40439. /** @hidden */
  40440. _gamepadManager: Nullable<GamepadManager>;
  40441. /**
  40442. * Gets the gamepad manager associated with the scene
  40443. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40444. */
  40445. gamepadManager: GamepadManager;
  40446. }
  40447. }
  40448. module "babylonjs/Cameras/freeCameraInputsManager" {
  40449. /**
  40450. * Interface representing a free camera inputs manager
  40451. */
  40452. interface FreeCameraInputsManager {
  40453. /**
  40454. * Adds gamepad input support to the FreeCameraInputsManager.
  40455. * @returns the FreeCameraInputsManager
  40456. */
  40457. addGamepad(): FreeCameraInputsManager;
  40458. }
  40459. }
  40460. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40461. /**
  40462. * Interface representing an arc rotate camera inputs manager
  40463. */
  40464. interface ArcRotateCameraInputsManager {
  40465. /**
  40466. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40467. * @returns the camera inputs manager
  40468. */
  40469. addGamepad(): ArcRotateCameraInputsManager;
  40470. }
  40471. }
  40472. /**
  40473. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40474. */
  40475. export class GamepadSystemSceneComponent implements ISceneComponent {
  40476. /**
  40477. * The component name helpfull to identify the component in the list of scene components.
  40478. */
  40479. readonly name: string;
  40480. /**
  40481. * The scene the component belongs to.
  40482. */
  40483. scene: Scene;
  40484. /**
  40485. * Creates a new instance of the component for the given scene
  40486. * @param scene Defines the scene to register the component in
  40487. */
  40488. constructor(scene: Scene);
  40489. /**
  40490. * Registers the component in a given scene
  40491. */
  40492. register(): void;
  40493. /**
  40494. * Rebuilds the elements related to this component in case of
  40495. * context lost for instance.
  40496. */
  40497. rebuild(): void;
  40498. /**
  40499. * Disposes the component and the associated ressources
  40500. */
  40501. dispose(): void;
  40502. private _beforeCameraUpdate;
  40503. }
  40504. }
  40505. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40506. import { Observable } from "babylonjs/Misc/observable";
  40507. import { Nullable } from "babylonjs/types";
  40508. import { Camera } from "babylonjs/Cameras/camera";
  40509. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40510. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40511. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40512. import { Scene } from "babylonjs/scene";
  40513. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40514. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40516. import { Mesh } from "babylonjs/Meshes/mesh";
  40517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40518. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40519. import "babylonjs/Meshes/Builders/groundBuilder";
  40520. import "babylonjs/Meshes/Builders/torusBuilder";
  40521. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40522. import "babylonjs/Gamepads/gamepadSceneComponent";
  40523. import "babylonjs/Animations/animatable";
  40524. /**
  40525. * Options to modify the vr teleportation behavior.
  40526. */
  40527. export interface VRTeleportationOptions {
  40528. /**
  40529. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40530. */
  40531. floorMeshName?: string;
  40532. /**
  40533. * A list of meshes to be used as the teleportation floor. (default: empty)
  40534. */
  40535. floorMeshes?: Mesh[];
  40536. }
  40537. /**
  40538. * Options to modify the vr experience helper's behavior.
  40539. */
  40540. export interface VRExperienceHelperOptions extends WebVROptions {
  40541. /**
  40542. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40543. */
  40544. createDeviceOrientationCamera?: boolean;
  40545. /**
  40546. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40547. */
  40548. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40549. /**
  40550. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40551. */
  40552. laserToggle?: boolean;
  40553. /**
  40554. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40555. */
  40556. floorMeshes?: Mesh[];
  40557. /**
  40558. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40559. */
  40560. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40561. }
  40562. /**
  40563. * Event containing information after VR has been entered
  40564. */
  40565. export class OnAfterEnteringVRObservableEvent {
  40566. /**
  40567. * If entering vr was successful
  40568. */
  40569. success: boolean;
  40570. }
  40571. /**
  40572. * Helps to quickly add VR support to an existing scene.
  40573. * See http://doc.babylonjs.com/how_to/webvr_helper
  40574. */
  40575. export class VRExperienceHelper {
  40576. /** Options to modify the vr experience helper's behavior. */
  40577. webVROptions: VRExperienceHelperOptions;
  40578. private _scene;
  40579. private _position;
  40580. private _btnVR;
  40581. private _btnVRDisplayed;
  40582. private _webVRsupported;
  40583. private _webVRready;
  40584. private _webVRrequesting;
  40585. private _webVRpresenting;
  40586. private _hasEnteredVR;
  40587. private _fullscreenVRpresenting;
  40588. private _canvas;
  40589. private _webVRCamera;
  40590. private _vrDeviceOrientationCamera;
  40591. private _deviceOrientationCamera;
  40592. private _existingCamera;
  40593. private _onKeyDown;
  40594. private _onVrDisplayPresentChange;
  40595. private _onVRDisplayChanged;
  40596. private _onVRRequestPresentStart;
  40597. private _onVRRequestPresentComplete;
  40598. /**
  40599. * Observable raised right before entering VR.
  40600. */
  40601. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40602. /**
  40603. * Observable raised when entering VR has completed.
  40604. */
  40605. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40606. /**
  40607. * Observable raised when exiting VR.
  40608. */
  40609. onExitingVRObservable: Observable<VRExperienceHelper>;
  40610. /**
  40611. * Observable raised when controller mesh is loaded.
  40612. */
  40613. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40614. /** Return this.onEnteringVRObservable
  40615. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40616. */
  40617. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40618. /** Return this.onExitingVRObservable
  40619. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40620. */
  40621. readonly onExitingVR: Observable<VRExperienceHelper>;
  40622. /** Return this.onControllerMeshLoadedObservable
  40623. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40624. */
  40625. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40626. private _rayLength;
  40627. private _useCustomVRButton;
  40628. private _teleportationRequested;
  40629. private _teleportActive;
  40630. private _floorMeshName;
  40631. private _floorMeshesCollection;
  40632. private _rotationAllowed;
  40633. private _teleportBackwardsVector;
  40634. private _teleportationTarget;
  40635. private _isDefaultTeleportationTarget;
  40636. private _postProcessMove;
  40637. private _teleportationFillColor;
  40638. private _teleportationBorderColor;
  40639. private _rotationAngle;
  40640. private _haloCenter;
  40641. private _cameraGazer;
  40642. private _padSensibilityUp;
  40643. private _padSensibilityDown;
  40644. private _leftController;
  40645. private _rightController;
  40646. /**
  40647. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40648. */
  40649. onNewMeshSelected: Observable<AbstractMesh>;
  40650. /**
  40651. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40652. */
  40653. onNewMeshPicked: Observable<PickingInfo>;
  40654. private _circleEase;
  40655. /**
  40656. * Observable raised before camera teleportation
  40657. */
  40658. onBeforeCameraTeleport: Observable<Vector3>;
  40659. /**
  40660. * Observable raised after camera teleportation
  40661. */
  40662. onAfterCameraTeleport: Observable<Vector3>;
  40663. /**
  40664. * Observable raised when current selected mesh gets unselected
  40665. */
  40666. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40667. private _raySelectionPredicate;
  40668. /**
  40669. * To be optionaly changed by user to define custom ray selection
  40670. */
  40671. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40672. /**
  40673. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40674. */
  40675. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40676. /**
  40677. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40678. */
  40679. teleportationEnabled: boolean;
  40680. private _defaultHeight;
  40681. private _teleportationInitialized;
  40682. private _interactionsEnabled;
  40683. private _interactionsRequested;
  40684. private _displayGaze;
  40685. private _displayLaserPointer;
  40686. /**
  40687. * The mesh used to display where the user is going to teleport.
  40688. */
  40689. /**
  40690. * Sets the mesh to be used to display where the user is going to teleport.
  40691. */
  40692. teleportationTarget: Mesh;
  40693. /**
  40694. * 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
  40695. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40696. * See http://doc.babylonjs.com/resources/baking_transformations
  40697. */
  40698. gazeTrackerMesh: Mesh;
  40699. /**
  40700. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40701. */
  40702. updateGazeTrackerScale: boolean;
  40703. /**
  40704. * If the gaze trackers color should be updated when selecting meshes
  40705. */
  40706. updateGazeTrackerColor: boolean;
  40707. /**
  40708. * The gaze tracking mesh corresponding to the left controller
  40709. */
  40710. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40711. /**
  40712. * The gaze tracking mesh corresponding to the right controller
  40713. */
  40714. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40715. /**
  40716. * If the ray of the gaze should be displayed.
  40717. */
  40718. /**
  40719. * Sets if the ray of the gaze should be displayed.
  40720. */
  40721. displayGaze: boolean;
  40722. /**
  40723. * If the ray of the LaserPointer should be displayed.
  40724. */
  40725. /**
  40726. * Sets if the ray of the LaserPointer should be displayed.
  40727. */
  40728. displayLaserPointer: boolean;
  40729. /**
  40730. * The deviceOrientationCamera used as the camera when not in VR.
  40731. */
  40732. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40733. /**
  40734. * Based on the current WebVR support, returns the current VR camera used.
  40735. */
  40736. readonly currentVRCamera: Nullable<Camera>;
  40737. /**
  40738. * The webVRCamera which is used when in VR.
  40739. */
  40740. readonly webVRCamera: WebVRFreeCamera;
  40741. /**
  40742. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40743. */
  40744. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40745. private readonly _teleportationRequestInitiated;
  40746. /**
  40747. * Defines wether or not Pointer lock should be requested when switching to
  40748. * full screen.
  40749. */
  40750. requestPointerLockOnFullScreen: boolean;
  40751. /**
  40752. * Instantiates a VRExperienceHelper.
  40753. * Helps to quickly add VR support to an existing scene.
  40754. * @param scene The scene the VRExperienceHelper belongs to.
  40755. * @param webVROptions Options to modify the vr experience helper's behavior.
  40756. */
  40757. constructor(scene: Scene,
  40758. /** Options to modify the vr experience helper's behavior. */
  40759. webVROptions?: VRExperienceHelperOptions);
  40760. private _onDefaultMeshLoaded;
  40761. private _onResize;
  40762. private _onFullscreenChange;
  40763. /**
  40764. * Gets a value indicating if we are currently in VR mode.
  40765. */
  40766. readonly isInVRMode: boolean;
  40767. private onVrDisplayPresentChange;
  40768. private onVRDisplayChanged;
  40769. private moveButtonToBottomRight;
  40770. private displayVRButton;
  40771. private updateButtonVisibility;
  40772. private _cachedAngularSensibility;
  40773. /**
  40774. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40775. * Otherwise, will use the fullscreen API.
  40776. */
  40777. enterVR(): void;
  40778. /**
  40779. * Attempt to exit VR, or fullscreen.
  40780. */
  40781. exitVR(): void;
  40782. /**
  40783. * The position of the vr experience helper.
  40784. */
  40785. /**
  40786. * Sets the position of the vr experience helper.
  40787. */
  40788. position: Vector3;
  40789. /**
  40790. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40791. */
  40792. enableInteractions(): void;
  40793. private readonly _noControllerIsActive;
  40794. private beforeRender;
  40795. private _isTeleportationFloor;
  40796. /**
  40797. * Adds a floor mesh to be used for teleportation.
  40798. * @param floorMesh the mesh to be used for teleportation.
  40799. */
  40800. addFloorMesh(floorMesh: Mesh): void;
  40801. /**
  40802. * Removes a floor mesh from being used for teleportation.
  40803. * @param floorMesh the mesh to be removed.
  40804. */
  40805. removeFloorMesh(floorMesh: Mesh): void;
  40806. /**
  40807. * Enables interactions and teleportation using the VR controllers and gaze.
  40808. * @param vrTeleportationOptions options to modify teleportation behavior.
  40809. */
  40810. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40811. private _onNewGamepadConnected;
  40812. private _tryEnableInteractionOnController;
  40813. private _onNewGamepadDisconnected;
  40814. private _enableInteractionOnController;
  40815. private _checkTeleportWithRay;
  40816. private _checkRotate;
  40817. private _checkTeleportBackwards;
  40818. private _enableTeleportationOnController;
  40819. private _createTeleportationCircles;
  40820. private _displayTeleportationTarget;
  40821. private _hideTeleportationTarget;
  40822. private _rotateCamera;
  40823. private _moveTeleportationSelectorTo;
  40824. private _workingVector;
  40825. private _workingQuaternion;
  40826. private _workingMatrix;
  40827. /**
  40828. * Teleports the users feet to the desired location
  40829. * @param location The location where the user's feet should be placed
  40830. */
  40831. teleportCamera(location: Vector3): void;
  40832. private _convertNormalToDirectionOfRay;
  40833. private _castRayAndSelectObject;
  40834. private _notifySelectedMeshUnselected;
  40835. /**
  40836. * Sets the color of the laser ray from the vr controllers.
  40837. * @param color new color for the ray.
  40838. */
  40839. changeLaserColor(color: Color3): void;
  40840. /**
  40841. * Sets the color of the ray from the vr headsets gaze.
  40842. * @param color new color for the ray.
  40843. */
  40844. changeGazeColor(color: Color3): void;
  40845. /**
  40846. * Exits VR and disposes of the vr experience helper
  40847. */
  40848. dispose(): void;
  40849. /**
  40850. * Gets the name of the VRExperienceHelper class
  40851. * @returns "VRExperienceHelper"
  40852. */
  40853. getClassName(): string;
  40854. }
  40855. }
  40856. declare module "babylonjs/Cameras/VR/index" {
  40857. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40858. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40859. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40860. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40861. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40862. export * from "babylonjs/Cameras/VR/webVRCamera";
  40863. }
  40864. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40865. import { Observable } from "babylonjs/Misc/observable";
  40866. import { Nullable } from "babylonjs/types";
  40867. import { IDisposable, Scene } from "babylonjs/scene";
  40868. import { Vector3 } from "babylonjs/Maths/math";
  40869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40870. import { Ray } from "babylonjs/Culling/ray";
  40871. /**
  40872. * Manages an XRSession
  40873. * @see https://doc.babylonjs.com/how_to/webxr
  40874. */
  40875. export class WebXRSessionManager implements IDisposable {
  40876. private scene;
  40877. /**
  40878. * Fires every time a new xrFrame arrives which can be used to update the camera
  40879. */
  40880. onXRFrameObservable: Observable<any>;
  40881. /**
  40882. * Fires when the xr session is ended either by the device or manually done
  40883. */
  40884. onXRSessionEnded: Observable<any>;
  40885. /** @hidden */
  40886. _xrSession: XRSession;
  40887. /** @hidden */
  40888. _frameOfReference: XRFrameOfReference;
  40889. /** @hidden */
  40890. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40891. /** @hidden */
  40892. _currentXRFrame: Nullable<XRFrame>;
  40893. private _xrNavigator;
  40894. private _xrDevice;
  40895. private _tmpMatrix;
  40896. /**
  40897. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40898. * @param scene The scene which the session should be created for
  40899. */
  40900. constructor(scene: Scene);
  40901. /**
  40902. * Initializes the manager
  40903. * After initialization enterXR can be called to start an XR session
  40904. * @returns Promise which resolves after it is initialized
  40905. */
  40906. initializeAsync(): Promise<void>;
  40907. /**
  40908. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40909. * @param sessionCreationOptions xr options to create the session with
  40910. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40911. * @returns Promise which resolves after it enters XR
  40912. */
  40913. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40914. /**
  40915. * Stops the xrSession and restores the renderloop
  40916. * @returns Promise which resolves after it exits XR
  40917. */
  40918. exitXRAsync(): Promise<void>;
  40919. /**
  40920. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40921. * @param ray ray to cast into the environment
  40922. * @returns Promise which resolves with a collision point in the environment if it exists
  40923. */
  40924. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40925. /**
  40926. * Checks if a session would be supported for the creation options specified
  40927. * @param options creation options to check if they are supported
  40928. * @returns true if supported
  40929. */
  40930. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40931. /**
  40932. * @hidden
  40933. * Converts the render layer of xrSession to a render target
  40934. * @param session session to create render target for
  40935. * @param scene scene the new render target should be created for
  40936. */
  40937. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40938. /**
  40939. * Disposes of the session manager
  40940. */
  40941. dispose(): void;
  40942. }
  40943. }
  40944. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40945. import { Scene } from "babylonjs/scene";
  40946. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40947. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40948. /**
  40949. * WebXR Camera which holds the views for the xrSession
  40950. * @see https://doc.babylonjs.com/how_to/webxr
  40951. */
  40952. export class WebXRCamera extends FreeCamera {
  40953. private static _TmpMatrix;
  40954. /**
  40955. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40956. * @param name the name of the camera
  40957. * @param scene the scene to add the camera to
  40958. */
  40959. constructor(name: string, scene: Scene);
  40960. private _updateNumberOfRigCameras;
  40961. /** @hidden */
  40962. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40963. /**
  40964. * Updates the cameras position from the current pose information of the XR session
  40965. * @param xrSessionManager the session containing pose information
  40966. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40967. */
  40968. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40969. }
  40970. }
  40971. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40972. import { Nullable } from "babylonjs/types";
  40973. import { Observable } from "babylonjs/Misc/observable";
  40974. import { IDisposable, Scene } from "babylonjs/scene";
  40975. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40977. import { Ray } from "babylonjs/Culling/ray";
  40978. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40979. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40980. /**
  40981. * States of the webXR experience
  40982. */
  40983. export enum WebXRState {
  40984. /**
  40985. * Transitioning to being in XR mode
  40986. */
  40987. ENTERING_XR = 0,
  40988. /**
  40989. * Transitioning to non XR mode
  40990. */
  40991. EXITING_XR = 1,
  40992. /**
  40993. * In XR mode and presenting
  40994. */
  40995. IN_XR = 2,
  40996. /**
  40997. * Not entered XR mode
  40998. */
  40999. NOT_IN_XR = 3
  41000. }
  41001. /**
  41002. * Helper class used to enable XR
  41003. * @see https://doc.babylonjs.com/how_to/webxr
  41004. */
  41005. export class WebXRExperienceHelper implements IDisposable {
  41006. private scene;
  41007. /**
  41008. * 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
  41009. */
  41010. container: AbstractMesh;
  41011. /**
  41012. * Camera used to render xr content
  41013. */
  41014. camera: WebXRCamera;
  41015. /**
  41016. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41017. */
  41018. state: WebXRState;
  41019. private _setState;
  41020. private static _TmpVector;
  41021. /**
  41022. * Fires when the state of the experience helper has changed
  41023. */
  41024. onStateChangedObservable: Observable<WebXRState>;
  41025. /** @hidden */
  41026. _sessionManager: WebXRSessionManager;
  41027. private _nonVRCamera;
  41028. private _originalSceneAutoClear;
  41029. private _supported;
  41030. /**
  41031. * Creates the experience helper
  41032. * @param scene the scene to attach the experience helper to
  41033. * @returns a promise for the experience helper
  41034. */
  41035. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41036. /**
  41037. * Creates a WebXRExperienceHelper
  41038. * @param scene The scene the helper should be created in
  41039. */
  41040. private constructor();
  41041. /**
  41042. * Exits XR mode and returns the scene to its original state
  41043. * @returns promise that resolves after xr mode has exited
  41044. */
  41045. exitXRAsync(): Promise<void>;
  41046. /**
  41047. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41048. * @param sessionCreationOptions options for the XR session
  41049. * @param frameOfReference frame of reference of the XR session
  41050. * @returns promise that resolves after xr mode has entered
  41051. */
  41052. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41053. /**
  41054. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41055. * @param ray ray to cast into the environment
  41056. * @returns Promise which resolves with a collision point in the environment if it exists
  41057. */
  41058. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41059. /**
  41060. * Updates the global position of the camera by moving the camera's container
  41061. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41062. * @param position The desired global position of the camera
  41063. */
  41064. setPositionOfCameraUsingContainer(position: Vector3): void;
  41065. /**
  41066. * Rotates the xr camera by rotating the camera's container around the camera's position
  41067. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41068. * @param rotation the desired quaternion rotation to apply to the camera
  41069. */
  41070. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41071. /**
  41072. * Checks if the creation options are supported by the xr session
  41073. * @param options creation options
  41074. * @returns true if supported
  41075. */
  41076. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41077. /**
  41078. * Disposes of the experience helper
  41079. */
  41080. dispose(): void;
  41081. }
  41082. }
  41083. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41084. import { Nullable } from "babylonjs/types";
  41085. import { Observable } from "babylonjs/Misc/observable";
  41086. import { IDisposable, Scene } from "babylonjs/scene";
  41087. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41088. /**
  41089. * Button which can be used to enter a different mode of XR
  41090. */
  41091. export class WebXREnterExitUIButton {
  41092. /** button element */
  41093. element: HTMLElement;
  41094. /** XR initialization options for the button */
  41095. initializationOptions: XRSessionCreationOptions;
  41096. /**
  41097. * Creates a WebXREnterExitUIButton
  41098. * @param element button element
  41099. * @param initializationOptions XR initialization options for the button
  41100. */
  41101. constructor(
  41102. /** button element */
  41103. element: HTMLElement,
  41104. /** XR initialization options for the button */
  41105. initializationOptions: XRSessionCreationOptions);
  41106. /**
  41107. * Overwritable function which can be used to update the button's visuals when the state changes
  41108. * @param activeButton the current active button in the UI
  41109. */
  41110. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41111. }
  41112. /**
  41113. * Options to create the webXR UI
  41114. */
  41115. export class WebXREnterExitUIOptions {
  41116. /**
  41117. * Context to enter xr with
  41118. */
  41119. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41120. /**
  41121. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41122. */
  41123. customButtons?: Array<WebXREnterExitUIButton>;
  41124. }
  41125. /**
  41126. * UI to allow the user to enter/exit XR mode
  41127. */
  41128. export class WebXREnterExitUI implements IDisposable {
  41129. private scene;
  41130. private _overlay;
  41131. private _buttons;
  41132. private _activeButton;
  41133. /**
  41134. * Fired every time the active button is changed.
  41135. *
  41136. * When xr is entered via a button that launches xr that button will be the callback parameter
  41137. *
  41138. * When exiting xr the callback parameter will be null)
  41139. */
  41140. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41141. /**
  41142. * Creates UI to allow the user to enter/exit XR mode
  41143. * @param scene the scene to add the ui to
  41144. * @param helper the xr experience helper to enter/exit xr with
  41145. * @param options options to configure the UI
  41146. * @returns the created ui
  41147. */
  41148. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41149. private constructor();
  41150. private _updateButtons;
  41151. /**
  41152. * Disposes of the object
  41153. */
  41154. dispose(): void;
  41155. }
  41156. }
  41157. declare module "babylonjs/Cameras/XR/webXRInput" {
  41158. import { IDisposable, Scene } from "babylonjs/scene";
  41159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41160. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41161. /**
  41162. * Represents an XR input
  41163. */
  41164. export class WebXRController {
  41165. /**
  41166. * 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
  41167. */
  41168. grip?: AbstractMesh;
  41169. /**
  41170. * Pointer which can be used to select objects or attach a visible laser to
  41171. */
  41172. pointer: AbstractMesh;
  41173. /**
  41174. * Creates the controller
  41175. * @see https://doc.babylonjs.com/how_to/webxr
  41176. * @param scene the scene which the controller should be associated to
  41177. */
  41178. constructor(scene: Scene);
  41179. /**
  41180. * Disposes of the object
  41181. */
  41182. dispose(): void;
  41183. }
  41184. /**
  41185. * XR input used to track XR inputs such as controllers/rays
  41186. */
  41187. export class WebXRInput implements IDisposable {
  41188. private helper;
  41189. /**
  41190. * XR controllers being tracked
  41191. */
  41192. controllers: Array<WebXRController>;
  41193. private _tmpMatrix;
  41194. private _frameObserver;
  41195. /**
  41196. * Initializes the WebXRInput
  41197. * @param helper experience helper which the input should be created for
  41198. */
  41199. constructor(helper: WebXRExperienceHelper);
  41200. /**
  41201. * Disposes of the object
  41202. */
  41203. dispose(): void;
  41204. }
  41205. }
  41206. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41207. import { Nullable } from "babylonjs/types";
  41208. import { IDisposable } from "babylonjs/scene";
  41209. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41210. /**
  41211. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41212. */
  41213. export class WebXRManagedOutputCanvas implements IDisposable {
  41214. private _canvas;
  41215. /**
  41216. * xrpresent context of the canvas which can be used to display/mirror xr content
  41217. */
  41218. canvasContext: Nullable<WebGLRenderingContext>;
  41219. /**
  41220. * Initializes the canvas to be added/removed upon entering/exiting xr
  41221. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41222. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41223. */
  41224. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41225. /**
  41226. * Disposes of the object
  41227. */
  41228. dispose(): void;
  41229. private _setManagedOutputCanvas;
  41230. private _addCanvas;
  41231. private _removeCanvas;
  41232. }
  41233. }
  41234. declare module "babylonjs/Cameras/XR/index" {
  41235. export * from "babylonjs/Cameras/XR/webXRCamera";
  41236. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41237. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41238. export * from "babylonjs/Cameras/XR/webXRInput";
  41239. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41240. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41241. }
  41242. declare module "babylonjs/Cameras/RigModes/index" {
  41243. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41244. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41245. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41246. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41247. }
  41248. declare module "babylonjs/Cameras/index" {
  41249. export * from "babylonjs/Cameras/Inputs/index";
  41250. export * from "babylonjs/Cameras/cameraInputsManager";
  41251. export * from "babylonjs/Cameras/camera";
  41252. export * from "babylonjs/Cameras/targetCamera";
  41253. export * from "babylonjs/Cameras/freeCamera";
  41254. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41255. export * from "babylonjs/Cameras/touchCamera";
  41256. export * from "babylonjs/Cameras/arcRotateCamera";
  41257. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41258. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41259. export * from "babylonjs/Cameras/flyCamera";
  41260. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41261. export * from "babylonjs/Cameras/followCamera";
  41262. export * from "babylonjs/Cameras/gamepadCamera";
  41263. export * from "babylonjs/Cameras/Stereoscopic/index";
  41264. export * from "babylonjs/Cameras/universalCamera";
  41265. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41266. export * from "babylonjs/Cameras/VR/index";
  41267. export * from "babylonjs/Cameras/XR/index";
  41268. export * from "babylonjs/Cameras/RigModes/index";
  41269. }
  41270. declare module "babylonjs/Collisions/index" {
  41271. export * from "babylonjs/Collisions/collider";
  41272. export * from "babylonjs/Collisions/collisionCoordinator";
  41273. export * from "babylonjs/Collisions/pickingInfo";
  41274. export * from "babylonjs/Collisions/intersectionInfo";
  41275. }
  41276. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41277. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41278. import { Vector3, Plane } from "babylonjs/Maths/math";
  41279. import { Ray } from "babylonjs/Culling/ray";
  41280. /**
  41281. * Contains an array of blocks representing the octree
  41282. */
  41283. export interface IOctreeContainer<T> {
  41284. /**
  41285. * Blocks within the octree
  41286. */
  41287. blocks: Array<OctreeBlock<T>>;
  41288. }
  41289. /**
  41290. * Class used to store a cell in an octree
  41291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41292. */
  41293. export class OctreeBlock<T> {
  41294. /**
  41295. * Gets the content of the current block
  41296. */
  41297. entries: T[];
  41298. /**
  41299. * Gets the list of block children
  41300. */
  41301. blocks: Array<OctreeBlock<T>>;
  41302. private _depth;
  41303. private _maxDepth;
  41304. private _capacity;
  41305. private _minPoint;
  41306. private _maxPoint;
  41307. private _boundingVectors;
  41308. private _creationFunc;
  41309. /**
  41310. * Creates a new block
  41311. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41312. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41313. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41314. * @param depth defines the current depth of this block in the octree
  41315. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41316. * @param creationFunc defines a callback to call when an element is added to the block
  41317. */
  41318. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41319. /**
  41320. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41321. */
  41322. readonly capacity: number;
  41323. /**
  41324. * Gets the minimum vector (in world space) of the block's bounding box
  41325. */
  41326. readonly minPoint: Vector3;
  41327. /**
  41328. * Gets the maximum vector (in world space) of the block's bounding box
  41329. */
  41330. readonly maxPoint: Vector3;
  41331. /**
  41332. * Add a new element to this block
  41333. * @param entry defines the element to add
  41334. */
  41335. addEntry(entry: T): void;
  41336. /**
  41337. * Remove an element from this block
  41338. * @param entry defines the element to remove
  41339. */
  41340. removeEntry(entry: T): void;
  41341. /**
  41342. * Add an array of elements to this block
  41343. * @param entries defines the array of elements to add
  41344. */
  41345. addEntries(entries: T[]): void;
  41346. /**
  41347. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41348. * @param frustumPlanes defines the frustum planes to test
  41349. * @param selection defines the array to store current content if selection is positive
  41350. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41351. */
  41352. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41353. /**
  41354. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41355. * @param sphereCenter defines the bounding sphere center
  41356. * @param sphereRadius defines the bounding sphere radius
  41357. * @param selection defines the array to store current content if selection is positive
  41358. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41359. */
  41360. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41361. /**
  41362. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41363. * @param ray defines the ray to test with
  41364. * @param selection defines the array to store current content if selection is positive
  41365. */
  41366. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41367. /**
  41368. * Subdivide the content into child blocks (this block will then be empty)
  41369. */
  41370. createInnerBlocks(): void;
  41371. /**
  41372. * @hidden
  41373. */
  41374. 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;
  41375. }
  41376. }
  41377. declare module "babylonjs/Culling/Octrees/octree" {
  41378. import { SmartArray } from "babylonjs/Misc/smartArray";
  41379. import { Vector3, Plane } from "babylonjs/Maths/math";
  41380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41382. import { Ray } from "babylonjs/Culling/ray";
  41383. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41384. /**
  41385. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41386. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41387. */
  41388. export class Octree<T> {
  41389. /** 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.) */
  41390. maxDepth: number;
  41391. /**
  41392. * Blocks within the octree containing objects
  41393. */
  41394. blocks: Array<OctreeBlock<T>>;
  41395. /**
  41396. * Content stored in the octree
  41397. */
  41398. dynamicContent: T[];
  41399. private _maxBlockCapacity;
  41400. private _selectionContent;
  41401. private _creationFunc;
  41402. /**
  41403. * Creates a octree
  41404. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41405. * @param creationFunc function to be used to instatiate the octree
  41406. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41407. * @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.)
  41408. */
  41409. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41410. /** 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.) */
  41411. maxDepth?: number);
  41412. /**
  41413. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41414. * @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);
  41415. * @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);
  41416. * @param entries meshes to be added to the octree blocks
  41417. */
  41418. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41419. /**
  41420. * Adds a mesh to the octree
  41421. * @param entry Mesh to add to the octree
  41422. */
  41423. addMesh(entry: T): void;
  41424. /**
  41425. * Remove an element from the octree
  41426. * @param entry defines the element to remove
  41427. */
  41428. removeMesh(entry: T): void;
  41429. /**
  41430. * Selects an array of meshes within the frustum
  41431. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41432. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41433. * @returns array of meshes within the frustum
  41434. */
  41435. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41436. /**
  41437. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41438. * @param sphereCenter defines the bounding sphere center
  41439. * @param sphereRadius defines the bounding sphere radius
  41440. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41441. * @returns an array of objects that intersect the sphere
  41442. */
  41443. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41444. /**
  41445. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41446. * @param ray defines the ray to test with
  41447. * @returns array of intersected objects
  41448. */
  41449. intersectsRay(ray: Ray): SmartArray<T>;
  41450. /**
  41451. * Adds a mesh into the octree block if it intersects the block
  41452. */
  41453. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41454. /**
  41455. * Adds a submesh into the octree block if it intersects the block
  41456. */
  41457. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41458. }
  41459. }
  41460. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41461. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41462. import { Scene } from "babylonjs/scene";
  41463. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41465. import { Ray } from "babylonjs/Culling/ray";
  41466. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41467. import { Collider } from "babylonjs/Collisions/collider";
  41468. module "babylonjs/scene" {
  41469. interface Scene {
  41470. /**
  41471. * @hidden
  41472. * Backing Filed
  41473. */
  41474. _selectionOctree: Octree<AbstractMesh>;
  41475. /**
  41476. * Gets the octree used to boost mesh selection (picking)
  41477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41478. */
  41479. selectionOctree: Octree<AbstractMesh>;
  41480. /**
  41481. * Creates or updates the octree used to boost selection (picking)
  41482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41483. * @param maxCapacity defines the maximum capacity per leaf
  41484. * @param maxDepth defines the maximum depth of the octree
  41485. * @returns an octree of AbstractMesh
  41486. */
  41487. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41488. }
  41489. }
  41490. module "babylonjs/Meshes/abstractMesh" {
  41491. interface AbstractMesh {
  41492. /**
  41493. * @hidden
  41494. * Backing Field
  41495. */
  41496. _submeshesOctree: Octree<SubMesh>;
  41497. /**
  41498. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41499. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41500. * @param maxCapacity defines the maximum size of each block (64 by default)
  41501. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41502. * @returns the new octree
  41503. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41505. */
  41506. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41507. }
  41508. }
  41509. /**
  41510. * Defines the octree scene component responsible to manage any octrees
  41511. * in a given scene.
  41512. */
  41513. export class OctreeSceneComponent {
  41514. /**
  41515. * The component name helpfull to identify the component in the list of scene components.
  41516. */
  41517. readonly name: string;
  41518. /**
  41519. * The scene the component belongs to.
  41520. */
  41521. scene: Scene;
  41522. /**
  41523. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41524. */
  41525. readonly checksIsEnabled: boolean;
  41526. /**
  41527. * Creates a new instance of the component for the given scene
  41528. * @param scene Defines the scene to register the component in
  41529. */
  41530. constructor(scene: Scene);
  41531. /**
  41532. * Registers the component in a given scene
  41533. */
  41534. register(): void;
  41535. /**
  41536. * Return the list of active meshes
  41537. * @returns the list of active meshes
  41538. */
  41539. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41540. /**
  41541. * Return the list of active sub meshes
  41542. * @param mesh The mesh to get the candidates sub meshes from
  41543. * @returns the list of active sub meshes
  41544. */
  41545. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41546. private _tempRay;
  41547. /**
  41548. * Return the list of sub meshes intersecting with a given local ray
  41549. * @param mesh defines the mesh to find the submesh for
  41550. * @param localRay defines the ray in local space
  41551. * @returns the list of intersecting sub meshes
  41552. */
  41553. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41554. /**
  41555. * Return the list of sub meshes colliding with a collider
  41556. * @param mesh defines the mesh to find the submesh for
  41557. * @param collider defines the collider to evaluate the collision against
  41558. * @returns the list of colliding sub meshes
  41559. */
  41560. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41561. /**
  41562. * Rebuilds the elements related to this component in case of
  41563. * context lost for instance.
  41564. */
  41565. rebuild(): void;
  41566. /**
  41567. * Disposes the component and the associated ressources.
  41568. */
  41569. dispose(): void;
  41570. }
  41571. }
  41572. declare module "babylonjs/Culling/Octrees/index" {
  41573. export * from "babylonjs/Culling/Octrees/octree";
  41574. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41575. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41576. }
  41577. declare module "babylonjs/Culling/index" {
  41578. export * from "babylonjs/Culling/boundingBox";
  41579. export * from "babylonjs/Culling/boundingInfo";
  41580. export * from "babylonjs/Culling/boundingSphere";
  41581. export * from "babylonjs/Culling/Octrees/index";
  41582. export * from "babylonjs/Culling/ray";
  41583. }
  41584. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41585. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41586. import { Nullable } from "babylonjs/types";
  41587. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41588. import { Scene } from "babylonjs/scene";
  41589. /**
  41590. * Class containing static functions to help procedurally build meshes
  41591. */
  41592. export class LinesBuilder {
  41593. /**
  41594. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41595. * * 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
  41596. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41597. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41598. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41599. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41600. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41601. * * 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
  41602. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41605. * @param name defines the name of the new line system
  41606. * @param options defines the options used to create the line system
  41607. * @param scene defines the hosting scene
  41608. * @returns a new line system mesh
  41609. */
  41610. static CreateLineSystem(name: string, options: {
  41611. lines: Vector3[][];
  41612. updatable?: boolean;
  41613. instance?: Nullable<LinesMesh>;
  41614. colors?: Nullable<Color4[][]>;
  41615. useVertexAlpha?: boolean;
  41616. }, scene: Nullable<Scene>): LinesMesh;
  41617. /**
  41618. * Creates a line mesh
  41619. * 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
  41620. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41621. * * The parameter `points` is an array successive Vector3
  41622. * * 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
  41623. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41624. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41625. * * When updating an instance, remember that only point positions can change, not the number of points
  41626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41628. * @param name defines the name of the new line system
  41629. * @param options defines the options used to create the line system
  41630. * @param scene defines the hosting scene
  41631. * @returns a new line mesh
  41632. */
  41633. static CreateLines(name: string, options: {
  41634. points: Vector3[];
  41635. updatable?: boolean;
  41636. instance?: Nullable<LinesMesh>;
  41637. colors?: Color4[];
  41638. useVertexAlpha?: boolean;
  41639. }, scene?: Nullable<Scene>): LinesMesh;
  41640. /**
  41641. * Creates a dashed line mesh
  41642. * * 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
  41643. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41644. * * The parameter `points` is an array successive Vector3
  41645. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41646. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41647. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41648. * * 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
  41649. * * When updating an instance, remember that only point positions can change, not the number of points
  41650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41651. * @param name defines the name of the mesh
  41652. * @param options defines the options used to create the mesh
  41653. * @param scene defines the hosting scene
  41654. * @returns the dashed line mesh
  41655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41656. */
  41657. static CreateDashedLines(name: string, options: {
  41658. points: Vector3[];
  41659. dashSize?: number;
  41660. gapSize?: number;
  41661. dashNb?: number;
  41662. updatable?: boolean;
  41663. instance?: LinesMesh;
  41664. }, scene?: Nullable<Scene>): LinesMesh;
  41665. }
  41666. }
  41667. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41668. import { IDisposable, Scene } from "babylonjs/scene";
  41669. import { Nullable } from "babylonjs/types";
  41670. import { Observable } from "babylonjs/Misc/observable";
  41671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41672. /**
  41673. * Renders a layer on top of an existing scene
  41674. */
  41675. export class UtilityLayerRenderer implements IDisposable {
  41676. /** the original scene that will be rendered on top of */
  41677. originalScene: Scene;
  41678. private _pointerCaptures;
  41679. private _lastPointerEvents;
  41680. private static _DefaultUtilityLayer;
  41681. private static _DefaultKeepDepthUtilityLayer;
  41682. /**
  41683. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41684. */
  41685. pickUtilitySceneFirst: boolean;
  41686. /**
  41687. * 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)
  41688. */
  41689. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41690. /**
  41691. * 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)
  41692. */
  41693. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41694. /**
  41695. * The scene that is rendered on top of the original scene
  41696. */
  41697. utilityLayerScene: Scene;
  41698. /**
  41699. * If the utility layer should automatically be rendered on top of existing scene
  41700. */
  41701. shouldRender: boolean;
  41702. /**
  41703. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41704. */
  41705. onlyCheckPointerDownEvents: boolean;
  41706. /**
  41707. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41708. */
  41709. processAllEvents: boolean;
  41710. /**
  41711. * Observable raised when the pointer move from the utility layer scene to the main scene
  41712. */
  41713. onPointerOutObservable: Observable<number>;
  41714. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41715. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41716. private _afterRenderObserver;
  41717. private _sceneDisposeObserver;
  41718. private _originalPointerObserver;
  41719. /**
  41720. * Instantiates a UtilityLayerRenderer
  41721. * @param originalScene the original scene that will be rendered on top of
  41722. * @param handleEvents boolean indicating if the utility layer should handle events
  41723. */
  41724. constructor(
  41725. /** the original scene that will be rendered on top of */
  41726. originalScene: Scene, handleEvents?: boolean);
  41727. private _notifyObservers;
  41728. /**
  41729. * Renders the utility layers scene on top of the original scene
  41730. */
  41731. render(): void;
  41732. /**
  41733. * Disposes of the renderer
  41734. */
  41735. dispose(): void;
  41736. private _updateCamera;
  41737. }
  41738. }
  41739. declare module "babylonjs/Gizmos/gizmo" {
  41740. import { Nullable } from "babylonjs/types";
  41741. import { IDisposable } from "babylonjs/scene";
  41742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41743. import { Mesh } from "babylonjs/Meshes/mesh";
  41744. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41745. /**
  41746. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41747. */
  41748. export class Gizmo implements IDisposable {
  41749. /** The utility layer the gizmo will be added to */
  41750. gizmoLayer: UtilityLayerRenderer;
  41751. /**
  41752. * The root mesh of the gizmo
  41753. */
  41754. _rootMesh: Mesh;
  41755. private _attachedMesh;
  41756. /**
  41757. * Ratio for the scale of the gizmo (Default: 1)
  41758. */
  41759. scaleRatio: number;
  41760. private _tmpMatrix;
  41761. /**
  41762. * If a custom mesh has been set (Default: false)
  41763. */
  41764. protected _customMeshSet: boolean;
  41765. /**
  41766. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41767. * * When set, interactions will be enabled
  41768. */
  41769. attachedMesh: Nullable<AbstractMesh>;
  41770. /**
  41771. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41772. * @param mesh The mesh to replace the default mesh of the gizmo
  41773. */
  41774. setCustomMesh(mesh: Mesh): void;
  41775. /**
  41776. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41777. */
  41778. updateGizmoRotationToMatchAttachedMesh: boolean;
  41779. /**
  41780. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41781. */
  41782. updateGizmoPositionToMatchAttachedMesh: boolean;
  41783. /**
  41784. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41785. */
  41786. protected _updateScale: boolean;
  41787. protected _interactionsEnabled: boolean;
  41788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41789. private _beforeRenderObserver;
  41790. /**
  41791. * Creates a gizmo
  41792. * @param gizmoLayer The utility layer the gizmo will be added to
  41793. */
  41794. constructor(
  41795. /** The utility layer the gizmo will be added to */
  41796. gizmoLayer?: UtilityLayerRenderer);
  41797. private _tempVector;
  41798. /**
  41799. * @hidden
  41800. * Updates the gizmo to match the attached mesh's position/rotation
  41801. */
  41802. protected _update(): void;
  41803. /**
  41804. * Disposes of the gizmo
  41805. */
  41806. dispose(): void;
  41807. }
  41808. }
  41809. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41810. import { Observable } from "babylonjs/Misc/observable";
  41811. import { Nullable } from "babylonjs/types";
  41812. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41813. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41815. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41816. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41817. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41818. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41819. import { Scene } from "babylonjs/scene";
  41820. /**
  41821. * Single axis drag gizmo
  41822. */
  41823. export class AxisDragGizmo extends Gizmo {
  41824. /**
  41825. * Drag behavior responsible for the gizmos dragging interactions
  41826. */
  41827. dragBehavior: PointerDragBehavior;
  41828. private _pointerObserver;
  41829. /**
  41830. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41831. */
  41832. snapDistance: number;
  41833. /**
  41834. * Event that fires each time the gizmo snaps to a new location.
  41835. * * snapDistance is the the change in distance
  41836. */
  41837. onSnapObservable: Observable<{
  41838. snapDistance: number;
  41839. }>;
  41840. /** @hidden */
  41841. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41842. /** @hidden */
  41843. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41844. /**
  41845. * Creates an AxisDragGizmo
  41846. * @param gizmoLayer The utility layer the gizmo will be added to
  41847. * @param dragAxis The axis which the gizmo will be able to drag on
  41848. * @param color The color of the gizmo
  41849. */
  41850. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41851. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41852. /**
  41853. * Disposes of the gizmo
  41854. */
  41855. dispose(): void;
  41856. }
  41857. }
  41858. declare module "babylonjs/Debug/axesViewer" {
  41859. import { Vector3 } from "babylonjs/Maths/math";
  41860. import { Nullable } from "babylonjs/types";
  41861. import { Scene } from "babylonjs/scene";
  41862. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41863. /**
  41864. * The Axes viewer will show 3 axes in a specific point in space
  41865. */
  41866. export class AxesViewer {
  41867. private _xAxis;
  41868. private _yAxis;
  41869. private _zAxis;
  41870. private _scaleLinesFactor;
  41871. private _instanced;
  41872. /**
  41873. * Gets the hosting scene
  41874. */
  41875. scene: Scene;
  41876. /**
  41877. * Gets or sets a number used to scale line length
  41878. */
  41879. scaleLines: number;
  41880. /** Gets the node hierarchy used to render x-axis */
  41881. readonly xAxis: TransformNode;
  41882. /** Gets the node hierarchy used to render y-axis */
  41883. readonly yAxis: TransformNode;
  41884. /** Gets the node hierarchy used to render z-axis */
  41885. readonly zAxis: TransformNode;
  41886. /**
  41887. * Creates a new AxesViewer
  41888. * @param scene defines the hosting scene
  41889. * @param scaleLines defines a number used to scale line length (1 by default)
  41890. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41891. * @param xAxis defines the node hierarchy used to render the x-axis
  41892. * @param yAxis defines the node hierarchy used to render the y-axis
  41893. * @param zAxis defines the node hierarchy used to render the z-axis
  41894. */
  41895. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41896. /**
  41897. * Force the viewer to update
  41898. * @param position defines the position of the viewer
  41899. * @param xaxis defines the x axis of the viewer
  41900. * @param yaxis defines the y axis of the viewer
  41901. * @param zaxis defines the z axis of the viewer
  41902. */
  41903. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41904. /**
  41905. * Creates an instance of this axes viewer.
  41906. * @returns a new axes viewer with instanced meshes
  41907. */
  41908. createInstance(): AxesViewer;
  41909. /** Releases resources */
  41910. dispose(): void;
  41911. private static _SetRenderingGroupId;
  41912. }
  41913. }
  41914. declare module "babylonjs/Debug/boneAxesViewer" {
  41915. import { Nullable } from "babylonjs/types";
  41916. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41917. import { Vector3 } from "babylonjs/Maths/math";
  41918. import { Mesh } from "babylonjs/Meshes/mesh";
  41919. import { Bone } from "babylonjs/Bones/bone";
  41920. import { Scene } from "babylonjs/scene";
  41921. /**
  41922. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41923. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41924. */
  41925. export class BoneAxesViewer extends AxesViewer {
  41926. /**
  41927. * Gets or sets the target mesh where to display the axes viewer
  41928. */
  41929. mesh: Nullable<Mesh>;
  41930. /**
  41931. * Gets or sets the target bone where to display the axes viewer
  41932. */
  41933. bone: Nullable<Bone>;
  41934. /** Gets current position */
  41935. pos: Vector3;
  41936. /** Gets direction of X axis */
  41937. xaxis: Vector3;
  41938. /** Gets direction of Y axis */
  41939. yaxis: Vector3;
  41940. /** Gets direction of Z axis */
  41941. zaxis: Vector3;
  41942. /**
  41943. * Creates a new BoneAxesViewer
  41944. * @param scene defines the hosting scene
  41945. * @param bone defines the target bone
  41946. * @param mesh defines the target mesh
  41947. * @param scaleLines defines a scaling factor for line length (1 by default)
  41948. */
  41949. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41950. /**
  41951. * Force the viewer to update
  41952. */
  41953. update(): void;
  41954. /** Releases resources */
  41955. dispose(): void;
  41956. }
  41957. }
  41958. declare module "babylonjs/Debug/debugLayer" {
  41959. import { Observable } from "babylonjs/Misc/observable";
  41960. import { Scene } from "babylonjs/scene";
  41961. /**
  41962. * Interface used to define scene explorer extensibility option
  41963. */
  41964. export interface IExplorerExtensibilityOption {
  41965. /**
  41966. * Define the option label
  41967. */
  41968. label: string;
  41969. /**
  41970. * Defines the action to execute on click
  41971. */
  41972. action: (entity: any) => void;
  41973. }
  41974. /**
  41975. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41976. */
  41977. export interface IExplorerExtensibilityGroup {
  41978. /**
  41979. * Defines a predicate to test if a given type mut be extended
  41980. */
  41981. predicate: (entity: any) => boolean;
  41982. /**
  41983. * Gets the list of options added to a type
  41984. */
  41985. entries: IExplorerExtensibilityOption[];
  41986. }
  41987. /**
  41988. * Interface used to define the options to use to create the Inspector
  41989. */
  41990. export interface IInspectorOptions {
  41991. /**
  41992. * Display in overlay mode (default: false)
  41993. */
  41994. overlay?: boolean;
  41995. /**
  41996. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41997. */
  41998. globalRoot?: HTMLElement;
  41999. /**
  42000. * Display the Scene explorer
  42001. */
  42002. showExplorer?: boolean;
  42003. /**
  42004. * Display the property inspector
  42005. */
  42006. showInspector?: boolean;
  42007. /**
  42008. * Display in embed mode (both panes on the right)
  42009. */
  42010. embedMode?: boolean;
  42011. /**
  42012. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42013. */
  42014. handleResize?: boolean;
  42015. /**
  42016. * Allow the panes to popup (default: true)
  42017. */
  42018. enablePopup?: boolean;
  42019. /**
  42020. * Allow the panes to be closed by users (default: true)
  42021. */
  42022. enableClose?: boolean;
  42023. /**
  42024. * Optional list of extensibility entries
  42025. */
  42026. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42027. /**
  42028. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42029. */
  42030. inspectorURL?: string;
  42031. }
  42032. module "babylonjs/scene" {
  42033. interface Scene {
  42034. /**
  42035. * @hidden
  42036. * Backing field
  42037. */
  42038. _debugLayer: DebugLayer;
  42039. /**
  42040. * Gets the debug layer (aka Inspector) associated with the scene
  42041. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42042. */
  42043. debugLayer: DebugLayer;
  42044. }
  42045. }
  42046. /**
  42047. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42048. * what is happening in your scene
  42049. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42050. */
  42051. export class DebugLayer {
  42052. /**
  42053. * Define the url to get the inspector script from.
  42054. * By default it uses the babylonjs CDN.
  42055. * @ignoreNaming
  42056. */
  42057. static InspectorURL: string;
  42058. private _scene;
  42059. private BJSINSPECTOR;
  42060. /**
  42061. * Observable triggered when a property is changed through the inspector.
  42062. */
  42063. onPropertyChangedObservable: Observable<{
  42064. object: any;
  42065. property: string;
  42066. value: any;
  42067. initialValue: any;
  42068. }>;
  42069. /**
  42070. * Instantiates a new debug layer.
  42071. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42072. * what is happening in your scene
  42073. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42074. * @param scene Defines the scene to inspect
  42075. */
  42076. constructor(scene: Scene);
  42077. /** Creates the inspector window. */
  42078. private _createInspector;
  42079. /**
  42080. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42081. * @param entity defines the entity to select
  42082. * @param lineContainerTitle defines the specific block to highlight
  42083. */
  42084. select(entity: any, lineContainerTitle?: string): void;
  42085. /** Get the inspector from bundle or global */
  42086. private _getGlobalInspector;
  42087. /**
  42088. * Get if the inspector is visible or not.
  42089. * @returns true if visible otherwise, false
  42090. */
  42091. isVisible(): boolean;
  42092. /**
  42093. * Hide the inspector and close its window.
  42094. */
  42095. hide(): void;
  42096. /**
  42097. * Launch the debugLayer.
  42098. * @param config Define the configuration of the inspector
  42099. * @return a promise fulfilled when the debug layer is visible
  42100. */
  42101. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42102. }
  42103. }
  42104. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42105. import { Nullable } from "babylonjs/types";
  42106. import { Scene } from "babylonjs/scene";
  42107. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42108. import { Mesh } from "babylonjs/Meshes/mesh";
  42109. /**
  42110. * Class containing static functions to help procedurally build meshes
  42111. */
  42112. export class BoxBuilder {
  42113. /**
  42114. * Creates a box mesh
  42115. * * The parameter `size` sets the size (float) of each box side (default 1)
  42116. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42117. * * 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)
  42118. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42122. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42123. * @param name defines the name of the mesh
  42124. * @param options defines the options used to create the mesh
  42125. * @param scene defines the hosting scene
  42126. * @returns the box mesh
  42127. */
  42128. static CreateBox(name: string, options: {
  42129. size?: number;
  42130. width?: number;
  42131. height?: number;
  42132. depth?: number;
  42133. faceUV?: Vector4[];
  42134. faceColors?: Color4[];
  42135. sideOrientation?: number;
  42136. frontUVs?: Vector4;
  42137. backUVs?: Vector4;
  42138. updatable?: boolean;
  42139. }, scene?: Nullable<Scene>): Mesh;
  42140. }
  42141. }
  42142. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42143. import { Vector4 } from "babylonjs/Maths/math";
  42144. import { Mesh } from "babylonjs/Meshes/mesh";
  42145. /**
  42146. * Class containing static functions to help procedurally build meshes
  42147. */
  42148. export class SphereBuilder {
  42149. /**
  42150. * Creates a sphere mesh
  42151. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42152. * * 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`)
  42153. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42154. * * 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
  42155. * * 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)
  42156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42159. * @param name defines the name of the mesh
  42160. * @param options defines the options used to create the mesh
  42161. * @param scene defines the hosting scene
  42162. * @returns the sphere mesh
  42163. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42164. */
  42165. static CreateSphere(name: string, options: {
  42166. segments?: number;
  42167. diameter?: number;
  42168. diameterX?: number;
  42169. diameterY?: number;
  42170. diameterZ?: number;
  42171. arc?: number;
  42172. slice?: number;
  42173. sideOrientation?: number;
  42174. frontUVs?: Vector4;
  42175. backUVs?: Vector4;
  42176. updatable?: boolean;
  42177. }, scene: any): Mesh;
  42178. }
  42179. }
  42180. declare module "babylonjs/Debug/physicsViewer" {
  42181. import { Nullable } from "babylonjs/types";
  42182. import { Scene } from "babylonjs/scene";
  42183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42184. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42185. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42186. /**
  42187. * Used to show the physics impostor around the specific mesh
  42188. */
  42189. export class PhysicsViewer {
  42190. /** @hidden */
  42191. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42192. /** @hidden */
  42193. protected _meshes: Array<Nullable<AbstractMesh>>;
  42194. /** @hidden */
  42195. protected _scene: Nullable<Scene>;
  42196. /** @hidden */
  42197. protected _numMeshes: number;
  42198. /** @hidden */
  42199. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42200. private _renderFunction;
  42201. private _utilityLayer;
  42202. private _debugBoxMesh;
  42203. private _debugSphereMesh;
  42204. private _debugMaterial;
  42205. /**
  42206. * Creates a new PhysicsViewer
  42207. * @param scene defines the hosting scene
  42208. */
  42209. constructor(scene: Scene);
  42210. /** @hidden */
  42211. protected _updateDebugMeshes(): void;
  42212. /**
  42213. * Renders a specified physic impostor
  42214. * @param impostor defines the impostor to render
  42215. * @returns the new debug mesh used to render the impostor
  42216. */
  42217. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  42218. /**
  42219. * Hides a specified physic impostor
  42220. * @param impostor defines the impostor to hide
  42221. */
  42222. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42223. private _getDebugMaterial;
  42224. private _getDebugBoxMesh;
  42225. private _getDebugSphereMesh;
  42226. private _getDebugMesh;
  42227. /** Releases all resources */
  42228. dispose(): void;
  42229. }
  42230. }
  42231. declare module "babylonjs/Debug/rayHelper" {
  42232. import { Nullable } from "babylonjs/types";
  42233. import { Ray } from "babylonjs/Culling/ray";
  42234. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42235. import { Scene } from "babylonjs/scene";
  42236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42237. import "babylonjs/Meshes/Builders/linesBuilder";
  42238. /**
  42239. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42240. * in order to better appreciate the issue one might have.
  42241. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42242. */
  42243. export class RayHelper {
  42244. /**
  42245. * Defines the ray we are currently tryin to visualize.
  42246. */
  42247. ray: Nullable<Ray>;
  42248. private _renderPoints;
  42249. private _renderLine;
  42250. private _renderFunction;
  42251. private _scene;
  42252. private _updateToMeshFunction;
  42253. private _attachedToMesh;
  42254. private _meshSpaceDirection;
  42255. private _meshSpaceOrigin;
  42256. /**
  42257. * Helper function to create a colored helper in a scene in one line.
  42258. * @param ray Defines the ray we are currently tryin to visualize
  42259. * @param scene Defines the scene the ray is used in
  42260. * @param color Defines the color we want to see the ray in
  42261. * @returns The newly created ray helper.
  42262. */
  42263. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42264. /**
  42265. * Instantiate a new ray helper.
  42266. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42267. * in order to better appreciate the issue one might have.
  42268. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42269. * @param ray Defines the ray we are currently tryin to visualize
  42270. */
  42271. constructor(ray: Ray);
  42272. /**
  42273. * Shows the ray we are willing to debug.
  42274. * @param scene Defines the scene the ray needs to be rendered in
  42275. * @param color Defines the color the ray needs to be rendered in
  42276. */
  42277. show(scene: Scene, color?: Color3): void;
  42278. /**
  42279. * Hides the ray we are debugging.
  42280. */
  42281. hide(): void;
  42282. private _render;
  42283. /**
  42284. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42285. * @param mesh Defines the mesh we want the helper attached to
  42286. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42287. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42288. * @param length Defines the length of the ray
  42289. */
  42290. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42291. /**
  42292. * Detach the ray helper from the mesh it has previously been attached to.
  42293. */
  42294. detachFromMesh(): void;
  42295. private _updateToMesh;
  42296. /**
  42297. * Dispose the helper and release its associated resources.
  42298. */
  42299. dispose(): void;
  42300. }
  42301. }
  42302. declare module "babylonjs/Debug/skeletonViewer" {
  42303. import { Color3 } from "babylonjs/Maths/math";
  42304. import { Scene } from "babylonjs/scene";
  42305. import { Nullable } from "babylonjs/types";
  42306. import { Skeleton } from "babylonjs/Bones/skeleton";
  42307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42308. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42309. /**
  42310. * Class used to render a debug view of a given skeleton
  42311. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42312. */
  42313. export class SkeletonViewer {
  42314. /** defines the skeleton to render */
  42315. skeleton: Skeleton;
  42316. /** defines the mesh attached to the skeleton */
  42317. mesh: AbstractMesh;
  42318. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42319. autoUpdateBonesMatrices: boolean;
  42320. /** defines the rendering group id to use with the viewer */
  42321. renderingGroupId: number;
  42322. /** Gets or sets the color used to render the skeleton */
  42323. color: Color3;
  42324. private _scene;
  42325. private _debugLines;
  42326. private _debugMesh;
  42327. private _isEnabled;
  42328. private _renderFunction;
  42329. private _utilityLayer;
  42330. /**
  42331. * Returns the mesh used to render the bones
  42332. */
  42333. readonly debugMesh: Nullable<LinesMesh>;
  42334. /**
  42335. * Creates a new SkeletonViewer
  42336. * @param skeleton defines the skeleton to render
  42337. * @param mesh defines the mesh attached to the skeleton
  42338. * @param scene defines the hosting scene
  42339. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42340. * @param renderingGroupId defines the rendering group id to use with the viewer
  42341. */
  42342. constructor(
  42343. /** defines the skeleton to render */
  42344. skeleton: Skeleton,
  42345. /** defines the mesh attached to the skeleton */
  42346. mesh: AbstractMesh, scene: Scene,
  42347. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42348. autoUpdateBonesMatrices?: boolean,
  42349. /** defines the rendering group id to use with the viewer */
  42350. renderingGroupId?: number);
  42351. /** Gets or sets a boolean indicating if the viewer is enabled */
  42352. isEnabled: boolean;
  42353. private _getBonePosition;
  42354. private _getLinesForBonesWithLength;
  42355. private _getLinesForBonesNoLength;
  42356. /** Update the viewer to sync with current skeleton state */
  42357. update(): void;
  42358. /** Release associated resources */
  42359. dispose(): void;
  42360. }
  42361. }
  42362. declare module "babylonjs/Debug/index" {
  42363. export * from "babylonjs/Debug/axesViewer";
  42364. export * from "babylonjs/Debug/boneAxesViewer";
  42365. export * from "babylonjs/Debug/debugLayer";
  42366. export * from "babylonjs/Debug/physicsViewer";
  42367. export * from "babylonjs/Debug/rayHelper";
  42368. export * from "babylonjs/Debug/skeletonViewer";
  42369. }
  42370. declare module "babylonjs/Engines/nullEngine" {
  42371. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42372. import { Scene } from "babylonjs/scene";
  42373. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42374. import { Engine } from "babylonjs/Engines/engine";
  42375. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42376. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42378. import { Effect } from "babylonjs/Materials/effect";
  42379. /**
  42380. * Options to create the null engine
  42381. */
  42382. export class NullEngineOptions {
  42383. /**
  42384. * Render width (Default: 512)
  42385. */
  42386. renderWidth: number;
  42387. /**
  42388. * Render height (Default: 256)
  42389. */
  42390. renderHeight: number;
  42391. /**
  42392. * Texture size (Default: 512)
  42393. */
  42394. textureSize: number;
  42395. /**
  42396. * If delta time between frames should be constant
  42397. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42398. */
  42399. deterministicLockstep: boolean;
  42400. /**
  42401. * Maximum about of steps between frames (Default: 4)
  42402. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42403. */
  42404. lockstepMaxSteps: number;
  42405. }
  42406. /**
  42407. * The null engine class provides support for headless version of babylon.js.
  42408. * This can be used in server side scenario or for testing purposes
  42409. */
  42410. export class NullEngine extends Engine {
  42411. private _options;
  42412. /**
  42413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42414. */
  42415. isDeterministicLockStep(): boolean;
  42416. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42417. getLockstepMaxSteps(): number;
  42418. /**
  42419. * Sets hardware scaling, used to save performance if needed
  42420. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42421. */
  42422. getHardwareScalingLevel(): number;
  42423. constructor(options?: NullEngineOptions);
  42424. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42425. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42426. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42427. getRenderWidth(useScreen?: boolean): number;
  42428. getRenderHeight(useScreen?: boolean): number;
  42429. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42430. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42431. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42432. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42433. bindSamplers(effect: Effect): void;
  42434. enableEffect(effect: Effect): void;
  42435. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42436. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42437. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42438. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42439. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42440. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42441. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42442. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42443. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42444. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42445. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42446. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42447. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42448. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42449. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42450. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42451. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42452. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42453. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42454. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42455. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42456. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42457. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42458. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42459. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42460. bindBuffers(vertexBuffers: {
  42461. [key: string]: VertexBuffer;
  42462. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42463. wipeCaches(bruteForce?: boolean): void;
  42464. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42465. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42467. /** @hidden */
  42468. _createTexture(): WebGLTexture;
  42469. /** @hidden */
  42470. _releaseTexture(texture: InternalTexture): void;
  42471. 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;
  42472. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42473. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42474. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42475. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42476. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42477. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42478. areAllEffectsReady(): boolean;
  42479. /**
  42480. * @hidden
  42481. * Get the current error code of the webGL context
  42482. * @returns the error code
  42483. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42484. */
  42485. getError(): number;
  42486. /** @hidden */
  42487. _getUnpackAlignement(): number;
  42488. /** @hidden */
  42489. _unpackFlipY(value: boolean): void;
  42490. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42491. /**
  42492. * Updates a dynamic vertex buffer.
  42493. * @param vertexBuffer the vertex buffer to update
  42494. * @param data the data used to update the vertex buffer
  42495. * @param byteOffset the byte offset of the data (optional)
  42496. * @param byteLength the byte length of the data (optional)
  42497. */
  42498. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42499. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42500. /** @hidden */
  42501. _bindTexture(channel: number, texture: InternalTexture): void;
  42502. /** @hidden */
  42503. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42504. releaseEffects(): void;
  42505. displayLoadingUI(): void;
  42506. hideLoadingUI(): void;
  42507. /** @hidden */
  42508. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42509. /** @hidden */
  42510. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42511. /** @hidden */
  42512. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42513. /** @hidden */
  42514. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42515. }
  42516. }
  42517. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42518. import { Nullable, int } from "babylonjs/types";
  42519. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42520. /** @hidden */
  42521. export class _OcclusionDataStorage {
  42522. /** @hidden */
  42523. occlusionInternalRetryCounter: number;
  42524. /** @hidden */
  42525. isOcclusionQueryInProgress: boolean;
  42526. /** @hidden */
  42527. isOccluded: boolean;
  42528. /** @hidden */
  42529. occlusionRetryCount: number;
  42530. /** @hidden */
  42531. occlusionType: number;
  42532. /** @hidden */
  42533. occlusionQueryAlgorithmType: number;
  42534. }
  42535. module "babylonjs/Engines/engine" {
  42536. interface Engine {
  42537. /**
  42538. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42539. * @return the new query
  42540. */
  42541. createQuery(): WebGLQuery;
  42542. /**
  42543. * Delete and release a webGL query
  42544. * @param query defines the query to delete
  42545. * @return the current engine
  42546. */
  42547. deleteQuery(query: WebGLQuery): Engine;
  42548. /**
  42549. * Check if a given query has resolved and got its value
  42550. * @param query defines the query to check
  42551. * @returns true if the query got its value
  42552. */
  42553. isQueryResultAvailable(query: WebGLQuery): boolean;
  42554. /**
  42555. * Gets the value of a given query
  42556. * @param query defines the query to check
  42557. * @returns the value of the query
  42558. */
  42559. getQueryResult(query: WebGLQuery): number;
  42560. /**
  42561. * Initiates an occlusion query
  42562. * @param algorithmType defines the algorithm to use
  42563. * @param query defines the query to use
  42564. * @returns the current engine
  42565. * @see http://doc.babylonjs.com/features/occlusionquery
  42566. */
  42567. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42568. /**
  42569. * Ends an occlusion query
  42570. * @see http://doc.babylonjs.com/features/occlusionquery
  42571. * @param algorithmType defines the algorithm to use
  42572. * @returns the current engine
  42573. */
  42574. endOcclusionQuery(algorithmType: number): Engine;
  42575. /**
  42576. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42577. * Please note that only one query can be issued at a time
  42578. * @returns a time token used to track the time span
  42579. */
  42580. startTimeQuery(): Nullable<_TimeToken>;
  42581. /**
  42582. * Ends a time query
  42583. * @param token defines the token used to measure the time span
  42584. * @returns the time spent (in ns)
  42585. */
  42586. endTimeQuery(token: _TimeToken): int;
  42587. /** @hidden */
  42588. _currentNonTimestampToken: Nullable<_TimeToken>;
  42589. /** @hidden */
  42590. _createTimeQuery(): WebGLQuery;
  42591. /** @hidden */
  42592. _deleteTimeQuery(query: WebGLQuery): void;
  42593. /** @hidden */
  42594. _getGlAlgorithmType(algorithmType: number): number;
  42595. /** @hidden */
  42596. _getTimeQueryResult(query: WebGLQuery): any;
  42597. /** @hidden */
  42598. _getTimeQueryAvailability(query: WebGLQuery): any;
  42599. }
  42600. }
  42601. module "babylonjs/Meshes/abstractMesh" {
  42602. interface AbstractMesh {
  42603. /**
  42604. * Backing filed
  42605. * @hidden
  42606. */
  42607. __occlusionDataStorage: _OcclusionDataStorage;
  42608. /**
  42609. * Access property
  42610. * @hidden
  42611. */
  42612. _occlusionDataStorage: _OcclusionDataStorage;
  42613. /**
  42614. * 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.
  42615. * The default value is -1 which means don't break the query and wait till the result
  42616. * @see http://doc.babylonjs.com/features/occlusionquery
  42617. */
  42618. occlusionRetryCount: number;
  42619. /**
  42620. * 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:
  42621. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42622. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42623. * * 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.
  42624. * @see http://doc.babylonjs.com/features/occlusionquery
  42625. */
  42626. occlusionType: number;
  42627. /**
  42628. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42629. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42630. * * 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.
  42631. * @see http://doc.babylonjs.com/features/occlusionquery
  42632. */
  42633. occlusionQueryAlgorithmType: number;
  42634. /**
  42635. * 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
  42636. * @see http://doc.babylonjs.com/features/occlusionquery
  42637. */
  42638. isOccluded: boolean;
  42639. /**
  42640. * Flag to check the progress status of the query
  42641. * @see http://doc.babylonjs.com/features/occlusionquery
  42642. */
  42643. isOcclusionQueryInProgress: boolean;
  42644. }
  42645. }
  42646. }
  42647. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42648. import { Nullable } from "babylonjs/types";
  42649. /** @hidden */
  42650. export var _forceTransformFeedbackToBundle: boolean;
  42651. module "babylonjs/Engines/engine" {
  42652. interface Engine {
  42653. /**
  42654. * Creates a webGL transform feedback object
  42655. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42656. * @returns the webGL transform feedback object
  42657. */
  42658. createTransformFeedback(): WebGLTransformFeedback;
  42659. /**
  42660. * Delete a webGL transform feedback object
  42661. * @param value defines the webGL transform feedback object to delete
  42662. */
  42663. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42664. /**
  42665. * Bind a webGL transform feedback object to the webgl context
  42666. * @param value defines the webGL transform feedback object to bind
  42667. */
  42668. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42669. /**
  42670. * Begins a transform feedback operation
  42671. * @param usePoints defines if points or triangles must be used
  42672. */
  42673. beginTransformFeedback(usePoints: boolean): void;
  42674. /**
  42675. * Ends a transform feedback operation
  42676. */
  42677. endTransformFeedback(): void;
  42678. /**
  42679. * Specify the varyings to use with transform feedback
  42680. * @param program defines the associated webGL program
  42681. * @param value defines the list of strings representing the varying names
  42682. */
  42683. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42684. /**
  42685. * Bind a webGL buffer for a transform feedback operation
  42686. * @param value defines the webGL buffer to bind
  42687. */
  42688. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42689. }
  42690. }
  42691. }
  42692. declare module "babylonjs/Engines/Extensions/index" {
  42693. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42694. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42695. }
  42696. declare module "babylonjs/Engines/index" {
  42697. export * from "babylonjs/Engines/constants";
  42698. export * from "babylonjs/Engines/engine";
  42699. export * from "babylonjs/Engines/engineStore";
  42700. export * from "babylonjs/Engines/nullEngine";
  42701. export * from "babylonjs/Engines/Extensions/index";
  42702. }
  42703. declare module "babylonjs/Events/clipboardEvents" {
  42704. /**
  42705. * Gather the list of clipboard event types as constants.
  42706. */
  42707. export class ClipboardEventTypes {
  42708. /**
  42709. * The clipboard event is fired when a copy command is active (pressed).
  42710. */
  42711. static readonly COPY: number;
  42712. /**
  42713. * The clipboard event is fired when a cut command is active (pressed).
  42714. */
  42715. static readonly CUT: number;
  42716. /**
  42717. * The clipboard event is fired when a paste command is active (pressed).
  42718. */
  42719. static readonly PASTE: number;
  42720. }
  42721. /**
  42722. * This class is used to store clipboard related info for the onClipboardObservable event.
  42723. */
  42724. export class ClipboardInfo {
  42725. /**
  42726. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42727. */
  42728. type: number;
  42729. /**
  42730. * Defines the related dom event
  42731. */
  42732. event: ClipboardEvent;
  42733. /**
  42734. *Creates an instance of ClipboardInfo.
  42735. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42736. * @param event Defines the related dom event
  42737. */
  42738. constructor(
  42739. /**
  42740. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42741. */
  42742. type: number,
  42743. /**
  42744. * Defines the related dom event
  42745. */
  42746. event: ClipboardEvent);
  42747. /**
  42748. * Get the clipboard event's type from the keycode.
  42749. * @param keyCode Defines the keyCode for the current keyboard event.
  42750. * @return {number}
  42751. */
  42752. static GetTypeFromCharacter(keyCode: number): number;
  42753. }
  42754. }
  42755. declare module "babylonjs/Events/index" {
  42756. export * from "babylonjs/Events/keyboardEvents";
  42757. export * from "babylonjs/Events/pointerEvents";
  42758. export * from "babylonjs/Events/clipboardEvents";
  42759. }
  42760. declare module "babylonjs/Loading/sceneLoader" {
  42761. import { Observable } from "babylonjs/Misc/observable";
  42762. import { Nullable } from "babylonjs/types";
  42763. import { Scene } from "babylonjs/scene";
  42764. import { Engine } from "babylonjs/Engines/engine";
  42765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42766. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42767. import { AssetContainer } from "babylonjs/assetContainer";
  42768. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42769. import { Skeleton } from "babylonjs/Bones/skeleton";
  42770. /**
  42771. * Class used to represent data loading progression
  42772. */
  42773. export class SceneLoaderProgressEvent {
  42774. /** defines if data length to load can be evaluated */
  42775. readonly lengthComputable: boolean;
  42776. /** defines the loaded data length */
  42777. readonly loaded: number;
  42778. /** defines the data length to load */
  42779. readonly total: number;
  42780. /**
  42781. * Create a new progress event
  42782. * @param lengthComputable defines if data length to load can be evaluated
  42783. * @param loaded defines the loaded data length
  42784. * @param total defines the data length to load
  42785. */
  42786. constructor(
  42787. /** defines if data length to load can be evaluated */
  42788. lengthComputable: boolean,
  42789. /** defines the loaded data length */
  42790. loaded: number,
  42791. /** defines the data length to load */
  42792. total: number);
  42793. /**
  42794. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42795. * @param event defines the source event
  42796. * @returns a new SceneLoaderProgressEvent
  42797. */
  42798. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42799. }
  42800. /**
  42801. * Interface used by SceneLoader plugins to define supported file extensions
  42802. */
  42803. export interface ISceneLoaderPluginExtensions {
  42804. /**
  42805. * Defines the list of supported extensions
  42806. */
  42807. [extension: string]: {
  42808. isBinary: boolean;
  42809. };
  42810. }
  42811. /**
  42812. * Interface used by SceneLoader plugin factory
  42813. */
  42814. export interface ISceneLoaderPluginFactory {
  42815. /**
  42816. * Defines the name of the factory
  42817. */
  42818. name: string;
  42819. /**
  42820. * Function called to create a new plugin
  42821. * @return the new plugin
  42822. */
  42823. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42824. /**
  42825. * Boolean indicating if the plugin can direct load specific data
  42826. */
  42827. canDirectLoad?: (data: string) => boolean;
  42828. }
  42829. /**
  42830. * Interface used to define a SceneLoader plugin
  42831. */
  42832. export interface ISceneLoaderPlugin {
  42833. /**
  42834. * The friendly name of this plugin.
  42835. */
  42836. name: string;
  42837. /**
  42838. * The file extensions supported by this plugin.
  42839. */
  42840. extensions: string | ISceneLoaderPluginExtensions;
  42841. /**
  42842. * Import meshes into a scene.
  42843. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42844. * @param scene The scene to import into
  42845. * @param data The data to import
  42846. * @param rootUrl The root url for scene and resources
  42847. * @param meshes The meshes array to import into
  42848. * @param particleSystems The particle systems array to import into
  42849. * @param skeletons The skeletons array to import into
  42850. * @param onError The callback when import fails
  42851. * @returns True if successful or false otherwise
  42852. */
  42853. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42854. /**
  42855. * Load into a scene.
  42856. * @param scene The scene to load into
  42857. * @param data The data to import
  42858. * @param rootUrl The root url for scene and resources
  42859. * @param onError The callback when import fails
  42860. * @returns true if successful or false otherwise
  42861. */
  42862. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42863. /**
  42864. * The callback that returns true if the data can be directly loaded.
  42865. */
  42866. canDirectLoad?: (data: string) => boolean;
  42867. /**
  42868. * The callback that allows custom handling of the root url based on the response url.
  42869. */
  42870. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42871. /**
  42872. * Load into an asset container.
  42873. * @param scene The scene to load into
  42874. * @param data The data to import
  42875. * @param rootUrl The root url for scene and resources
  42876. * @param onError The callback when import fails
  42877. * @returns The loaded asset container
  42878. */
  42879. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42880. }
  42881. /**
  42882. * Interface used to define an async SceneLoader plugin
  42883. */
  42884. export interface ISceneLoaderPluginAsync {
  42885. /**
  42886. * The friendly name of this plugin.
  42887. */
  42888. name: string;
  42889. /**
  42890. * The file extensions supported by this plugin.
  42891. */
  42892. extensions: string | ISceneLoaderPluginExtensions;
  42893. /**
  42894. * Import meshes into a scene.
  42895. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42896. * @param scene The scene to import into
  42897. * @param data The data to import
  42898. * @param rootUrl The root url for scene and resources
  42899. * @param onProgress The callback when the load progresses
  42900. * @param fileName Defines the name of the file to load
  42901. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42902. */
  42903. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42904. meshes: AbstractMesh[];
  42905. particleSystems: IParticleSystem[];
  42906. skeletons: Skeleton[];
  42907. animationGroups: AnimationGroup[];
  42908. }>;
  42909. /**
  42910. * Load into a scene.
  42911. * @param scene The scene to load into
  42912. * @param data The data to import
  42913. * @param rootUrl The root url for scene and resources
  42914. * @param onProgress The callback when the load progresses
  42915. * @param fileName Defines the name of the file to load
  42916. * @returns Nothing
  42917. */
  42918. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42919. /**
  42920. * The callback that returns true if the data can be directly loaded.
  42921. */
  42922. canDirectLoad?: (data: string) => boolean;
  42923. /**
  42924. * The callback that allows custom handling of the root url based on the response url.
  42925. */
  42926. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42927. /**
  42928. * Load into an asset container.
  42929. * @param scene The scene to load into
  42930. * @param data The data to import
  42931. * @param rootUrl The root url for scene and resources
  42932. * @param onProgress The callback when the load progresses
  42933. * @param fileName Defines the name of the file to load
  42934. * @returns The loaded asset container
  42935. */
  42936. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42937. }
  42938. /**
  42939. * Class used to load scene from various file formats using registered plugins
  42940. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42941. */
  42942. export class SceneLoader {
  42943. /**
  42944. * No logging while loading
  42945. */
  42946. static readonly NO_LOGGING: number;
  42947. /**
  42948. * Minimal logging while loading
  42949. */
  42950. static readonly MINIMAL_LOGGING: number;
  42951. /**
  42952. * Summary logging while loading
  42953. */
  42954. static readonly SUMMARY_LOGGING: number;
  42955. /**
  42956. * Detailled logging while loading
  42957. */
  42958. static readonly DETAILED_LOGGING: number;
  42959. /**
  42960. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42961. */
  42962. static ForceFullSceneLoadingForIncremental: boolean;
  42963. /**
  42964. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42965. */
  42966. static ShowLoadingScreen: boolean;
  42967. /**
  42968. * Defines the current logging level (while loading the scene)
  42969. * @ignorenaming
  42970. */
  42971. static loggingLevel: number;
  42972. /**
  42973. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42974. */
  42975. static CleanBoneMatrixWeights: boolean;
  42976. /**
  42977. * Event raised when a plugin is used to load a scene
  42978. */
  42979. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42980. private static _registeredPlugins;
  42981. private static _getDefaultPlugin;
  42982. private static _getPluginForExtension;
  42983. private static _getPluginForDirectLoad;
  42984. private static _getPluginForFilename;
  42985. private static _getDirectLoad;
  42986. private static _loadData;
  42987. private static _getFileInfo;
  42988. /**
  42989. * Gets a plugin that can load the given extension
  42990. * @param extension defines the extension to load
  42991. * @returns a plugin or null if none works
  42992. */
  42993. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42994. /**
  42995. * Gets a boolean indicating that the given extension can be loaded
  42996. * @param extension defines the extension to load
  42997. * @returns true if the extension is supported
  42998. */
  42999. static IsPluginForExtensionAvailable(extension: string): boolean;
  43000. /**
  43001. * Adds a new plugin to the list of registered plugins
  43002. * @param plugin defines the plugin to add
  43003. */
  43004. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43005. /**
  43006. * Import meshes into a scene
  43007. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43008. * @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)
  43009. * @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)
  43010. * @param scene the instance of BABYLON.Scene to append to
  43011. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43012. * @param onProgress a callback with a progress event for each file being loaded
  43013. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43014. * @param pluginExtension the extension used to determine the plugin
  43015. * @returns The loaded plugin
  43016. */
  43017. 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>;
  43018. /**
  43019. * Import meshes into a scene
  43020. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43021. * @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)
  43022. * @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)
  43023. * @param scene the instance of BABYLON.Scene to append to
  43024. * @param onProgress a callback with a progress event for each file being loaded
  43025. * @param pluginExtension the extension used to determine the plugin
  43026. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43027. */
  43028. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43029. meshes: AbstractMesh[];
  43030. particleSystems: IParticleSystem[];
  43031. skeletons: Skeleton[];
  43032. animationGroups: AnimationGroup[];
  43033. }>;
  43034. /**
  43035. * Load a scene
  43036. * @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)
  43037. * @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)
  43038. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43039. * @param onSuccess a callback with the scene when import succeeds
  43040. * @param onProgress a callback with a progress event for each file being loaded
  43041. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43042. * @param pluginExtension the extension used to determine the plugin
  43043. * @returns The loaded plugin
  43044. */
  43045. 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>;
  43046. /**
  43047. * Load a scene
  43048. * @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)
  43049. * @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)
  43050. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43051. * @param onProgress a callback with a progress event for each file being loaded
  43052. * @param pluginExtension the extension used to determine the plugin
  43053. * @returns The loaded scene
  43054. */
  43055. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43056. /**
  43057. * Append a scene
  43058. * @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)
  43059. * @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)
  43060. * @param scene is the instance of BABYLON.Scene to append to
  43061. * @param onSuccess a callback with the scene when import succeeds
  43062. * @param onProgress a callback with a progress event for each file being loaded
  43063. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43064. * @param pluginExtension the extension used to determine the plugin
  43065. * @returns The loaded plugin
  43066. */
  43067. 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>;
  43068. /**
  43069. * Append a scene
  43070. * @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)
  43071. * @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)
  43072. * @param scene is the instance of BABYLON.Scene to append to
  43073. * @param onProgress a callback with a progress event for each file being loaded
  43074. * @param pluginExtension the extension used to determine the plugin
  43075. * @returns The given scene
  43076. */
  43077. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43078. /**
  43079. * Load a scene into an asset container
  43080. * @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)
  43081. * @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)
  43082. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43083. * @param onSuccess a callback with the scene when import succeeds
  43084. * @param onProgress a callback with a progress event for each file being loaded
  43085. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43086. * @param pluginExtension the extension used to determine the plugin
  43087. * @returns The loaded plugin
  43088. */
  43089. 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>;
  43090. /**
  43091. * Load a scene into an asset container
  43092. * @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)
  43093. * @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)
  43094. * @param scene is the instance of Scene to append to
  43095. * @param onProgress a callback with a progress event for each file being loaded
  43096. * @param pluginExtension the extension used to determine the plugin
  43097. * @returns The loaded asset container
  43098. */
  43099. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43100. }
  43101. }
  43102. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43103. import { Scene } from "babylonjs/scene";
  43104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43105. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43106. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43107. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43108. /**
  43109. * Google Daydream controller
  43110. */
  43111. export class DaydreamController extends WebVRController {
  43112. /**
  43113. * Base Url for the controller model.
  43114. */
  43115. static MODEL_BASE_URL: string;
  43116. /**
  43117. * File name for the controller model.
  43118. */
  43119. static MODEL_FILENAME: string;
  43120. /**
  43121. * Gamepad Id prefix used to identify Daydream Controller.
  43122. */
  43123. static readonly GAMEPAD_ID_PREFIX: string;
  43124. /**
  43125. * Creates a new DaydreamController from a gamepad
  43126. * @param vrGamepad the gamepad that the controller should be created from
  43127. */
  43128. constructor(vrGamepad: any);
  43129. /**
  43130. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43131. * @param scene scene in which to add meshes
  43132. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43133. */
  43134. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43135. /**
  43136. * Called once for each button that changed state since the last frame
  43137. * @param buttonIdx Which button index changed
  43138. * @param state New state of the button
  43139. * @param changes Which properties on the state changed since last frame
  43140. */
  43141. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43142. }
  43143. }
  43144. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43145. import { Scene } from "babylonjs/scene";
  43146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43147. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43148. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43149. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43150. /**
  43151. * Gear VR Controller
  43152. */
  43153. export class GearVRController extends WebVRController {
  43154. /**
  43155. * Base Url for the controller model.
  43156. */
  43157. static MODEL_BASE_URL: string;
  43158. /**
  43159. * File name for the controller model.
  43160. */
  43161. static MODEL_FILENAME: string;
  43162. /**
  43163. * Gamepad Id prefix used to identify this controller.
  43164. */
  43165. static readonly GAMEPAD_ID_PREFIX: string;
  43166. private readonly _buttonIndexToObservableNameMap;
  43167. /**
  43168. * Creates a new GearVRController from a gamepad
  43169. * @param vrGamepad the gamepad that the controller should be created from
  43170. */
  43171. constructor(vrGamepad: any);
  43172. /**
  43173. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43174. * @param scene scene in which to add meshes
  43175. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43176. */
  43177. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43178. /**
  43179. * Called once for each button that changed state since the last frame
  43180. * @param buttonIdx Which button index changed
  43181. * @param state New state of the button
  43182. * @param changes Which properties on the state changed since last frame
  43183. */
  43184. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43185. }
  43186. }
  43187. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43188. import { Scene } from "babylonjs/scene";
  43189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43190. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43191. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43192. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43193. /**
  43194. * Generic Controller
  43195. */
  43196. export class GenericController extends WebVRController {
  43197. /**
  43198. * Base Url for the controller model.
  43199. */
  43200. static readonly MODEL_BASE_URL: string;
  43201. /**
  43202. * File name for the controller model.
  43203. */
  43204. static readonly MODEL_FILENAME: string;
  43205. /**
  43206. * Creates a new GenericController from a gamepad
  43207. * @param vrGamepad the gamepad that the controller should be created from
  43208. */
  43209. constructor(vrGamepad: any);
  43210. /**
  43211. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43212. * @param scene scene in which to add meshes
  43213. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43214. */
  43215. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43216. /**
  43217. * Called once for each button that changed state since the last frame
  43218. * @param buttonIdx Which button index changed
  43219. * @param state New state of the button
  43220. * @param changes Which properties on the state changed since last frame
  43221. */
  43222. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43223. }
  43224. }
  43225. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43226. import { Observable } from "babylonjs/Misc/observable";
  43227. import { Scene } from "babylonjs/scene";
  43228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43229. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43230. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43231. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43232. /**
  43233. * Oculus Touch Controller
  43234. */
  43235. export class OculusTouchController extends WebVRController {
  43236. /**
  43237. * Base Url for the controller model.
  43238. */
  43239. static MODEL_BASE_URL: string;
  43240. /**
  43241. * File name for the left controller model.
  43242. */
  43243. static MODEL_LEFT_FILENAME: string;
  43244. /**
  43245. * File name for the right controller model.
  43246. */
  43247. static MODEL_RIGHT_FILENAME: string;
  43248. /**
  43249. * Fired when the secondary trigger on this controller is modified
  43250. */
  43251. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43252. /**
  43253. * Fired when the thumb rest on this controller is modified
  43254. */
  43255. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43256. /**
  43257. * Creates a new OculusTouchController from a gamepad
  43258. * @param vrGamepad the gamepad that the controller should be created from
  43259. */
  43260. constructor(vrGamepad: any);
  43261. /**
  43262. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43263. * @param scene scene in which to add meshes
  43264. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43265. */
  43266. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43267. /**
  43268. * Fired when the A button on this controller is modified
  43269. */
  43270. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43271. /**
  43272. * Fired when the B button on this controller is modified
  43273. */
  43274. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43275. /**
  43276. * Fired when the X button on this controller is modified
  43277. */
  43278. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43279. /**
  43280. * Fired when the Y button on this controller is modified
  43281. */
  43282. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43283. /**
  43284. * Called once for each button that changed state since the last frame
  43285. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43286. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43287. * 2) secondary trigger (same)
  43288. * 3) A (right) X (left), touch, pressed = value
  43289. * 4) B / Y
  43290. * 5) thumb rest
  43291. * @param buttonIdx Which button index changed
  43292. * @param state New state of the button
  43293. * @param changes Which properties on the state changed since last frame
  43294. */
  43295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43296. }
  43297. }
  43298. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43299. import { Scene } from "babylonjs/scene";
  43300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43301. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43302. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43303. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43304. import { Observable } from "babylonjs/Misc/observable";
  43305. /**
  43306. * Vive Controller
  43307. */
  43308. export class ViveController extends WebVRController {
  43309. /**
  43310. * Base Url for the controller model.
  43311. */
  43312. static MODEL_BASE_URL: string;
  43313. /**
  43314. * File name for the controller model.
  43315. */
  43316. static MODEL_FILENAME: string;
  43317. /**
  43318. * Creates a new ViveController from a gamepad
  43319. * @param vrGamepad the gamepad that the controller should be created from
  43320. */
  43321. constructor(vrGamepad: any);
  43322. /**
  43323. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43324. * @param scene scene in which to add meshes
  43325. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43326. */
  43327. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43328. /**
  43329. * Fired when the left button on this controller is modified
  43330. */
  43331. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43332. /**
  43333. * Fired when the right button on this controller is modified
  43334. */
  43335. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43336. /**
  43337. * Fired when the menu button on this controller is modified
  43338. */
  43339. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43340. /**
  43341. * Called once for each button that changed state since the last frame
  43342. * Vive mapping:
  43343. * 0: touchpad
  43344. * 1: trigger
  43345. * 2: left AND right buttons
  43346. * 3: menu button
  43347. * @param buttonIdx Which button index changed
  43348. * @param state New state of the button
  43349. * @param changes Which properties on the state changed since last frame
  43350. */
  43351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43352. }
  43353. }
  43354. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43355. import { Observable } from "babylonjs/Misc/observable";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43358. import { Ray } from "babylonjs/Culling/ray";
  43359. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43360. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43361. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43362. /**
  43363. * Defines the WindowsMotionController object that the state of the windows motion controller
  43364. */
  43365. export class WindowsMotionController extends WebVRController {
  43366. /**
  43367. * The base url used to load the left and right controller models
  43368. */
  43369. static MODEL_BASE_URL: string;
  43370. /**
  43371. * The name of the left controller model file
  43372. */
  43373. static MODEL_LEFT_FILENAME: string;
  43374. /**
  43375. * The name of the right controller model file
  43376. */
  43377. static MODEL_RIGHT_FILENAME: string;
  43378. /**
  43379. * The controller name prefix for this controller type
  43380. */
  43381. static readonly GAMEPAD_ID_PREFIX: string;
  43382. /**
  43383. * The controller id pattern for this controller type
  43384. */
  43385. private static readonly GAMEPAD_ID_PATTERN;
  43386. private _loadedMeshInfo;
  43387. private readonly _mapping;
  43388. /**
  43389. * Fired when the trackpad on this controller is clicked
  43390. */
  43391. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43392. /**
  43393. * Fired when the trackpad on this controller is modified
  43394. */
  43395. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43396. /**
  43397. * The current x and y values of this controller's trackpad
  43398. */
  43399. trackpad: StickValues;
  43400. /**
  43401. * Creates a new WindowsMotionController from a gamepad
  43402. * @param vrGamepad the gamepad that the controller should be created from
  43403. */
  43404. constructor(vrGamepad: any);
  43405. /**
  43406. * Fired when the trigger on this controller is modified
  43407. */
  43408. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43409. /**
  43410. * Fired when the menu button on this controller is modified
  43411. */
  43412. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43413. /**
  43414. * Fired when the grip button on this controller is modified
  43415. */
  43416. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43417. /**
  43418. * Fired when the thumbstick button on this controller is modified
  43419. */
  43420. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43421. /**
  43422. * Fired when the touchpad button on this controller is modified
  43423. */
  43424. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43425. /**
  43426. * Fired when the touchpad values on this controller are modified
  43427. */
  43428. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43429. private _updateTrackpad;
  43430. /**
  43431. * Called once per frame by the engine.
  43432. */
  43433. update(): void;
  43434. /**
  43435. * Called once for each button that changed state since the last frame
  43436. * @param buttonIdx Which button index changed
  43437. * @param state New state of the button
  43438. * @param changes Which properties on the state changed since last frame
  43439. */
  43440. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43441. /**
  43442. * Moves the buttons on the controller mesh based on their current state
  43443. * @param buttonName the name of the button to move
  43444. * @param buttonValue the value of the button which determines the buttons new position
  43445. */
  43446. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43447. /**
  43448. * Moves the axis on the controller mesh based on its current state
  43449. * @param axis the index of the axis
  43450. * @param axisValue the value of the axis which determines the meshes new position
  43451. * @hidden
  43452. */
  43453. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43454. /**
  43455. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43456. * @param scene scene in which to add meshes
  43457. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43458. */
  43459. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43460. /**
  43461. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43462. * can be transformed by button presses and axes values, based on this._mapping.
  43463. *
  43464. * @param scene scene in which the meshes exist
  43465. * @param meshes list of meshes that make up the controller model to process
  43466. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43467. */
  43468. private processModel;
  43469. private createMeshInfo;
  43470. /**
  43471. * Gets the ray of the controller in the direction the controller is pointing
  43472. * @param length the length the resulting ray should be
  43473. * @returns a ray in the direction the controller is pointing
  43474. */
  43475. getForwardRay(length?: number): Ray;
  43476. /**
  43477. * Disposes of the controller
  43478. */
  43479. dispose(): void;
  43480. }
  43481. }
  43482. declare module "babylonjs/Gamepads/Controllers/index" {
  43483. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43484. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43485. export * from "babylonjs/Gamepads/Controllers/genericController";
  43486. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43487. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43488. export * from "babylonjs/Gamepads/Controllers/viveController";
  43489. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43490. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43491. }
  43492. declare module "babylonjs/Gamepads/index" {
  43493. export * from "babylonjs/Gamepads/Controllers/index";
  43494. export * from "babylonjs/Gamepads/gamepad";
  43495. export * from "babylonjs/Gamepads/gamepadManager";
  43496. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43497. export * from "babylonjs/Gamepads/xboxGamepad";
  43498. }
  43499. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43500. import { Observable } from "babylonjs/Misc/observable";
  43501. import { Nullable } from "babylonjs/types";
  43502. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43504. import { Mesh } from "babylonjs/Meshes/mesh";
  43505. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43506. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43507. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43508. /**
  43509. * Single axis scale gizmo
  43510. */
  43511. export class AxisScaleGizmo extends Gizmo {
  43512. private _coloredMaterial;
  43513. /**
  43514. * Drag behavior responsible for the gizmos dragging interactions
  43515. */
  43516. dragBehavior: PointerDragBehavior;
  43517. private _pointerObserver;
  43518. /**
  43519. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43520. */
  43521. snapDistance: number;
  43522. /**
  43523. * Event that fires each time the gizmo snaps to a new location.
  43524. * * snapDistance is the the change in distance
  43525. */
  43526. onSnapObservable: Observable<{
  43527. snapDistance: number;
  43528. }>;
  43529. /**
  43530. * If the scaling operation should be done on all axis (default: false)
  43531. */
  43532. uniformScaling: boolean;
  43533. /**
  43534. * Creates an AxisScaleGizmo
  43535. * @param gizmoLayer The utility layer the gizmo will be added to
  43536. * @param dragAxis The axis which the gizmo will be able to scale on
  43537. * @param color The color of the gizmo
  43538. */
  43539. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43540. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43541. /**
  43542. * Disposes of the gizmo
  43543. */
  43544. dispose(): void;
  43545. /**
  43546. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43547. * @param mesh The mesh to replace the default mesh of the gizmo
  43548. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43549. */
  43550. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43551. }
  43552. }
  43553. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43554. import { Observable } from "babylonjs/Misc/observable";
  43555. import { Nullable } from "babylonjs/types";
  43556. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43558. import { Mesh } from "babylonjs/Meshes/mesh";
  43559. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43560. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43561. import "babylonjs/Meshes/Builders/boxBuilder";
  43562. /**
  43563. * Bounding box gizmo
  43564. */
  43565. export class BoundingBoxGizmo extends Gizmo {
  43566. private _lineBoundingBox;
  43567. private _rotateSpheresParent;
  43568. private _scaleBoxesParent;
  43569. private _boundingDimensions;
  43570. private _renderObserver;
  43571. private _pointerObserver;
  43572. private _scaleDragSpeed;
  43573. private _tmpQuaternion;
  43574. private _tmpVector;
  43575. private _tmpRotationMatrix;
  43576. /**
  43577. * 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)
  43578. */
  43579. ignoreChildren: boolean;
  43580. /**
  43581. * 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)
  43582. */
  43583. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43584. /**
  43585. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43586. */
  43587. rotationSphereSize: number;
  43588. /**
  43589. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43590. */
  43591. scaleBoxSize: number;
  43592. /**
  43593. * 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)
  43594. */
  43595. fixedDragMeshScreenSize: boolean;
  43596. /**
  43597. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43598. */
  43599. fixedDragMeshScreenSizeDistanceFactor: number;
  43600. /**
  43601. * Fired when a rotation sphere or scale box is dragged
  43602. */
  43603. onDragStartObservable: Observable<{}>;
  43604. /**
  43605. * Fired when a scale box is dragged
  43606. */
  43607. onScaleBoxDragObservable: Observable<{}>;
  43608. /**
  43609. * Fired when a scale box drag is ended
  43610. */
  43611. onScaleBoxDragEndObservable: Observable<{}>;
  43612. /**
  43613. * Fired when a rotation sphere is dragged
  43614. */
  43615. onRotationSphereDragObservable: Observable<{}>;
  43616. /**
  43617. * Fired when a rotation sphere drag is ended
  43618. */
  43619. onRotationSphereDragEndObservable: Observable<{}>;
  43620. /**
  43621. * 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)
  43622. */
  43623. scalePivot: Nullable<Vector3>;
  43624. private _anchorMesh;
  43625. private _existingMeshScale;
  43626. private _dragMesh;
  43627. private pointerDragBehavior;
  43628. private coloredMaterial;
  43629. private hoverColoredMaterial;
  43630. /**
  43631. * Sets the color of the bounding box gizmo
  43632. * @param color the color to set
  43633. */
  43634. setColor(color: Color3): void;
  43635. /**
  43636. * Creates an BoundingBoxGizmo
  43637. * @param gizmoLayer The utility layer the gizmo will be added to
  43638. * @param color The color of the gizmo
  43639. */
  43640. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43641. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43642. private _selectNode;
  43643. /**
  43644. * Updates the bounding box information for the Gizmo
  43645. */
  43646. updateBoundingBox(): void;
  43647. private _updateRotationSpheres;
  43648. private _updateScaleBoxes;
  43649. /**
  43650. * Enables rotation on the specified axis and disables rotation on the others
  43651. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43652. */
  43653. setEnabledRotationAxis(axis: string): void;
  43654. /**
  43655. * Enables/disables scaling
  43656. * @param enable if scaling should be enabled
  43657. */
  43658. setEnabledScaling(enable: boolean): void;
  43659. private _updateDummy;
  43660. /**
  43661. * Enables a pointer drag behavior on the bounding box of the gizmo
  43662. */
  43663. enableDragBehavior(): void;
  43664. /**
  43665. * Disposes of the gizmo
  43666. */
  43667. dispose(): void;
  43668. /**
  43669. * 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)
  43670. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43671. * @returns the bounding box mesh with the passed in mesh as a child
  43672. */
  43673. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43674. /**
  43675. * CustomMeshes are not supported by this gizmo
  43676. * @param mesh The mesh to replace the default mesh of the gizmo
  43677. */
  43678. setCustomMesh(mesh: Mesh): void;
  43679. }
  43680. }
  43681. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43682. import { Observable } from "babylonjs/Misc/observable";
  43683. import { Nullable } from "babylonjs/types";
  43684. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43686. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43687. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43688. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43689. import "babylonjs/Meshes/Builders/linesBuilder";
  43690. /**
  43691. * Single plane rotation gizmo
  43692. */
  43693. export class PlaneRotationGizmo extends Gizmo {
  43694. /**
  43695. * Drag behavior responsible for the gizmos dragging interactions
  43696. */
  43697. dragBehavior: PointerDragBehavior;
  43698. private _pointerObserver;
  43699. /**
  43700. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43701. */
  43702. snapDistance: number;
  43703. /**
  43704. * Event that fires each time the gizmo snaps to a new location.
  43705. * * snapDistance is the the change in distance
  43706. */
  43707. onSnapObservable: Observable<{
  43708. snapDistance: number;
  43709. }>;
  43710. /**
  43711. * Creates a PlaneRotationGizmo
  43712. * @param gizmoLayer The utility layer the gizmo will be added to
  43713. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43714. * @param color The color of the gizmo
  43715. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43716. */
  43717. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43718. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43719. /**
  43720. * Disposes of the gizmo
  43721. */
  43722. dispose(): void;
  43723. }
  43724. }
  43725. declare module "babylonjs/Gizmos/rotationGizmo" {
  43726. import { Observable } from "babylonjs/Misc/observable";
  43727. import { Nullable } from "babylonjs/types";
  43728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43729. import { Mesh } from "babylonjs/Meshes/mesh";
  43730. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43731. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43732. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43733. /**
  43734. * Gizmo that enables rotating a mesh along 3 axis
  43735. */
  43736. export class RotationGizmo extends Gizmo {
  43737. /**
  43738. * Internal gizmo used for interactions on the x axis
  43739. */
  43740. xGizmo: PlaneRotationGizmo;
  43741. /**
  43742. * Internal gizmo used for interactions on the y axis
  43743. */
  43744. yGizmo: PlaneRotationGizmo;
  43745. /**
  43746. * Internal gizmo used for interactions on the z axis
  43747. */
  43748. zGizmo: PlaneRotationGizmo;
  43749. /** Fires an event when any of it's sub gizmos are dragged */
  43750. onDragStartObservable: Observable<{}>;
  43751. /** Fires an event when any of it's sub gizmos are released from dragging */
  43752. onDragEndObservable: Observable<{}>;
  43753. attachedMesh: Nullable<AbstractMesh>;
  43754. /**
  43755. * Creates a RotationGizmo
  43756. * @param gizmoLayer The utility layer the gizmo will be added to
  43757. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43758. */
  43759. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43760. updateGizmoRotationToMatchAttachedMesh: boolean;
  43761. /**
  43762. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43763. */
  43764. snapDistance: number;
  43765. /**
  43766. * Ratio for the scale of the gizmo (Default: 1)
  43767. */
  43768. scaleRatio: number;
  43769. /**
  43770. * Disposes of the gizmo
  43771. */
  43772. dispose(): void;
  43773. /**
  43774. * CustomMeshes are not supported by this gizmo
  43775. * @param mesh The mesh to replace the default mesh of the gizmo
  43776. */
  43777. setCustomMesh(mesh: Mesh): void;
  43778. }
  43779. }
  43780. declare module "babylonjs/Gizmos/positionGizmo" {
  43781. import { Observable } from "babylonjs/Misc/observable";
  43782. import { Nullable } from "babylonjs/types";
  43783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43784. import { Mesh } from "babylonjs/Meshes/mesh";
  43785. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43786. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43787. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43788. /**
  43789. * Gizmo that enables dragging a mesh along 3 axis
  43790. */
  43791. export class PositionGizmo extends Gizmo {
  43792. /**
  43793. * Internal gizmo used for interactions on the x axis
  43794. */
  43795. xGizmo: AxisDragGizmo;
  43796. /**
  43797. * Internal gizmo used for interactions on the y axis
  43798. */
  43799. yGizmo: AxisDragGizmo;
  43800. /**
  43801. * Internal gizmo used for interactions on the z axis
  43802. */
  43803. zGizmo: AxisDragGizmo;
  43804. /** Fires an event when any of it's sub gizmos are dragged */
  43805. onDragStartObservable: Observable<{}>;
  43806. /** Fires an event when any of it's sub gizmos are released from dragging */
  43807. onDragEndObservable: Observable<{}>;
  43808. attachedMesh: Nullable<AbstractMesh>;
  43809. /**
  43810. * Creates a PositionGizmo
  43811. * @param gizmoLayer The utility layer the gizmo will be added to
  43812. */
  43813. constructor(gizmoLayer?: UtilityLayerRenderer);
  43814. updateGizmoRotationToMatchAttachedMesh: boolean;
  43815. /**
  43816. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43817. */
  43818. snapDistance: number;
  43819. /**
  43820. * Ratio for the scale of the gizmo (Default: 1)
  43821. */
  43822. scaleRatio: number;
  43823. /**
  43824. * Disposes of the gizmo
  43825. */
  43826. dispose(): void;
  43827. /**
  43828. * CustomMeshes are not supported by this gizmo
  43829. * @param mesh The mesh to replace the default mesh of the gizmo
  43830. */
  43831. setCustomMesh(mesh: Mesh): void;
  43832. }
  43833. }
  43834. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43835. import { Scene } from "babylonjs/scene";
  43836. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43837. import { Mesh } from "babylonjs/Meshes/mesh";
  43838. /**
  43839. * Class containing static functions to help procedurally build meshes
  43840. */
  43841. export class PolyhedronBuilder {
  43842. /**
  43843. * Creates a polyhedron mesh
  43844. * * 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
  43845. * * The parameter `size` (positive float, default 1) sets the polygon size
  43846. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43847. * * 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`
  43848. * * 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
  43849. * * 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)`)
  43850. * * 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
  43851. * * 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
  43852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43855. * @param name defines the name of the mesh
  43856. * @param options defines the options used to create the mesh
  43857. * @param scene defines the hosting scene
  43858. * @returns the polyhedron mesh
  43859. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43860. */
  43861. static CreatePolyhedron(name: string, options: {
  43862. type?: number;
  43863. size?: number;
  43864. sizeX?: number;
  43865. sizeY?: number;
  43866. sizeZ?: number;
  43867. custom?: any;
  43868. faceUV?: Vector4[];
  43869. faceColors?: Color4[];
  43870. flat?: boolean;
  43871. updatable?: boolean;
  43872. sideOrientation?: number;
  43873. frontUVs?: Vector4;
  43874. backUVs?: Vector4;
  43875. }, scene: Scene): Mesh;
  43876. }
  43877. }
  43878. declare module "babylonjs/Gizmos/scaleGizmo" {
  43879. import { Observable } from "babylonjs/Misc/observable";
  43880. import { Nullable } from "babylonjs/types";
  43881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43882. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43883. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43884. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43885. /**
  43886. * Gizmo that enables scaling a mesh along 3 axis
  43887. */
  43888. export class ScaleGizmo extends Gizmo {
  43889. /**
  43890. * Internal gizmo used for interactions on the x axis
  43891. */
  43892. xGizmo: AxisScaleGizmo;
  43893. /**
  43894. * Internal gizmo used for interactions on the y axis
  43895. */
  43896. yGizmo: AxisScaleGizmo;
  43897. /**
  43898. * Internal gizmo used for interactions on the z axis
  43899. */
  43900. zGizmo: AxisScaleGizmo;
  43901. /**
  43902. * Internal gizmo used to scale all axis equally
  43903. */
  43904. uniformScaleGizmo: AxisScaleGizmo;
  43905. /** Fires an event when any of it's sub gizmos are dragged */
  43906. onDragStartObservable: Observable<{}>;
  43907. /** Fires an event when any of it's sub gizmos are released from dragging */
  43908. onDragEndObservable: Observable<{}>;
  43909. attachedMesh: Nullable<AbstractMesh>;
  43910. /**
  43911. * Creates a ScaleGizmo
  43912. * @param gizmoLayer The utility layer the gizmo will be added to
  43913. */
  43914. constructor(gizmoLayer?: UtilityLayerRenderer);
  43915. updateGizmoRotationToMatchAttachedMesh: boolean;
  43916. /**
  43917. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43918. */
  43919. snapDistance: number;
  43920. /**
  43921. * Ratio for the scale of the gizmo (Default: 1)
  43922. */
  43923. scaleRatio: number;
  43924. /**
  43925. * Disposes of the gizmo
  43926. */
  43927. dispose(): void;
  43928. }
  43929. }
  43930. declare module "babylonjs/Gizmos/gizmoManager" {
  43931. import { Observable } from "babylonjs/Misc/observable";
  43932. import { Nullable } from "babylonjs/types";
  43933. import { Scene, IDisposable } from "babylonjs/scene";
  43934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43935. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43936. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43937. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43938. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43939. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43940. /**
  43941. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43942. */
  43943. export class GizmoManager implements IDisposable {
  43944. private scene;
  43945. /**
  43946. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43947. */
  43948. gizmos: {
  43949. positionGizmo: Nullable<PositionGizmo>;
  43950. rotationGizmo: Nullable<RotationGizmo>;
  43951. scaleGizmo: Nullable<ScaleGizmo>;
  43952. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43953. };
  43954. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43955. clearGizmoOnEmptyPointerEvent: boolean;
  43956. /** Fires an event when the manager is attached to a mesh */
  43957. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43958. private _gizmosEnabled;
  43959. private _pointerObserver;
  43960. private _attachedMesh;
  43961. private _boundingBoxColor;
  43962. private _defaultUtilityLayer;
  43963. private _defaultKeepDepthUtilityLayer;
  43964. /**
  43965. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43966. */
  43967. boundingBoxDragBehavior: SixDofDragBehavior;
  43968. /**
  43969. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43970. */
  43971. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43972. /**
  43973. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43974. */
  43975. usePointerToAttachGizmos: boolean;
  43976. /**
  43977. * Instatiates a gizmo manager
  43978. * @param scene the scene to overlay the gizmos on top of
  43979. */
  43980. constructor(scene: Scene);
  43981. /**
  43982. * Attaches a set of gizmos to the specified mesh
  43983. * @param mesh The mesh the gizmo's should be attached to
  43984. */
  43985. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43986. /**
  43987. * If the position gizmo is enabled
  43988. */
  43989. positionGizmoEnabled: boolean;
  43990. /**
  43991. * If the rotation gizmo is enabled
  43992. */
  43993. rotationGizmoEnabled: boolean;
  43994. /**
  43995. * If the scale gizmo is enabled
  43996. */
  43997. scaleGizmoEnabled: boolean;
  43998. /**
  43999. * If the boundingBox gizmo is enabled
  44000. */
  44001. boundingBoxGizmoEnabled: boolean;
  44002. /**
  44003. * Disposes of the gizmo manager
  44004. */
  44005. dispose(): void;
  44006. }
  44007. }
  44008. declare module "babylonjs/Gizmos/lightGizmo" {
  44009. import { Nullable } from "babylonjs/types";
  44010. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44011. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44012. import { Light } from "babylonjs/Lights/light";
  44013. /**
  44014. * Gizmo that enables viewing a light
  44015. */
  44016. export class LightGizmo extends Gizmo {
  44017. private _box;
  44018. /**
  44019. * Creates a LightGizmo
  44020. * @param gizmoLayer The utility layer the gizmo will be added to
  44021. */
  44022. constructor(gizmoLayer?: UtilityLayerRenderer);
  44023. private _light;
  44024. /**
  44025. * The light that the gizmo is attached to
  44026. */
  44027. light: Nullable<Light>;
  44028. /**
  44029. * @hidden
  44030. * Updates the gizmo to match the attached mesh's position/rotation
  44031. */
  44032. protected _update(): void;
  44033. }
  44034. }
  44035. declare module "babylonjs/Gizmos/index" {
  44036. export * from "babylonjs/Gizmos/axisDragGizmo";
  44037. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44038. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44039. export * from "babylonjs/Gizmos/gizmo";
  44040. export * from "babylonjs/Gizmos/gizmoManager";
  44041. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44042. export * from "babylonjs/Gizmos/positionGizmo";
  44043. export * from "babylonjs/Gizmos/rotationGizmo";
  44044. export * from "babylonjs/Gizmos/scaleGizmo";
  44045. export * from "babylonjs/Gizmos/lightGizmo";
  44046. }
  44047. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44048. /** @hidden */
  44049. export var backgroundFragmentDeclaration: {
  44050. name: string;
  44051. shader: string;
  44052. };
  44053. }
  44054. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44055. /** @hidden */
  44056. export var backgroundUboDeclaration: {
  44057. name: string;
  44058. shader: string;
  44059. };
  44060. }
  44061. declare module "babylonjs/Shaders/background.fragment" {
  44062. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44063. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44064. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44065. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44066. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44067. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44068. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44069. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44070. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44071. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44072. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44073. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44074. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44075. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44076. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44077. /** @hidden */
  44078. export var backgroundPixelShader: {
  44079. name: string;
  44080. shader: string;
  44081. };
  44082. }
  44083. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44084. /** @hidden */
  44085. export var backgroundVertexDeclaration: {
  44086. name: string;
  44087. shader: string;
  44088. };
  44089. }
  44090. declare module "babylonjs/Shaders/background.vertex" {
  44091. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44092. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44093. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44094. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44095. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44096. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44097. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44098. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44099. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44103. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44104. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44105. /** @hidden */
  44106. export var backgroundVertexShader: {
  44107. name: string;
  44108. shader: string;
  44109. };
  44110. }
  44111. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44112. import { Nullable, int, float } from "babylonjs/types";
  44113. import { Scene } from "babylonjs/scene";
  44114. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44115. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44117. import { Mesh } from "babylonjs/Meshes/mesh";
  44118. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44119. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44120. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44122. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44123. import "babylonjs/Shaders/background.fragment";
  44124. import "babylonjs/Shaders/background.vertex";
  44125. /**
  44126. * Background material used to create an efficient environement around your scene.
  44127. */
  44128. export class BackgroundMaterial extends PushMaterial {
  44129. /**
  44130. * Standard reflectance value at parallel view angle.
  44131. */
  44132. static StandardReflectance0: number;
  44133. /**
  44134. * Standard reflectance value at grazing angle.
  44135. */
  44136. static StandardReflectance90: number;
  44137. protected _primaryColor: Color3;
  44138. /**
  44139. * Key light Color (multiply against the environement texture)
  44140. */
  44141. primaryColor: Color3;
  44142. protected __perceptualColor: Nullable<Color3>;
  44143. /**
  44144. * Experimental Internal Use Only.
  44145. *
  44146. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44147. * This acts as a helper to set the primary color to a more "human friendly" value.
  44148. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44149. * output color as close as possible from the chosen value.
  44150. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44151. * part of lighting setup.)
  44152. */
  44153. _perceptualColor: Nullable<Color3>;
  44154. protected _primaryColorShadowLevel: float;
  44155. /**
  44156. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44157. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44158. */
  44159. primaryColorShadowLevel: float;
  44160. protected _primaryColorHighlightLevel: float;
  44161. /**
  44162. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44163. * The primary color is used at the level chosen to define what the white area would look.
  44164. */
  44165. primaryColorHighlightLevel: float;
  44166. protected _reflectionTexture: Nullable<BaseTexture>;
  44167. /**
  44168. * Reflection Texture used in the material.
  44169. * Should be author in a specific way for the best result (refer to the documentation).
  44170. */
  44171. reflectionTexture: Nullable<BaseTexture>;
  44172. protected _reflectionBlur: float;
  44173. /**
  44174. * Reflection Texture level of blur.
  44175. *
  44176. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44177. * texture twice.
  44178. */
  44179. reflectionBlur: float;
  44180. protected _diffuseTexture: Nullable<BaseTexture>;
  44181. /**
  44182. * Diffuse Texture used in the material.
  44183. * Should be author in a specific way for the best result (refer to the documentation).
  44184. */
  44185. diffuseTexture: Nullable<BaseTexture>;
  44186. protected _shadowLights: Nullable<IShadowLight[]>;
  44187. /**
  44188. * Specify the list of lights casting shadow on the material.
  44189. * All scene shadow lights will be included if null.
  44190. */
  44191. shadowLights: Nullable<IShadowLight[]>;
  44192. protected _shadowLevel: float;
  44193. /**
  44194. * Helps adjusting the shadow to a softer level if required.
  44195. * 0 means black shadows and 1 means no shadows.
  44196. */
  44197. shadowLevel: float;
  44198. protected _sceneCenter: Vector3;
  44199. /**
  44200. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44201. * It is usually zero but might be interesting to modify according to your setup.
  44202. */
  44203. sceneCenter: Vector3;
  44204. protected _opacityFresnel: boolean;
  44205. /**
  44206. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44207. * This helps ensuring a nice transition when the camera goes under the ground.
  44208. */
  44209. opacityFresnel: boolean;
  44210. protected _reflectionFresnel: boolean;
  44211. /**
  44212. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44213. * This helps adding a mirror texture on the ground.
  44214. */
  44215. reflectionFresnel: boolean;
  44216. protected _reflectionFalloffDistance: number;
  44217. /**
  44218. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44219. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44220. */
  44221. reflectionFalloffDistance: number;
  44222. protected _reflectionAmount: number;
  44223. /**
  44224. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44225. */
  44226. reflectionAmount: number;
  44227. protected _reflectionReflectance0: number;
  44228. /**
  44229. * This specifies the weight of the reflection at grazing angle.
  44230. */
  44231. reflectionReflectance0: number;
  44232. protected _reflectionReflectance90: number;
  44233. /**
  44234. * This specifies the weight of the reflection at a perpendicular point of view.
  44235. */
  44236. reflectionReflectance90: number;
  44237. /**
  44238. * Sets the reflection reflectance fresnel values according to the default standard
  44239. * empirically know to work well :-)
  44240. */
  44241. reflectionStandardFresnelWeight: number;
  44242. protected _useRGBColor: boolean;
  44243. /**
  44244. * Helps to directly use the maps channels instead of their level.
  44245. */
  44246. useRGBColor: boolean;
  44247. protected _enableNoise: boolean;
  44248. /**
  44249. * This helps reducing the banding effect that could occur on the background.
  44250. */
  44251. enableNoise: boolean;
  44252. /**
  44253. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44254. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44255. * Recommended to be keep at 1.0 except for special cases.
  44256. */
  44257. fovMultiplier: number;
  44258. private _fovMultiplier;
  44259. /**
  44260. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44261. */
  44262. useEquirectangularFOV: boolean;
  44263. private _maxSimultaneousLights;
  44264. /**
  44265. * Number of Simultaneous lights allowed on the material.
  44266. */
  44267. maxSimultaneousLights: int;
  44268. /**
  44269. * Default configuration related to image processing available in the Background Material.
  44270. */
  44271. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44272. /**
  44273. * Keep track of the image processing observer to allow dispose and replace.
  44274. */
  44275. private _imageProcessingObserver;
  44276. /**
  44277. * Attaches a new image processing configuration to the PBR Material.
  44278. * @param configuration (if null the scene configuration will be use)
  44279. */
  44280. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44281. /**
  44282. * Gets the image processing configuration used either in this material.
  44283. */
  44284. /**
  44285. * Sets the Default image processing configuration used either in the this material.
  44286. *
  44287. * If sets to null, the scene one is in use.
  44288. */
  44289. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44290. /**
  44291. * Gets wether the color curves effect is enabled.
  44292. */
  44293. /**
  44294. * Sets wether the color curves effect is enabled.
  44295. */
  44296. cameraColorCurvesEnabled: boolean;
  44297. /**
  44298. * Gets wether the color grading effect is enabled.
  44299. */
  44300. /**
  44301. * Gets wether the color grading effect is enabled.
  44302. */
  44303. cameraColorGradingEnabled: boolean;
  44304. /**
  44305. * Gets wether tonemapping is enabled or not.
  44306. */
  44307. /**
  44308. * Sets wether tonemapping is enabled or not
  44309. */
  44310. cameraToneMappingEnabled: boolean;
  44311. /**
  44312. * The camera exposure used on this material.
  44313. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44314. * This corresponds to a photographic exposure.
  44315. */
  44316. /**
  44317. * The camera exposure used on this material.
  44318. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44319. * This corresponds to a photographic exposure.
  44320. */
  44321. cameraExposure: float;
  44322. /**
  44323. * Gets The camera contrast used on this material.
  44324. */
  44325. /**
  44326. * Sets The camera contrast used on this material.
  44327. */
  44328. cameraContrast: float;
  44329. /**
  44330. * Gets the Color Grading 2D Lookup Texture.
  44331. */
  44332. /**
  44333. * Sets the Color Grading 2D Lookup Texture.
  44334. */
  44335. cameraColorGradingTexture: Nullable<BaseTexture>;
  44336. /**
  44337. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44338. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44339. * 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;
  44340. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44341. */
  44342. /**
  44343. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44344. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44345. * 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;
  44346. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44347. */
  44348. cameraColorCurves: Nullable<ColorCurves>;
  44349. /**
  44350. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44351. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44352. */
  44353. switchToBGR: boolean;
  44354. private _renderTargets;
  44355. private _reflectionControls;
  44356. private _white;
  44357. private _primaryShadowColor;
  44358. private _primaryHighlightColor;
  44359. /**
  44360. * Instantiates a Background Material in the given scene
  44361. * @param name The friendly name of the material
  44362. * @param scene The scene to add the material to
  44363. */
  44364. constructor(name: string, scene: Scene);
  44365. /**
  44366. * Gets a boolean indicating that current material needs to register RTT
  44367. */
  44368. readonly hasRenderTargetTextures: boolean;
  44369. /**
  44370. * The entire material has been created in order to prevent overdraw.
  44371. * @returns false
  44372. */
  44373. needAlphaTesting(): boolean;
  44374. /**
  44375. * The entire material has been created in order to prevent overdraw.
  44376. * @returns true if blending is enable
  44377. */
  44378. needAlphaBlending(): boolean;
  44379. /**
  44380. * Checks wether the material is ready to be rendered for a given mesh.
  44381. * @param mesh The mesh to render
  44382. * @param subMesh The submesh to check against
  44383. * @param useInstances Specify wether or not the material is used with instances
  44384. * @returns true if all the dependencies are ready (Textures, Effects...)
  44385. */
  44386. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44387. /**
  44388. * Compute the primary color according to the chosen perceptual color.
  44389. */
  44390. private _computePrimaryColorFromPerceptualColor;
  44391. /**
  44392. * Compute the highlights and shadow colors according to their chosen levels.
  44393. */
  44394. private _computePrimaryColors;
  44395. /**
  44396. * Build the uniform buffer used in the material.
  44397. */
  44398. buildUniformLayout(): void;
  44399. /**
  44400. * Unbind the material.
  44401. */
  44402. unbind(): void;
  44403. /**
  44404. * Bind only the world matrix to the material.
  44405. * @param world The world matrix to bind.
  44406. */
  44407. bindOnlyWorldMatrix(world: Matrix): void;
  44408. /**
  44409. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44410. * @param world The world matrix to bind.
  44411. * @param subMesh The submesh to bind for.
  44412. */
  44413. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44414. /**
  44415. * Dispose the material.
  44416. * @param forceDisposeEffect Force disposal of the associated effect.
  44417. * @param forceDisposeTextures Force disposal of the associated textures.
  44418. */
  44419. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44420. /**
  44421. * Clones the material.
  44422. * @param name The cloned name.
  44423. * @returns The cloned material.
  44424. */
  44425. clone(name: string): BackgroundMaterial;
  44426. /**
  44427. * Serializes the current material to its JSON representation.
  44428. * @returns The JSON representation.
  44429. */
  44430. serialize(): any;
  44431. /**
  44432. * Gets the class name of the material
  44433. * @returns "BackgroundMaterial"
  44434. */
  44435. getClassName(): string;
  44436. /**
  44437. * Parse a JSON input to create back a background material.
  44438. * @param source The JSON data to parse
  44439. * @param scene The scene to create the parsed material in
  44440. * @param rootUrl The root url of the assets the material depends upon
  44441. * @returns the instantiated BackgroundMaterial.
  44442. */
  44443. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44444. }
  44445. }
  44446. declare module "babylonjs/Helpers/environmentHelper" {
  44447. import { Observable } from "babylonjs/Misc/observable";
  44448. import { Nullable } from "babylonjs/types";
  44449. import { Scene } from "babylonjs/scene";
  44450. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44452. import { Mesh } from "babylonjs/Meshes/mesh";
  44453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44454. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44455. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44456. import "babylonjs/Meshes/Builders/planeBuilder";
  44457. import "babylonjs/Meshes/Builders/boxBuilder";
  44458. /**
  44459. * Represents the different options available during the creation of
  44460. * a Environment helper.
  44461. *
  44462. * This can control the default ground, skybox and image processing setup of your scene.
  44463. */
  44464. export interface IEnvironmentHelperOptions {
  44465. /**
  44466. * Specifies wether or not to create a ground.
  44467. * True by default.
  44468. */
  44469. createGround: boolean;
  44470. /**
  44471. * Specifies the ground size.
  44472. * 15 by default.
  44473. */
  44474. groundSize: number;
  44475. /**
  44476. * The texture used on the ground for the main color.
  44477. * Comes from the BabylonJS CDN by default.
  44478. *
  44479. * Remarks: Can be either a texture or a url.
  44480. */
  44481. groundTexture: string | BaseTexture;
  44482. /**
  44483. * The color mixed in the ground texture by default.
  44484. * BabylonJS clearColor by default.
  44485. */
  44486. groundColor: Color3;
  44487. /**
  44488. * Specifies the ground opacity.
  44489. * 1 by default.
  44490. */
  44491. groundOpacity: number;
  44492. /**
  44493. * Enables the ground to receive shadows.
  44494. * True by default.
  44495. */
  44496. enableGroundShadow: boolean;
  44497. /**
  44498. * Helps preventing the shadow to be fully black on the ground.
  44499. * 0.5 by default.
  44500. */
  44501. groundShadowLevel: number;
  44502. /**
  44503. * Creates a mirror texture attach to the ground.
  44504. * false by default.
  44505. */
  44506. enableGroundMirror: boolean;
  44507. /**
  44508. * Specifies the ground mirror size ratio.
  44509. * 0.3 by default as the default kernel is 64.
  44510. */
  44511. groundMirrorSizeRatio: number;
  44512. /**
  44513. * Specifies the ground mirror blur kernel size.
  44514. * 64 by default.
  44515. */
  44516. groundMirrorBlurKernel: number;
  44517. /**
  44518. * Specifies the ground mirror visibility amount.
  44519. * 1 by default
  44520. */
  44521. groundMirrorAmount: number;
  44522. /**
  44523. * Specifies the ground mirror reflectance weight.
  44524. * This uses the standard weight of the background material to setup the fresnel effect
  44525. * of the mirror.
  44526. * 1 by default.
  44527. */
  44528. groundMirrorFresnelWeight: number;
  44529. /**
  44530. * Specifies the ground mirror Falloff distance.
  44531. * This can helps reducing the size of the reflection.
  44532. * 0 by Default.
  44533. */
  44534. groundMirrorFallOffDistance: number;
  44535. /**
  44536. * Specifies the ground mirror texture type.
  44537. * Unsigned Int by Default.
  44538. */
  44539. groundMirrorTextureType: number;
  44540. /**
  44541. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44542. * the shown objects.
  44543. */
  44544. groundYBias: number;
  44545. /**
  44546. * Specifies wether or not to create a skybox.
  44547. * True by default.
  44548. */
  44549. createSkybox: boolean;
  44550. /**
  44551. * Specifies the skybox size.
  44552. * 20 by default.
  44553. */
  44554. skyboxSize: number;
  44555. /**
  44556. * The texture used on the skybox for the main color.
  44557. * Comes from the BabylonJS CDN by default.
  44558. *
  44559. * Remarks: Can be either a texture or a url.
  44560. */
  44561. skyboxTexture: string | BaseTexture;
  44562. /**
  44563. * The color mixed in the skybox texture by default.
  44564. * BabylonJS clearColor by default.
  44565. */
  44566. skyboxColor: Color3;
  44567. /**
  44568. * The background rotation around the Y axis of the scene.
  44569. * This helps aligning the key lights of your scene with the background.
  44570. * 0 by default.
  44571. */
  44572. backgroundYRotation: number;
  44573. /**
  44574. * Compute automatically the size of the elements to best fit with the scene.
  44575. */
  44576. sizeAuto: boolean;
  44577. /**
  44578. * Default position of the rootMesh if autoSize is not true.
  44579. */
  44580. rootPosition: Vector3;
  44581. /**
  44582. * Sets up the image processing in the scene.
  44583. * true by default.
  44584. */
  44585. setupImageProcessing: boolean;
  44586. /**
  44587. * The texture used as your environment texture in the scene.
  44588. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44589. *
  44590. * Remarks: Can be either a texture or a url.
  44591. */
  44592. environmentTexture: string | BaseTexture;
  44593. /**
  44594. * The value of the exposure to apply to the scene.
  44595. * 0.6 by default if setupImageProcessing is true.
  44596. */
  44597. cameraExposure: number;
  44598. /**
  44599. * The value of the contrast to apply to the scene.
  44600. * 1.6 by default if setupImageProcessing is true.
  44601. */
  44602. cameraContrast: number;
  44603. /**
  44604. * Specifies wether or not tonemapping should be enabled in the scene.
  44605. * true by default if setupImageProcessing is true.
  44606. */
  44607. toneMappingEnabled: boolean;
  44608. }
  44609. /**
  44610. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44611. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44612. * It also helps with the default setup of your imageProcessing configuration.
  44613. */
  44614. export class EnvironmentHelper {
  44615. /**
  44616. * Default ground texture URL.
  44617. */
  44618. private static _groundTextureCDNUrl;
  44619. /**
  44620. * Default skybox texture URL.
  44621. */
  44622. private static _skyboxTextureCDNUrl;
  44623. /**
  44624. * Default environment texture URL.
  44625. */
  44626. private static _environmentTextureCDNUrl;
  44627. /**
  44628. * Creates the default options for the helper.
  44629. */
  44630. private static _getDefaultOptions;
  44631. private _rootMesh;
  44632. /**
  44633. * Gets the root mesh created by the helper.
  44634. */
  44635. readonly rootMesh: Mesh;
  44636. private _skybox;
  44637. /**
  44638. * Gets the skybox created by the helper.
  44639. */
  44640. readonly skybox: Nullable<Mesh>;
  44641. private _skyboxTexture;
  44642. /**
  44643. * Gets the skybox texture created by the helper.
  44644. */
  44645. readonly skyboxTexture: Nullable<BaseTexture>;
  44646. private _skyboxMaterial;
  44647. /**
  44648. * Gets the skybox material created by the helper.
  44649. */
  44650. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44651. private _ground;
  44652. /**
  44653. * Gets the ground mesh created by the helper.
  44654. */
  44655. readonly ground: Nullable<Mesh>;
  44656. private _groundTexture;
  44657. /**
  44658. * Gets the ground texture created by the helper.
  44659. */
  44660. readonly groundTexture: Nullable<BaseTexture>;
  44661. private _groundMirror;
  44662. /**
  44663. * Gets the ground mirror created by the helper.
  44664. */
  44665. readonly groundMirror: Nullable<MirrorTexture>;
  44666. /**
  44667. * Gets the ground mirror render list to helps pushing the meshes
  44668. * you wish in the ground reflection.
  44669. */
  44670. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44671. private _groundMaterial;
  44672. /**
  44673. * Gets the ground material created by the helper.
  44674. */
  44675. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44676. /**
  44677. * Stores the creation options.
  44678. */
  44679. private readonly _scene;
  44680. private _options;
  44681. /**
  44682. * This observable will be notified with any error during the creation of the environment,
  44683. * mainly texture creation errors.
  44684. */
  44685. onErrorObservable: Observable<{
  44686. message?: string;
  44687. exception?: any;
  44688. }>;
  44689. /**
  44690. * constructor
  44691. * @param options Defines the options we want to customize the helper
  44692. * @param scene The scene to add the material to
  44693. */
  44694. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44695. /**
  44696. * Updates the background according to the new options
  44697. * @param options
  44698. */
  44699. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44700. /**
  44701. * Sets the primary color of all the available elements.
  44702. * @param color the main color to affect to the ground and the background
  44703. */
  44704. setMainColor(color: Color3): void;
  44705. /**
  44706. * Setup the image processing according to the specified options.
  44707. */
  44708. private _setupImageProcessing;
  44709. /**
  44710. * Setup the environment texture according to the specified options.
  44711. */
  44712. private _setupEnvironmentTexture;
  44713. /**
  44714. * Setup the background according to the specified options.
  44715. */
  44716. private _setupBackground;
  44717. /**
  44718. * Get the scene sizes according to the setup.
  44719. */
  44720. private _getSceneSize;
  44721. /**
  44722. * Setup the ground according to the specified options.
  44723. */
  44724. private _setupGround;
  44725. /**
  44726. * Setup the ground material according to the specified options.
  44727. */
  44728. private _setupGroundMaterial;
  44729. /**
  44730. * Setup the ground diffuse texture according to the specified options.
  44731. */
  44732. private _setupGroundDiffuseTexture;
  44733. /**
  44734. * Setup the ground mirror texture according to the specified options.
  44735. */
  44736. private _setupGroundMirrorTexture;
  44737. /**
  44738. * Setup the ground to receive the mirror texture.
  44739. */
  44740. private _setupMirrorInGroundMaterial;
  44741. /**
  44742. * Setup the skybox according to the specified options.
  44743. */
  44744. private _setupSkybox;
  44745. /**
  44746. * Setup the skybox material according to the specified options.
  44747. */
  44748. private _setupSkyboxMaterial;
  44749. /**
  44750. * Setup the skybox reflection texture according to the specified options.
  44751. */
  44752. private _setupSkyboxReflectionTexture;
  44753. private _errorHandler;
  44754. /**
  44755. * Dispose all the elements created by the Helper.
  44756. */
  44757. dispose(): void;
  44758. }
  44759. }
  44760. declare module "babylonjs/Helpers/photoDome" {
  44761. import { Observable } from "babylonjs/Misc/observable";
  44762. import { Nullable } from "babylonjs/types";
  44763. import { Scene } from "babylonjs/scene";
  44764. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44765. import { Mesh } from "babylonjs/Meshes/mesh";
  44766. import { Texture } from "babylonjs/Materials/Textures/texture";
  44767. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44768. import "babylonjs/Meshes/Builders/sphereBuilder";
  44769. /**
  44770. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44771. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44772. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44773. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44774. */
  44775. export class PhotoDome extends TransformNode {
  44776. private _useDirectMapping;
  44777. /**
  44778. * The texture being displayed on the sphere
  44779. */
  44780. protected _photoTexture: Texture;
  44781. /**
  44782. * Gets or sets the texture being displayed on the sphere
  44783. */
  44784. photoTexture: Texture;
  44785. /**
  44786. * Observable raised when an error occured while loading the 360 image
  44787. */
  44788. onLoadErrorObservable: Observable<string>;
  44789. /**
  44790. * The skybox material
  44791. */
  44792. protected _material: BackgroundMaterial;
  44793. /**
  44794. * The surface used for the skybox
  44795. */
  44796. protected _mesh: Mesh;
  44797. /**
  44798. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44799. * Also see the options.resolution property.
  44800. */
  44801. fovMultiplier: number;
  44802. /**
  44803. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44804. * @param name Element's name, child elements will append suffixes for their own names.
  44805. * @param urlsOfPhoto defines the url of the photo to display
  44806. * @param options defines an object containing optional or exposed sub element properties
  44807. * @param onError defines a callback called when an error occured while loading the texture
  44808. */
  44809. constructor(name: string, urlOfPhoto: string, options: {
  44810. resolution?: number;
  44811. size?: number;
  44812. useDirectMapping?: boolean;
  44813. faceForward?: boolean;
  44814. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44815. /**
  44816. * Releases resources associated with this node.
  44817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44819. */
  44820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44821. }
  44822. }
  44823. declare module "babylonjs/Misc/textureTools" {
  44824. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44825. import { Texture } from "babylonjs/Materials/Textures/texture";
  44826. import { Scene } from "babylonjs/scene";
  44827. /**
  44828. * Class used to host texture specific utilities
  44829. */
  44830. export class TextureTools {
  44831. /**
  44832. * Uses the GPU to create a copy texture rescaled at a given size
  44833. * @param texture Texture to copy from
  44834. * @param width defines the desired width
  44835. * @param height defines the desired height
  44836. * @param useBilinearMode defines if bilinear mode has to be used
  44837. * @return the generated texture
  44838. */
  44839. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44840. /**
  44841. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44842. * @param scene defines the hosting scene
  44843. * @returns the environment BRDF texture
  44844. */
  44845. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44846. private static _environmentBRDFBase64Texture;
  44847. }
  44848. }
  44849. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44850. import { Nullable } from "babylonjs/types";
  44851. import { IAnimatable } from "babylonjs/Misc/tools";
  44852. import { Color3 } from "babylonjs/Maths/math";
  44853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44854. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44855. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44856. import { Engine } from "babylonjs/Engines/engine";
  44857. import { Scene } from "babylonjs/scene";
  44858. /**
  44859. * @hidden
  44860. */
  44861. export interface IMaterialClearCoatDefines {
  44862. CLEARCOAT: boolean;
  44863. CLEARCOAT_DEFAULTIOR: boolean;
  44864. CLEARCOAT_TEXTURE: boolean;
  44865. CLEARCOAT_TEXTUREDIRECTUV: number;
  44866. CLEARCOAT_BUMP: boolean;
  44867. CLEARCOAT_BUMPDIRECTUV: number;
  44868. CLEARCOAT_TINT: boolean;
  44869. CLEARCOAT_TINT_TEXTURE: boolean;
  44870. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44871. /** @hidden */
  44872. _areTexturesDirty: boolean;
  44873. }
  44874. /**
  44875. * Define the code related to the clear coat parameters of the pbr material.
  44876. */
  44877. export class PBRClearCoatConfiguration {
  44878. /**
  44879. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44880. * The default fits with a polyurethane material.
  44881. */
  44882. private static readonly _DefaultIndiceOfRefraction;
  44883. private _isEnabled;
  44884. /**
  44885. * Defines if the clear coat is enabled in the material.
  44886. */
  44887. isEnabled: boolean;
  44888. /**
  44889. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44890. */
  44891. intensity: number;
  44892. /**
  44893. * Defines the clear coat layer roughness.
  44894. */
  44895. roughness: number;
  44896. private _indiceOfRefraction;
  44897. /**
  44898. * Defines the indice of refraction of the clear coat.
  44899. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44900. * The default fits with a polyurethane material.
  44901. * Changing the default value is more performance intensive.
  44902. */
  44903. indiceOfRefraction: number;
  44904. private _texture;
  44905. /**
  44906. * Stores the clear coat values in a texture.
  44907. */
  44908. texture: Nullable<BaseTexture>;
  44909. private _bumpTexture;
  44910. /**
  44911. * Define the clear coat specific bump texture.
  44912. */
  44913. bumpTexture: Nullable<BaseTexture>;
  44914. private _isTintEnabled;
  44915. /**
  44916. * Defines if the clear coat tint is enabled in the material.
  44917. */
  44918. isTintEnabled: boolean;
  44919. /**
  44920. * Defines if the clear coat tint is enabled in the material.
  44921. * This is only use if tint is enabled
  44922. */
  44923. tintColor: Color3;
  44924. /**
  44925. * Defines if the distance at which the tint color should be found in the
  44926. * clear coat media.
  44927. * This is only use if tint is enabled
  44928. */
  44929. tintColorAtDistance: number;
  44930. /**
  44931. * Defines the clear coat layer thickness.
  44932. * This is only use if tint is enabled
  44933. */
  44934. tintThickness: number;
  44935. private _tintTexture;
  44936. /**
  44937. * Stores the clear tint values in a texture.
  44938. * rgb is tint
  44939. * a is a thickness factor
  44940. */
  44941. tintTexture: Nullable<BaseTexture>;
  44942. /** @hidden */
  44943. private _internalMarkAllSubMeshesAsTexturesDirty;
  44944. /** @hidden */
  44945. _markAllSubMeshesAsTexturesDirty(): void;
  44946. /**
  44947. * Instantiate a new istance of clear coat configuration.
  44948. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44949. */
  44950. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44951. /**
  44952. * Specifies that the submesh is ready to be used.
  44953. * @param defines the list of "defines" to update.
  44954. * @param scene defines the scene the material belongs to.
  44955. * @param engine defines the engine the material belongs to.
  44956. * @param disableBumpMap defines wether the material disables bump or not.
  44957. * @returns - boolean indicating that the submesh is ready or not.
  44958. */
  44959. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44960. /**
  44961. * Checks to see if a texture is used in the material.
  44962. * @param defines the list of "defines" to update.
  44963. * @param scene defines the scene to the material belongs to.
  44964. */
  44965. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44966. /**
  44967. * Binds the material data.
  44968. * @param uniformBuffer defines the Uniform buffer to fill in.
  44969. * @param scene defines the scene the material belongs to.
  44970. * @param engine defines the engine the material belongs to.
  44971. * @param disableBumpMap defines wether the material disables bump or not.
  44972. * @param isFrozen defines wether the material is frozen or not.
  44973. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44974. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44975. */
  44976. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44977. /**
  44978. * Checks to see if a texture is used in the material.
  44979. * @param texture - Base texture to use.
  44980. * @returns - Boolean specifying if a texture is used in the material.
  44981. */
  44982. hasTexture(texture: BaseTexture): boolean;
  44983. /**
  44984. * Returns an array of the actively used textures.
  44985. * @param activeTextures Array of BaseTextures
  44986. */
  44987. getActiveTextures(activeTextures: BaseTexture[]): void;
  44988. /**
  44989. * Returns the animatable textures.
  44990. * @param animatables Array of animatable textures.
  44991. */
  44992. getAnimatables(animatables: IAnimatable[]): void;
  44993. /**
  44994. * Disposes the resources of the material.
  44995. * @param forceDisposeTextures - Forces the disposal of all textures.
  44996. */
  44997. dispose(forceDisposeTextures?: boolean): void;
  44998. /**
  44999. * Get the current class name of the texture useful for serialization or dynamic coding.
  45000. * @returns "PBRClearCoatConfiguration"
  45001. */
  45002. getClassName(): string;
  45003. /**
  45004. * Add fallbacks to the effect fallbacks list.
  45005. * @param defines defines the Base texture to use.
  45006. * @param fallbacks defines the current fallback list.
  45007. * @param currentRank defines the current fallback rank.
  45008. * @returns the new fallback rank.
  45009. */
  45010. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45011. /**
  45012. * Add the required uniforms to the current list.
  45013. * @param uniforms defines the current uniform list.
  45014. */
  45015. static AddUniforms(uniforms: string[]): void;
  45016. /**
  45017. * Add the required samplers to the current list.
  45018. * @param samplers defines the current sampler list.
  45019. */
  45020. static AddSamplers(samplers: string[]): void;
  45021. /**
  45022. * Add the required uniforms to the current buffer.
  45023. * @param uniformBuffer defines the current uniform buffer.
  45024. */
  45025. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45026. /**
  45027. * Makes a duplicate of the current configuration into another one.
  45028. * @param clearCoatConfiguration define the config where to copy the info
  45029. */
  45030. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45031. /**
  45032. * Serializes this clear coat configuration.
  45033. * @returns - An object with the serialized config.
  45034. */
  45035. serialize(): any;
  45036. /**
  45037. * Parses a Clear Coat Configuration from a serialized object.
  45038. * @param source - Serialized object.
  45039. */
  45040. parse(source: any): void;
  45041. }
  45042. }
  45043. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45044. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45045. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45047. import { Vector2 } from "babylonjs/Maths/math";
  45048. import { Scene } from "babylonjs/scene";
  45049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45050. import { IAnimatable } from "babylonjs/Misc/tools";
  45051. import { Nullable } from "babylonjs/types";
  45052. /**
  45053. * @hidden
  45054. */
  45055. export interface IMaterialAnisotropicDefines {
  45056. ANISOTROPIC: boolean;
  45057. ANISOTROPIC_TEXTURE: boolean;
  45058. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45059. MAINUV1: boolean;
  45060. _areTexturesDirty: boolean;
  45061. _needUVs: boolean;
  45062. }
  45063. /**
  45064. * Define the code related to the anisotropic parameters of the pbr material.
  45065. */
  45066. export class PBRAnisotropicConfiguration {
  45067. private _isEnabled;
  45068. /**
  45069. * Defines if the anisotropy is enabled in the material.
  45070. */
  45071. isEnabled: boolean;
  45072. /**
  45073. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45074. */
  45075. intensity: number;
  45076. /**
  45077. * Defines if the effect is along the tangents, bitangents or in between.
  45078. * By default, the effect is "strectching" the highlights along the tangents.
  45079. */
  45080. direction: Vector2;
  45081. private _texture;
  45082. /**
  45083. * Stores the anisotropy values in a texture.
  45084. * rg is direction (like normal from -1 to 1)
  45085. * b is a intensity
  45086. */
  45087. texture: Nullable<BaseTexture>;
  45088. /** @hidden */
  45089. private _internalMarkAllSubMeshesAsTexturesDirty;
  45090. /** @hidden */
  45091. _markAllSubMeshesAsTexturesDirty(): void;
  45092. /**
  45093. * Instantiate a new istance of anisotropy configuration.
  45094. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45095. */
  45096. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45097. /**
  45098. * Specifies that the submesh is ready to be used.
  45099. * @param defines the list of "defines" to update.
  45100. * @param scene defines the scene the material belongs to.
  45101. * @returns - boolean indicating that the submesh is ready or not.
  45102. */
  45103. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45104. /**
  45105. * Checks to see if a texture is used in the material.
  45106. * @param defines the list of "defines" to update.
  45107. * @param mesh the mesh we are preparing the defines for.
  45108. * @param scene defines the scene the material belongs to.
  45109. */
  45110. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45111. /**
  45112. * Binds the material data.
  45113. * @param uniformBuffer defines the Uniform buffer to fill in.
  45114. * @param scene defines the scene the material belongs to.
  45115. * @param isFrozen defines wether the material is frozen or not.
  45116. */
  45117. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45118. /**
  45119. * Checks to see if a texture is used in the material.
  45120. * @param texture - Base texture to use.
  45121. * @returns - Boolean specifying if a texture is used in the material.
  45122. */
  45123. hasTexture(texture: BaseTexture): boolean;
  45124. /**
  45125. * Returns an array of the actively used textures.
  45126. * @param activeTextures Array of BaseTextures
  45127. */
  45128. getActiveTextures(activeTextures: BaseTexture[]): void;
  45129. /**
  45130. * Returns the animatable textures.
  45131. * @param animatables Array of animatable textures.
  45132. */
  45133. getAnimatables(animatables: IAnimatable[]): void;
  45134. /**
  45135. * Disposes the resources of the material.
  45136. * @param forceDisposeTextures - Forces the disposal of all textures.
  45137. */
  45138. dispose(forceDisposeTextures?: boolean): void;
  45139. /**
  45140. * Get the current class name of the texture useful for serialization or dynamic coding.
  45141. * @returns "PBRAnisotropicConfiguration"
  45142. */
  45143. getClassName(): string;
  45144. /**
  45145. * Add fallbacks to the effect fallbacks list.
  45146. * @param defines defines the Base texture to use.
  45147. * @param fallbacks defines the current fallback list.
  45148. * @param currentRank defines the current fallback rank.
  45149. * @returns the new fallback rank.
  45150. */
  45151. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45152. /**
  45153. * Add the required uniforms to the current list.
  45154. * @param uniforms defines the current uniform list.
  45155. */
  45156. static AddUniforms(uniforms: string[]): void;
  45157. /**
  45158. * Add the required uniforms to the current buffer.
  45159. * @param uniformBuffer defines the current uniform buffer.
  45160. */
  45161. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45162. /**
  45163. * Add the required samplers to the current list.
  45164. * @param samplers defines the current sampler list.
  45165. */
  45166. static AddSamplers(samplers: string[]): void;
  45167. /**
  45168. * Makes a duplicate of the current configuration into another one.
  45169. * @param anisotropicConfiguration define the config where to copy the info
  45170. */
  45171. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45172. /**
  45173. * Serializes this anisotropy configuration.
  45174. * @returns - An object with the serialized config.
  45175. */
  45176. serialize(): any;
  45177. /**
  45178. * Parses a anisotropy Configuration from a serialized object.
  45179. * @param source - Serialized object.
  45180. */
  45181. parse(source: any): void;
  45182. }
  45183. }
  45184. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45185. /**
  45186. * @hidden
  45187. */
  45188. export interface IMaterialBRDFDefines {
  45189. BRDF_V_HEIGHT_CORRELATED: boolean;
  45190. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45191. /** @hidden */
  45192. _areMiscDirty: boolean;
  45193. }
  45194. /**
  45195. * Define the code related to the BRDF parameters of the pbr material.
  45196. */
  45197. export class PBRBRDFConfiguration {
  45198. /**
  45199. * Default value used for the energy conservation.
  45200. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45201. */
  45202. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45203. /**
  45204. * Default value used for the Smith Visibility Height Correlated mode.
  45205. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45206. */
  45207. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45208. private _useEnergyConservation;
  45209. /**
  45210. * Defines if the material uses energy conservation.
  45211. */
  45212. useEnergyConservation: boolean;
  45213. private _useSmithVisibilityHeightCorrelated;
  45214. /**
  45215. * LEGACY Mode set to false
  45216. * Defines if the material uses height smith correlated visibility term.
  45217. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45218. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45219. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45220. * Not relying on height correlated will also disable energy conservation.
  45221. */
  45222. useSmithVisibilityHeightCorrelated: boolean;
  45223. /** @hidden */
  45224. private _internalMarkAllSubMeshesAsMiscDirty;
  45225. /** @hidden */
  45226. _markAllSubMeshesAsMiscDirty(): void;
  45227. /**
  45228. * Instantiate a new istance of clear coat configuration.
  45229. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45230. */
  45231. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45232. /**
  45233. * Checks to see if a texture is used in the material.
  45234. * @param defines the list of "defines" to update.
  45235. */
  45236. prepareDefines(defines: IMaterialBRDFDefines): void;
  45237. /**
  45238. * Get the current class name of the texture useful for serialization or dynamic coding.
  45239. * @returns "PBRClearCoatConfiguration"
  45240. */
  45241. getClassName(): string;
  45242. /**
  45243. * Makes a duplicate of the current configuration into another one.
  45244. * @param brdfConfiguration define the config where to copy the info
  45245. */
  45246. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45247. /**
  45248. * Serializes this BRDF configuration.
  45249. * @returns - An object with the serialized config.
  45250. */
  45251. serialize(): any;
  45252. /**
  45253. * Parses a BRDF Configuration from a serialized object.
  45254. * @param source - Serialized object.
  45255. */
  45256. parse(source: any): void;
  45257. }
  45258. }
  45259. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45260. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45261. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45262. import { Color3 } from "babylonjs/Maths/math";
  45263. import { Scene } from "babylonjs/scene";
  45264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45265. import { IAnimatable } from "babylonjs/Misc/tools";
  45266. import { Nullable } from "babylonjs/types";
  45267. /**
  45268. * @hidden
  45269. */
  45270. export interface IMaterialSheenDefines {
  45271. SHEEN: boolean;
  45272. SHEEN_TEXTURE: boolean;
  45273. SHEEN_TEXTUREDIRECTUV: number;
  45274. SHEEN_LINKWITHALBEDO: boolean;
  45275. /** @hidden */
  45276. _areTexturesDirty: boolean;
  45277. }
  45278. /**
  45279. * Define the code related to the Sheen parameters of the pbr material.
  45280. */
  45281. export class PBRSheenConfiguration {
  45282. private _isEnabled;
  45283. /**
  45284. * Defines if the material uses sheen.
  45285. */
  45286. isEnabled: boolean;
  45287. private _linkSheenWithAlbedo;
  45288. /**
  45289. * Defines if the sheen is linked to the sheen color.
  45290. */
  45291. linkSheenWithAlbedo: boolean;
  45292. /**
  45293. * Defines the sheen intensity.
  45294. */
  45295. intensity: number;
  45296. /**
  45297. * Defines the sheen color.
  45298. */
  45299. color: Color3;
  45300. private _texture;
  45301. /**
  45302. * Stores the sheen tint values in a texture.
  45303. * rgb is tint
  45304. * a is a intensity
  45305. */
  45306. texture: Nullable<BaseTexture>;
  45307. /** @hidden */
  45308. private _internalMarkAllSubMeshesAsTexturesDirty;
  45309. /** @hidden */
  45310. _markAllSubMeshesAsTexturesDirty(): void;
  45311. /**
  45312. * Instantiate a new istance of clear coat configuration.
  45313. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45314. */
  45315. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45316. /**
  45317. * Specifies that the submesh is ready to be used.
  45318. * @param defines the list of "defines" to update.
  45319. * @param scene defines the scene the material belongs to.
  45320. * @returns - boolean indicating that the submesh is ready or not.
  45321. */
  45322. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45323. /**
  45324. * Checks to see if a texture is used in the material.
  45325. * @param defines the list of "defines" to update.
  45326. * @param scene defines the scene the material belongs to.
  45327. */
  45328. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45329. /**
  45330. * Binds the material data.
  45331. * @param uniformBuffer defines the Uniform buffer to fill in.
  45332. * @param scene defines the scene the material belongs to.
  45333. * @param isFrozen defines wether the material is frozen or not.
  45334. */
  45335. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45336. /**
  45337. * Checks to see if a texture is used in the material.
  45338. * @param texture - Base texture to use.
  45339. * @returns - Boolean specifying if a texture is used in the material.
  45340. */
  45341. hasTexture(texture: BaseTexture): boolean;
  45342. /**
  45343. * Returns an array of the actively used textures.
  45344. * @param activeTextures Array of BaseTextures
  45345. */
  45346. getActiveTextures(activeTextures: BaseTexture[]): void;
  45347. /**
  45348. * Returns the animatable textures.
  45349. * @param animatables Array of animatable textures.
  45350. */
  45351. getAnimatables(animatables: IAnimatable[]): void;
  45352. /**
  45353. * Disposes the resources of the material.
  45354. * @param forceDisposeTextures - Forces the disposal of all textures.
  45355. */
  45356. dispose(forceDisposeTextures?: boolean): void;
  45357. /**
  45358. * Get the current class name of the texture useful for serialization or dynamic coding.
  45359. * @returns "PBRSheenConfiguration"
  45360. */
  45361. getClassName(): string;
  45362. /**
  45363. * Add fallbacks to the effect fallbacks list.
  45364. * @param defines defines the Base texture to use.
  45365. * @param fallbacks defines the current fallback list.
  45366. * @param currentRank defines the current fallback rank.
  45367. * @returns the new fallback rank.
  45368. */
  45369. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45370. /**
  45371. * Add the required uniforms to the current list.
  45372. * @param uniforms defines the current uniform list.
  45373. */
  45374. static AddUniforms(uniforms: string[]): void;
  45375. /**
  45376. * Add the required uniforms to the current buffer.
  45377. * @param uniformBuffer defines the current uniform buffer.
  45378. */
  45379. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45380. /**
  45381. * Add the required samplers to the current list.
  45382. * @param samplers defines the current sampler list.
  45383. */
  45384. static AddSamplers(samplers: string[]): void;
  45385. /**
  45386. * Makes a duplicate of the current configuration into another one.
  45387. * @param sheenConfiguration define the config where to copy the info
  45388. */
  45389. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45390. /**
  45391. * Serializes this BRDF configuration.
  45392. * @returns - An object with the serialized config.
  45393. */
  45394. serialize(): any;
  45395. /**
  45396. * Parses a Sheen Configuration from a serialized object.
  45397. * @param source - Serialized object.
  45398. */
  45399. parse(source: any): void;
  45400. }
  45401. }
  45402. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45403. /** @hidden */
  45404. export var pbrFragmentDeclaration: {
  45405. name: string;
  45406. shader: string;
  45407. };
  45408. }
  45409. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45410. /** @hidden */
  45411. export var pbrUboDeclaration: {
  45412. name: string;
  45413. shader: string;
  45414. };
  45415. }
  45416. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  45417. /** @hidden */
  45418. export var pbrFragmentExtraDeclaration: {
  45419. name: string;
  45420. shader: string;
  45421. };
  45422. }
  45423. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  45424. /** @hidden */
  45425. export var pbrFragmentSamplersDeclaration: {
  45426. name: string;
  45427. shader: string;
  45428. };
  45429. }
  45430. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  45431. /** @hidden */
  45432. export var pbrHelperFunctions: {
  45433. name: string;
  45434. shader: string;
  45435. };
  45436. }
  45437. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45438. /** @hidden */
  45439. export var harmonicsFunctions: {
  45440. name: string;
  45441. shader: string;
  45442. };
  45443. }
  45444. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  45445. /** @hidden */
  45446. export var pbrDirectLightingSetupFunctions: {
  45447. name: string;
  45448. shader: string;
  45449. };
  45450. }
  45451. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  45452. /** @hidden */
  45453. export var pbrDirectLightingFalloffFunctions: {
  45454. name: string;
  45455. shader: string;
  45456. };
  45457. }
  45458. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  45459. /** @hidden */
  45460. export var pbrBRDFFunctions: {
  45461. name: string;
  45462. shader: string;
  45463. };
  45464. }
  45465. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  45466. /** @hidden */
  45467. export var pbrDirectLightingFunctions: {
  45468. name: string;
  45469. shader: string;
  45470. };
  45471. }
  45472. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  45473. /** @hidden */
  45474. export var pbrIBLFunctions: {
  45475. name: string;
  45476. shader: string;
  45477. };
  45478. }
  45479. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45480. /** @hidden */
  45481. export var pbrDebug: {
  45482. name: string;
  45483. shader: string;
  45484. };
  45485. }
  45486. declare module "babylonjs/Shaders/pbr.fragment" {
  45487. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45488. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45489. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  45490. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45491. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45492. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  45493. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45494. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45495. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45496. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45497. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45498. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  45499. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45500. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45501. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45502. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  45503. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  45504. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  45505. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  45506. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  45507. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45508. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45509. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45510. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45511. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45512. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45513. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45514. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45515. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45516. /** @hidden */
  45517. export var pbrPixelShader: {
  45518. name: string;
  45519. shader: string;
  45520. };
  45521. }
  45522. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45523. /** @hidden */
  45524. export var pbrVertexDeclaration: {
  45525. name: string;
  45526. shader: string;
  45527. };
  45528. }
  45529. declare module "babylonjs/Shaders/pbr.vertex" {
  45530. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45531. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45532. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45533. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45534. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45535. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45536. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45537. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45538. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45539. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45540. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45541. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45543. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45545. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45546. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45547. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45548. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45549. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45550. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45551. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45552. /** @hidden */
  45553. export var pbrVertexShader: {
  45554. name: string;
  45555. shader: string;
  45556. };
  45557. }
  45558. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45559. import { IAnimatable } from "babylonjs/Misc/tools";
  45560. import { Nullable } from "babylonjs/types";
  45561. import { Scene } from "babylonjs/scene";
  45562. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45565. import { Mesh } from "babylonjs/Meshes/mesh";
  45566. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45567. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45568. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45569. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45570. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45571. import { Material } from "babylonjs/Materials/material";
  45572. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45574. import "babylonjs/Shaders/pbr.fragment";
  45575. import "babylonjs/Shaders/pbr.vertex";
  45576. /**
  45577. * The Physically based material base class of BJS.
  45578. *
  45579. * This offers the main features of a standard PBR material.
  45580. * For more information, please refer to the documentation :
  45581. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45582. */
  45583. export abstract class PBRBaseMaterial extends PushMaterial {
  45584. /**
  45585. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45586. */
  45587. static readonly PBRMATERIAL_OPAQUE: number;
  45588. /**
  45589. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45590. */
  45591. static readonly PBRMATERIAL_ALPHATEST: number;
  45592. /**
  45593. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45594. */
  45595. static readonly PBRMATERIAL_ALPHABLEND: number;
  45596. /**
  45597. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45598. * They are also discarded below the alpha cutoff threshold to improve performances.
  45599. */
  45600. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45601. /**
  45602. * Defines the default value of how much AO map is occluding the analytical lights
  45603. * (point spot...).
  45604. */
  45605. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45606. /**
  45607. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45608. */
  45609. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45610. /**
  45611. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45612. * to enhance interoperability with other engines.
  45613. */
  45614. static readonly LIGHTFALLOFF_GLTF: number;
  45615. /**
  45616. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45617. * to enhance interoperability with other materials.
  45618. */
  45619. static readonly LIGHTFALLOFF_STANDARD: number;
  45620. /**
  45621. * Intensity of the direct lights e.g. the four lights available in your scene.
  45622. * This impacts both the direct diffuse and specular highlights.
  45623. */
  45624. protected _directIntensity: number;
  45625. /**
  45626. * Intensity of the emissive part of the material.
  45627. * This helps controlling the emissive effect without modifying the emissive color.
  45628. */
  45629. protected _emissiveIntensity: number;
  45630. /**
  45631. * Intensity of the environment e.g. how much the environment will light the object
  45632. * either through harmonics for rough material or through the refelction for shiny ones.
  45633. */
  45634. protected _environmentIntensity: number;
  45635. /**
  45636. * This is a special control allowing the reduction of the specular highlights coming from the
  45637. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45638. */
  45639. protected _specularIntensity: number;
  45640. /**
  45641. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45642. */
  45643. private _lightingInfos;
  45644. /**
  45645. * Debug Control allowing disabling the bump map on this material.
  45646. */
  45647. protected _disableBumpMap: boolean;
  45648. /**
  45649. * AKA Diffuse Texture in standard nomenclature.
  45650. */
  45651. protected _albedoTexture: BaseTexture;
  45652. /**
  45653. * AKA Occlusion Texture in other nomenclature.
  45654. */
  45655. protected _ambientTexture: BaseTexture;
  45656. /**
  45657. * AKA Occlusion Texture Intensity in other nomenclature.
  45658. */
  45659. protected _ambientTextureStrength: number;
  45660. /**
  45661. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45662. * 1 means it completely occludes it
  45663. * 0 mean it has no impact
  45664. */
  45665. protected _ambientTextureImpactOnAnalyticalLights: number;
  45666. /**
  45667. * Stores the alpha values in a texture.
  45668. */
  45669. protected _opacityTexture: BaseTexture;
  45670. /**
  45671. * Stores the reflection values in a texture.
  45672. */
  45673. protected _reflectionTexture: BaseTexture;
  45674. /**
  45675. * Stores the refraction values in a texture.
  45676. */
  45677. protected _refractionTexture: BaseTexture;
  45678. /**
  45679. * Stores the emissive values in a texture.
  45680. */
  45681. protected _emissiveTexture: BaseTexture;
  45682. /**
  45683. * AKA Specular texture in other nomenclature.
  45684. */
  45685. protected _reflectivityTexture: BaseTexture;
  45686. /**
  45687. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45688. */
  45689. protected _metallicTexture: BaseTexture;
  45690. /**
  45691. * Specifies the metallic scalar of the metallic/roughness workflow.
  45692. * Can also be used to scale the metalness values of the metallic texture.
  45693. */
  45694. protected _metallic: Nullable<number>;
  45695. /**
  45696. * Specifies the roughness scalar of the metallic/roughness workflow.
  45697. * Can also be used to scale the roughness values of the metallic texture.
  45698. */
  45699. protected _roughness: Nullable<number>;
  45700. /**
  45701. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45702. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45703. */
  45704. protected _microSurfaceTexture: BaseTexture;
  45705. /**
  45706. * Stores surface normal data used to displace a mesh in a texture.
  45707. */
  45708. protected _bumpTexture: BaseTexture;
  45709. /**
  45710. * Stores the pre-calculated light information of a mesh in a texture.
  45711. */
  45712. protected _lightmapTexture: BaseTexture;
  45713. /**
  45714. * The color of a material in ambient lighting.
  45715. */
  45716. protected _ambientColor: Color3;
  45717. /**
  45718. * AKA Diffuse Color in other nomenclature.
  45719. */
  45720. protected _albedoColor: Color3;
  45721. /**
  45722. * AKA Specular Color in other nomenclature.
  45723. */
  45724. protected _reflectivityColor: Color3;
  45725. /**
  45726. * The color applied when light is reflected from a material.
  45727. */
  45728. protected _reflectionColor: Color3;
  45729. /**
  45730. * The color applied when light is emitted from a material.
  45731. */
  45732. protected _emissiveColor: Color3;
  45733. /**
  45734. * AKA Glossiness in other nomenclature.
  45735. */
  45736. protected _microSurface: number;
  45737. /**
  45738. * source material index of refraction (IOR)' / 'destination material IOR.
  45739. */
  45740. protected _indexOfRefraction: number;
  45741. /**
  45742. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45743. */
  45744. protected _invertRefractionY: boolean;
  45745. /**
  45746. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45747. * Materials half opaque for instance using refraction could benefit from this control.
  45748. */
  45749. protected _linkRefractionWithTransparency: boolean;
  45750. /**
  45751. * Specifies that the material will use the light map as a show map.
  45752. */
  45753. protected _useLightmapAsShadowmap: boolean;
  45754. /**
  45755. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45756. * makes the reflect vector face the model (under horizon).
  45757. */
  45758. protected _useHorizonOcclusion: boolean;
  45759. /**
  45760. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45761. * too much the area relying on ambient texture to define their ambient occlusion.
  45762. */
  45763. protected _useRadianceOcclusion: boolean;
  45764. /**
  45765. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45766. */
  45767. protected _useAlphaFromAlbedoTexture: boolean;
  45768. /**
  45769. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45770. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45771. */
  45772. protected _useSpecularOverAlpha: boolean;
  45773. /**
  45774. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45775. */
  45776. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45777. /**
  45778. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45779. */
  45780. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45781. /**
  45782. * Specifies if the metallic texture contains the roughness information in its green channel.
  45783. */
  45784. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45785. /**
  45786. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45787. */
  45788. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45789. /**
  45790. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45791. */
  45792. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45793. /**
  45794. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45795. */
  45796. protected _useAmbientInGrayScale: boolean;
  45797. /**
  45798. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45799. * The material will try to infer what glossiness each pixel should be.
  45800. */
  45801. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45802. /**
  45803. * Defines the falloff type used in this material.
  45804. * It by default is Physical.
  45805. */
  45806. protected _lightFalloff: number;
  45807. /**
  45808. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45809. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45810. */
  45811. protected _useRadianceOverAlpha: boolean;
  45812. /**
  45813. * Allows using an object space normal map (instead of tangent space).
  45814. */
  45815. protected _useObjectSpaceNormalMap: boolean;
  45816. /**
  45817. * Allows using the bump map in parallax mode.
  45818. */
  45819. protected _useParallax: boolean;
  45820. /**
  45821. * Allows using the bump map in parallax occlusion mode.
  45822. */
  45823. protected _useParallaxOcclusion: boolean;
  45824. /**
  45825. * Controls the scale bias of the parallax mode.
  45826. */
  45827. protected _parallaxScaleBias: number;
  45828. /**
  45829. * If sets to true, disables all the lights affecting the material.
  45830. */
  45831. protected _disableLighting: boolean;
  45832. /**
  45833. * Number of Simultaneous lights allowed on the material.
  45834. */
  45835. protected _maxSimultaneousLights: number;
  45836. /**
  45837. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45838. */
  45839. protected _invertNormalMapX: boolean;
  45840. /**
  45841. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45842. */
  45843. protected _invertNormalMapY: boolean;
  45844. /**
  45845. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45846. */
  45847. protected _twoSidedLighting: boolean;
  45848. /**
  45849. * Defines the alpha limits in alpha test mode.
  45850. */
  45851. protected _alphaCutOff: number;
  45852. /**
  45853. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45854. */
  45855. protected _forceAlphaTest: boolean;
  45856. /**
  45857. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45858. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45859. */
  45860. protected _useAlphaFresnel: boolean;
  45861. /**
  45862. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45863. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45864. */
  45865. protected _useLinearAlphaFresnel: boolean;
  45866. /**
  45867. * The transparency mode of the material.
  45868. */
  45869. protected _transparencyMode: Nullable<number>;
  45870. /**
  45871. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45872. * from cos thetav and roughness:
  45873. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45874. */
  45875. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45876. /**
  45877. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45878. */
  45879. protected _forceIrradianceInFragment: boolean;
  45880. /**
  45881. * Force normal to face away from face.
  45882. */
  45883. protected _forceNormalForward: boolean;
  45884. /**
  45885. * Enables specular anti aliasing in the PBR shader.
  45886. * It will both interacts on the Geometry for analytical and IBL lighting.
  45887. * It also prefilter the roughness map based on the bump values.
  45888. */
  45889. protected _enableSpecularAntiAliasing: boolean;
  45890. /**
  45891. * Default configuration related to image processing available in the PBR Material.
  45892. */
  45893. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45894. /**
  45895. * Keep track of the image processing observer to allow dispose and replace.
  45896. */
  45897. private _imageProcessingObserver;
  45898. /**
  45899. * Attaches a new image processing configuration to the PBR Material.
  45900. * @param configuration
  45901. */
  45902. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45903. /**
  45904. * Stores the available render targets.
  45905. */
  45906. private _renderTargets;
  45907. /**
  45908. * Sets the global ambient color for the material used in lighting calculations.
  45909. */
  45910. private _globalAmbientColor;
  45911. /**
  45912. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45913. */
  45914. private _useLogarithmicDepth;
  45915. /**
  45916. * If set to true, no lighting calculations will be applied.
  45917. */
  45918. private _unlit;
  45919. private _debugMode;
  45920. /**
  45921. * @hidden
  45922. * This is reserved for the inspector.
  45923. * Defines the material debug mode.
  45924. * It helps seeing only some components of the material while troubleshooting.
  45925. */
  45926. debugMode: number;
  45927. /**
  45928. * @hidden
  45929. * This is reserved for the inspector.
  45930. * Specify from where on screen the debug mode should start.
  45931. * The value goes from -1 (full screen) to 1 (not visible)
  45932. * It helps with side by side comparison against the final render
  45933. * This defaults to -1
  45934. */
  45935. private debugLimit;
  45936. /**
  45937. * @hidden
  45938. * This is reserved for the inspector.
  45939. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45940. * You can use the factor to better multiply the final value.
  45941. */
  45942. private debugFactor;
  45943. /**
  45944. * Defines the clear coat layer parameters for the material.
  45945. */
  45946. readonly clearCoat: PBRClearCoatConfiguration;
  45947. /**
  45948. * Defines the anisotropic parameters for the material.
  45949. */
  45950. readonly anisotropy: PBRAnisotropicConfiguration;
  45951. /**
  45952. * Defines the BRDF parameters for the material.
  45953. */
  45954. readonly brdf: PBRBRDFConfiguration;
  45955. /**
  45956. * Defines the Sheen parameters for the material.
  45957. */
  45958. readonly sheen: PBRSheenConfiguration;
  45959. /**
  45960. * Instantiates a new PBRMaterial instance.
  45961. *
  45962. * @param name The material name
  45963. * @param scene The scene the material will be use in.
  45964. */
  45965. constructor(name: string, scene: Scene);
  45966. /**
  45967. * Gets a boolean indicating that current material needs to register RTT
  45968. */
  45969. readonly hasRenderTargetTextures: boolean;
  45970. /**
  45971. * Gets the name of the material class.
  45972. */
  45973. getClassName(): string;
  45974. /**
  45975. * Gets the name of the material shader.
  45976. * @returns - string that specifies the shader program of the material.
  45977. */
  45978. getShaderName(): string;
  45979. /**
  45980. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45981. */
  45982. /**
  45983. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45984. */
  45985. useLogarithmicDepth: boolean;
  45986. /**
  45987. * Gets the current transparency mode.
  45988. */
  45989. /**
  45990. * Sets the transparency mode of the material.
  45991. *
  45992. * | Value | Type | Description |
  45993. * | ----- | ----------------------------------- | ----------- |
  45994. * | 0 | OPAQUE | |
  45995. * | 1 | ALPHATEST | |
  45996. * | 2 | ALPHABLEND | |
  45997. * | 3 | ALPHATESTANDBLEND | |
  45998. *
  45999. */
  46000. transparencyMode: Nullable<number>;
  46001. /**
  46002. * Returns true if alpha blending should be disabled.
  46003. */
  46004. private readonly _disableAlphaBlending;
  46005. /**
  46006. * Specifies whether or not this material should be rendered in alpha blend mode.
  46007. */
  46008. needAlphaBlending(): boolean;
  46009. /**
  46010. * Specifies if the mesh will require alpha blending.
  46011. * @param mesh - BJS mesh.
  46012. */
  46013. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46014. /**
  46015. * Specifies whether or not this material should be rendered in alpha test mode.
  46016. */
  46017. needAlphaTesting(): boolean;
  46018. /**
  46019. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46020. */
  46021. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46022. /**
  46023. * Gets the texture used for the alpha test.
  46024. */
  46025. getAlphaTestTexture(): BaseTexture;
  46026. /**
  46027. * Specifies that the submesh is ready to be used.
  46028. * @param mesh - BJS mesh.
  46029. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46030. * @param useInstances - Specifies that instances should be used.
  46031. * @returns - boolean indicating that the submesh is ready or not.
  46032. */
  46033. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46034. /**
  46035. * Specifies if the material uses metallic roughness workflow.
  46036. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46037. */
  46038. isMetallicWorkflow(): boolean;
  46039. private _prepareEffect;
  46040. private _prepareDefines;
  46041. /**
  46042. * Force shader compilation
  46043. */
  46044. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46045. clipPlane: boolean;
  46046. }>): void;
  46047. /**
  46048. * Initializes the uniform buffer layout for the shader.
  46049. */
  46050. buildUniformLayout(): void;
  46051. /**
  46052. * Unbinds the textures.
  46053. */
  46054. unbind(): void;
  46055. /**
  46056. * Binds the submesh data.
  46057. * @param world - The world matrix.
  46058. * @param mesh - The BJS mesh.
  46059. * @param subMesh - A submesh of the BJS mesh.
  46060. */
  46061. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46062. /**
  46063. * Returns the animatable textures.
  46064. * @returns - Array of animatable textures.
  46065. */
  46066. getAnimatables(): IAnimatable[];
  46067. /**
  46068. * Returns the texture used for reflections.
  46069. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46070. */
  46071. private _getReflectionTexture;
  46072. /**
  46073. * Returns the texture used for refraction or null if none is used.
  46074. * @returns - Refection texture if present. If no refraction texture and refraction
  46075. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46076. */
  46077. private _getRefractionTexture;
  46078. /**
  46079. * Returns an array of the actively used textures.
  46080. * @returns - Array of BaseTextures
  46081. */
  46082. getActiveTextures(): BaseTexture[];
  46083. /**
  46084. * Checks to see if a texture is used in the material.
  46085. * @param texture - Base texture to use.
  46086. * @returns - Boolean specifying if a texture is used in the material.
  46087. */
  46088. hasTexture(texture: BaseTexture): boolean;
  46089. /**
  46090. * Disposes the resources of the material.
  46091. * @param forceDisposeEffect - Forces the disposal of effects.
  46092. * @param forceDisposeTextures - Forces the disposal of all textures.
  46093. */
  46094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46095. }
  46096. }
  46097. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46098. import { Nullable } from "babylonjs/types";
  46099. import { Scene } from "babylonjs/scene";
  46100. import { Color3 } from "babylonjs/Maths/math";
  46101. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46102. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46104. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46105. /**
  46106. * The Physically based material of BJS.
  46107. *
  46108. * This offers the main features of a standard PBR material.
  46109. * For more information, please refer to the documentation :
  46110. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46111. */
  46112. export class PBRMaterial extends PBRBaseMaterial {
  46113. /**
  46114. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46115. */
  46116. static readonly PBRMATERIAL_OPAQUE: number;
  46117. /**
  46118. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46119. */
  46120. static readonly PBRMATERIAL_ALPHATEST: number;
  46121. /**
  46122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46123. */
  46124. static readonly PBRMATERIAL_ALPHABLEND: number;
  46125. /**
  46126. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46127. * They are also discarded below the alpha cutoff threshold to improve performances.
  46128. */
  46129. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46130. /**
  46131. * Defines the default value of how much AO map is occluding the analytical lights
  46132. * (point spot...).
  46133. */
  46134. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46135. /**
  46136. * Intensity of the direct lights e.g. the four lights available in your scene.
  46137. * This impacts both the direct diffuse and specular highlights.
  46138. */
  46139. directIntensity: number;
  46140. /**
  46141. * Intensity of the emissive part of the material.
  46142. * This helps controlling the emissive effect without modifying the emissive color.
  46143. */
  46144. emissiveIntensity: number;
  46145. /**
  46146. * Intensity of the environment e.g. how much the environment will light the object
  46147. * either through harmonics for rough material or through the refelction for shiny ones.
  46148. */
  46149. environmentIntensity: number;
  46150. /**
  46151. * This is a special control allowing the reduction of the specular highlights coming from the
  46152. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46153. */
  46154. specularIntensity: number;
  46155. /**
  46156. * Debug Control allowing disabling the bump map on this material.
  46157. */
  46158. disableBumpMap: boolean;
  46159. /**
  46160. * AKA Diffuse Texture in standard nomenclature.
  46161. */
  46162. albedoTexture: BaseTexture;
  46163. /**
  46164. * AKA Occlusion Texture in other nomenclature.
  46165. */
  46166. ambientTexture: BaseTexture;
  46167. /**
  46168. * AKA Occlusion Texture Intensity in other nomenclature.
  46169. */
  46170. ambientTextureStrength: number;
  46171. /**
  46172. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46173. * 1 means it completely occludes it
  46174. * 0 mean it has no impact
  46175. */
  46176. ambientTextureImpactOnAnalyticalLights: number;
  46177. /**
  46178. * Stores the alpha values in a texture.
  46179. */
  46180. opacityTexture: BaseTexture;
  46181. /**
  46182. * Stores the reflection values in a texture.
  46183. */
  46184. reflectionTexture: Nullable<BaseTexture>;
  46185. /**
  46186. * Stores the emissive values in a texture.
  46187. */
  46188. emissiveTexture: BaseTexture;
  46189. /**
  46190. * AKA Specular texture in other nomenclature.
  46191. */
  46192. reflectivityTexture: BaseTexture;
  46193. /**
  46194. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46195. */
  46196. metallicTexture: BaseTexture;
  46197. /**
  46198. * Specifies the metallic scalar of the metallic/roughness workflow.
  46199. * Can also be used to scale the metalness values of the metallic texture.
  46200. */
  46201. metallic: Nullable<number>;
  46202. /**
  46203. * Specifies the roughness scalar of the metallic/roughness workflow.
  46204. * Can also be used to scale the roughness values of the metallic texture.
  46205. */
  46206. roughness: Nullable<number>;
  46207. /**
  46208. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46209. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46210. */
  46211. microSurfaceTexture: BaseTexture;
  46212. /**
  46213. * Stores surface normal data used to displace a mesh in a texture.
  46214. */
  46215. bumpTexture: BaseTexture;
  46216. /**
  46217. * Stores the pre-calculated light information of a mesh in a texture.
  46218. */
  46219. lightmapTexture: BaseTexture;
  46220. /**
  46221. * Stores the refracted light information in a texture.
  46222. */
  46223. refractionTexture: BaseTexture;
  46224. /**
  46225. * The color of a material in ambient lighting.
  46226. */
  46227. ambientColor: Color3;
  46228. /**
  46229. * AKA Diffuse Color in other nomenclature.
  46230. */
  46231. albedoColor: Color3;
  46232. /**
  46233. * AKA Specular Color in other nomenclature.
  46234. */
  46235. reflectivityColor: Color3;
  46236. /**
  46237. * The color reflected from the material.
  46238. */
  46239. reflectionColor: Color3;
  46240. /**
  46241. * The color emitted from the material.
  46242. */
  46243. emissiveColor: Color3;
  46244. /**
  46245. * AKA Glossiness in other nomenclature.
  46246. */
  46247. microSurface: number;
  46248. /**
  46249. * source material index of refraction (IOR)' / 'destination material IOR.
  46250. */
  46251. indexOfRefraction: number;
  46252. /**
  46253. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46254. */
  46255. invertRefractionY: boolean;
  46256. /**
  46257. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46258. * Materials half opaque for instance using refraction could benefit from this control.
  46259. */
  46260. linkRefractionWithTransparency: boolean;
  46261. /**
  46262. * If true, the light map contains occlusion information instead of lighting info.
  46263. */
  46264. useLightmapAsShadowmap: boolean;
  46265. /**
  46266. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46267. */
  46268. useAlphaFromAlbedoTexture: boolean;
  46269. /**
  46270. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46271. */
  46272. forceAlphaTest: boolean;
  46273. /**
  46274. * Defines the alpha limits in alpha test mode.
  46275. */
  46276. alphaCutOff: number;
  46277. /**
  46278. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46279. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46280. */
  46281. useSpecularOverAlpha: boolean;
  46282. /**
  46283. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46284. */
  46285. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46286. /**
  46287. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46288. */
  46289. useRoughnessFromMetallicTextureAlpha: boolean;
  46290. /**
  46291. * Specifies if the metallic texture contains the roughness information in its green channel.
  46292. */
  46293. useRoughnessFromMetallicTextureGreen: boolean;
  46294. /**
  46295. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46296. */
  46297. useMetallnessFromMetallicTextureBlue: boolean;
  46298. /**
  46299. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46300. */
  46301. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46302. /**
  46303. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46304. */
  46305. useAmbientInGrayScale: boolean;
  46306. /**
  46307. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46308. * The material will try to infer what glossiness each pixel should be.
  46309. */
  46310. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46311. /**
  46312. * BJS is using an harcoded light falloff based on a manually sets up range.
  46313. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46314. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46315. */
  46316. /**
  46317. * BJS is using an harcoded light falloff based on a manually sets up range.
  46318. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46319. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46320. */
  46321. usePhysicalLightFalloff: boolean;
  46322. /**
  46323. * In order to support the falloff compatibility with gltf, a special mode has been added
  46324. * to reproduce the gltf light falloff.
  46325. */
  46326. /**
  46327. * In order to support the falloff compatibility with gltf, a special mode has been added
  46328. * to reproduce the gltf light falloff.
  46329. */
  46330. useGLTFLightFalloff: boolean;
  46331. /**
  46332. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46333. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46334. */
  46335. useRadianceOverAlpha: boolean;
  46336. /**
  46337. * Allows using an object space normal map (instead of tangent space).
  46338. */
  46339. useObjectSpaceNormalMap: boolean;
  46340. /**
  46341. * Allows using the bump map in parallax mode.
  46342. */
  46343. useParallax: boolean;
  46344. /**
  46345. * Allows using the bump map in parallax occlusion mode.
  46346. */
  46347. useParallaxOcclusion: boolean;
  46348. /**
  46349. * Controls the scale bias of the parallax mode.
  46350. */
  46351. parallaxScaleBias: number;
  46352. /**
  46353. * If sets to true, disables all the lights affecting the material.
  46354. */
  46355. disableLighting: boolean;
  46356. /**
  46357. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46358. */
  46359. forceIrradianceInFragment: boolean;
  46360. /**
  46361. * Number of Simultaneous lights allowed on the material.
  46362. */
  46363. maxSimultaneousLights: number;
  46364. /**
  46365. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46366. */
  46367. invertNormalMapX: boolean;
  46368. /**
  46369. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46370. */
  46371. invertNormalMapY: boolean;
  46372. /**
  46373. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46374. */
  46375. twoSidedLighting: boolean;
  46376. /**
  46377. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46378. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46379. */
  46380. useAlphaFresnel: boolean;
  46381. /**
  46382. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46383. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46384. */
  46385. useLinearAlphaFresnel: boolean;
  46386. /**
  46387. * Let user defines the brdf lookup texture used for IBL.
  46388. * A default 8bit version is embedded but you could point at :
  46389. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46390. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46391. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46392. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46393. */
  46394. environmentBRDFTexture: Nullable<BaseTexture>;
  46395. /**
  46396. * Force normal to face away from face.
  46397. */
  46398. forceNormalForward: boolean;
  46399. /**
  46400. * Enables specular anti aliasing in the PBR shader.
  46401. * It will both interacts on the Geometry for analytical and IBL lighting.
  46402. * It also prefilter the roughness map based on the bump values.
  46403. */
  46404. enableSpecularAntiAliasing: boolean;
  46405. /**
  46406. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46407. * makes the reflect vector face the model (under horizon).
  46408. */
  46409. useHorizonOcclusion: boolean;
  46410. /**
  46411. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46412. * too much the area relying on ambient texture to define their ambient occlusion.
  46413. */
  46414. useRadianceOcclusion: boolean;
  46415. /**
  46416. * If set to true, no lighting calculations will be applied.
  46417. */
  46418. unlit: boolean;
  46419. /**
  46420. * Gets the image processing configuration used either in this material.
  46421. */
  46422. /**
  46423. * Sets the Default image processing configuration used either in the this material.
  46424. *
  46425. * If sets to null, the scene one is in use.
  46426. */
  46427. imageProcessingConfiguration: ImageProcessingConfiguration;
  46428. /**
  46429. * Gets wether the color curves effect is enabled.
  46430. */
  46431. /**
  46432. * Sets wether the color curves effect is enabled.
  46433. */
  46434. cameraColorCurvesEnabled: boolean;
  46435. /**
  46436. * Gets wether the color grading effect is enabled.
  46437. */
  46438. /**
  46439. * Gets wether the color grading effect is enabled.
  46440. */
  46441. cameraColorGradingEnabled: boolean;
  46442. /**
  46443. * Gets wether tonemapping is enabled or not.
  46444. */
  46445. /**
  46446. * Sets wether tonemapping is enabled or not
  46447. */
  46448. cameraToneMappingEnabled: boolean;
  46449. /**
  46450. * The camera exposure used on this material.
  46451. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46452. * This corresponds to a photographic exposure.
  46453. */
  46454. /**
  46455. * The camera exposure used on this material.
  46456. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46457. * This corresponds to a photographic exposure.
  46458. */
  46459. cameraExposure: number;
  46460. /**
  46461. * Gets The camera contrast used on this material.
  46462. */
  46463. /**
  46464. * Sets The camera contrast used on this material.
  46465. */
  46466. cameraContrast: number;
  46467. /**
  46468. * Gets the Color Grading 2D Lookup Texture.
  46469. */
  46470. /**
  46471. * Sets the Color Grading 2D Lookup Texture.
  46472. */
  46473. cameraColorGradingTexture: Nullable<BaseTexture>;
  46474. /**
  46475. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46476. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46477. * 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;
  46478. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46479. */
  46480. /**
  46481. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46482. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46483. * 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;
  46484. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46485. */
  46486. cameraColorCurves: Nullable<ColorCurves>;
  46487. /**
  46488. * Instantiates a new PBRMaterial instance.
  46489. *
  46490. * @param name The material name
  46491. * @param scene The scene the material will be use in.
  46492. */
  46493. constructor(name: string, scene: Scene);
  46494. /**
  46495. * Returns the name of this material class.
  46496. */
  46497. getClassName(): string;
  46498. /**
  46499. * Makes a duplicate of the current material.
  46500. * @param name - name to use for the new material.
  46501. */
  46502. clone(name: string): PBRMaterial;
  46503. /**
  46504. * Serializes this PBR Material.
  46505. * @returns - An object with the serialized material.
  46506. */
  46507. serialize(): any;
  46508. /**
  46509. * Parses a PBR Material from a serialized object.
  46510. * @param source - Serialized object.
  46511. * @param scene - BJS scene instance.
  46512. * @param rootUrl - url for the scene object
  46513. * @returns - PBRMaterial
  46514. */
  46515. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46516. }
  46517. }
  46518. declare module "babylonjs/Misc/dds" {
  46519. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46520. import { Engine } from "babylonjs/Engines/engine";
  46521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46522. import { Nullable } from "babylonjs/types";
  46523. import { Scene } from "babylonjs/scene";
  46524. /**
  46525. * Direct draw surface info
  46526. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46527. */
  46528. export interface DDSInfo {
  46529. /**
  46530. * Width of the texture
  46531. */
  46532. width: number;
  46533. /**
  46534. * Width of the texture
  46535. */
  46536. height: number;
  46537. /**
  46538. * Number of Mipmaps for the texture
  46539. * @see https://en.wikipedia.org/wiki/Mipmap
  46540. */
  46541. mipmapCount: number;
  46542. /**
  46543. * If the textures format is a known fourCC format
  46544. * @see https://www.fourcc.org/
  46545. */
  46546. isFourCC: boolean;
  46547. /**
  46548. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46549. */
  46550. isRGB: boolean;
  46551. /**
  46552. * If the texture is a lumincance format
  46553. */
  46554. isLuminance: boolean;
  46555. /**
  46556. * If this is a cube texture
  46557. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46558. */
  46559. isCube: boolean;
  46560. /**
  46561. * If the texture is a compressed format eg. FOURCC_DXT1
  46562. */
  46563. isCompressed: boolean;
  46564. /**
  46565. * The dxgiFormat of the texture
  46566. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46567. */
  46568. dxgiFormat: number;
  46569. /**
  46570. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46571. */
  46572. textureType: number;
  46573. /**
  46574. * Sphericle polynomial created for the dds texture
  46575. */
  46576. sphericalPolynomial?: SphericalPolynomial;
  46577. }
  46578. /**
  46579. * Class used to provide DDS decompression tools
  46580. */
  46581. export class DDSTools {
  46582. /**
  46583. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46584. */
  46585. static StoreLODInAlphaChannel: boolean;
  46586. /**
  46587. * Gets DDS information from an array buffer
  46588. * @param arrayBuffer defines the array buffer to read data from
  46589. * @returns the DDS information
  46590. */
  46591. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46592. private static _FloatView;
  46593. private static _Int32View;
  46594. private static _ToHalfFloat;
  46595. private static _FromHalfFloat;
  46596. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46597. private static _GetHalfFloatRGBAArrayBuffer;
  46598. private static _GetFloatRGBAArrayBuffer;
  46599. private static _GetFloatAsUIntRGBAArrayBuffer;
  46600. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46601. private static _GetRGBAArrayBuffer;
  46602. private static _ExtractLongWordOrder;
  46603. private static _GetRGBArrayBuffer;
  46604. private static _GetLuminanceArrayBuffer;
  46605. /**
  46606. * Uploads DDS Levels to a Babylon Texture
  46607. * @hidden
  46608. */
  46609. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46610. }
  46611. module "babylonjs/Engines/engine" {
  46612. interface Engine {
  46613. /**
  46614. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46615. * @param rootUrl defines the url where the file to load is located
  46616. * @param scene defines the current scene
  46617. * @param lodScale defines scale to apply to the mip map selection
  46618. * @param lodOffset defines offset to apply to the mip map selection
  46619. * @param onLoad defines an optional callback raised when the texture is loaded
  46620. * @param onError defines an optional callback raised if there is an issue to load the texture
  46621. * @param format defines the format of the data
  46622. * @param forcedExtension defines the extension to use to pick the right loader
  46623. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46624. * @returns the cube texture as an InternalTexture
  46625. */
  46626. 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;
  46627. }
  46628. }
  46629. }
  46630. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46631. import { Nullable } from "babylonjs/types";
  46632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46633. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46634. /**
  46635. * Implementation of the DDS Texture Loader.
  46636. * @hidden
  46637. */
  46638. export class _DDSTextureLoader implements IInternalTextureLoader {
  46639. /**
  46640. * Defines wether the loader supports cascade loading the different faces.
  46641. */
  46642. readonly supportCascades: boolean;
  46643. /**
  46644. * This returns if the loader support the current file information.
  46645. * @param extension defines the file extension of the file being loaded
  46646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46647. * @param fallback defines the fallback internal texture if any
  46648. * @param isBase64 defines whether the texture is encoded as a base64
  46649. * @param isBuffer defines whether the texture data are stored as a buffer
  46650. * @returns true if the loader can load the specified file
  46651. */
  46652. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46653. /**
  46654. * Transform the url before loading if required.
  46655. * @param rootUrl the url of the texture
  46656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46657. * @returns the transformed texture
  46658. */
  46659. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46660. /**
  46661. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46662. * @param rootUrl the url of the texture
  46663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46664. * @returns the fallback texture
  46665. */
  46666. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46667. /**
  46668. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46669. * @param data contains the texture data
  46670. * @param texture defines the BabylonJS internal texture
  46671. * @param createPolynomials will be true if polynomials have been requested
  46672. * @param onLoad defines the callback to trigger once the texture is ready
  46673. * @param onError defines the callback to trigger in case of error
  46674. */
  46675. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46676. /**
  46677. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46678. * @param data contains the texture data
  46679. * @param texture defines the BabylonJS internal texture
  46680. * @param callback defines the method to call once ready to upload
  46681. */
  46682. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46683. }
  46684. }
  46685. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46686. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46687. /** @hidden */
  46688. export var rgbdEncodePixelShader: {
  46689. name: string;
  46690. shader: string;
  46691. };
  46692. }
  46693. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46694. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46695. /** @hidden */
  46696. export var rgbdDecodePixelShader: {
  46697. name: string;
  46698. shader: string;
  46699. };
  46700. }
  46701. declare module "babylonjs/Misc/environmentTextureTools" {
  46702. import { Nullable } from "babylonjs/types";
  46703. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46704. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46705. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46706. import "babylonjs/Shaders/rgbdEncode.fragment";
  46707. import "babylonjs/Shaders/rgbdDecode.fragment";
  46708. /**
  46709. * Raw texture data and descriptor sufficient for WebGL texture upload
  46710. */
  46711. export interface EnvironmentTextureInfo {
  46712. /**
  46713. * Version of the environment map
  46714. */
  46715. version: number;
  46716. /**
  46717. * Width of image
  46718. */
  46719. width: number;
  46720. /**
  46721. * Irradiance information stored in the file.
  46722. */
  46723. irradiance: any;
  46724. /**
  46725. * Specular information stored in the file.
  46726. */
  46727. specular: any;
  46728. }
  46729. /**
  46730. * Sets of helpers addressing the serialization and deserialization of environment texture
  46731. * stored in a BabylonJS env file.
  46732. * Those files are usually stored as .env files.
  46733. */
  46734. export class EnvironmentTextureTools {
  46735. /**
  46736. * Magic number identifying the env file.
  46737. */
  46738. private static _MagicBytes;
  46739. /**
  46740. * Gets the environment info from an env file.
  46741. * @param data The array buffer containing the .env bytes.
  46742. * @returns the environment file info (the json header) if successfully parsed.
  46743. */
  46744. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46745. /**
  46746. * Creates an environment texture from a loaded cube texture.
  46747. * @param texture defines the cube texture to convert in env file
  46748. * @return a promise containing the environment data if succesfull.
  46749. */
  46750. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46751. /**
  46752. * Creates a JSON representation of the spherical data.
  46753. * @param texture defines the texture containing the polynomials
  46754. * @return the JSON representation of the spherical info
  46755. */
  46756. private static _CreateEnvTextureIrradiance;
  46757. /**
  46758. * Uploads the texture info contained in the env file to the GPU.
  46759. * @param texture defines the internal texture to upload to
  46760. * @param arrayBuffer defines the buffer cotaining the data to load
  46761. * @param info defines the texture info retrieved through the GetEnvInfo method
  46762. * @returns a promise
  46763. */
  46764. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46765. /**
  46766. * Uploads the levels of image data to the GPU.
  46767. * @param texture defines the internal texture to upload to
  46768. * @param imageData defines the array buffer views of image data [mipmap][face]
  46769. * @returns a promise
  46770. */
  46771. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46772. /**
  46773. * Uploads spherical polynomials information to the texture.
  46774. * @param texture defines the texture we are trying to upload the information to
  46775. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46776. */
  46777. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46778. /** @hidden */
  46779. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46780. }
  46781. }
  46782. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46783. import { Nullable } from "babylonjs/types";
  46784. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46785. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46786. /**
  46787. * Implementation of the ENV Texture Loader.
  46788. * @hidden
  46789. */
  46790. export class _ENVTextureLoader implements IInternalTextureLoader {
  46791. /**
  46792. * Defines wether the loader supports cascade loading the different faces.
  46793. */
  46794. readonly supportCascades: boolean;
  46795. /**
  46796. * This returns if the loader support the current file information.
  46797. * @param extension defines the file extension of the file being loaded
  46798. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46799. * @param fallback defines the fallback internal texture if any
  46800. * @param isBase64 defines whether the texture is encoded as a base64
  46801. * @param isBuffer defines whether the texture data are stored as a buffer
  46802. * @returns true if the loader can load the specified file
  46803. */
  46804. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46805. /**
  46806. * Transform the url before loading if required.
  46807. * @param rootUrl the url of the texture
  46808. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46809. * @returns the transformed texture
  46810. */
  46811. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46812. /**
  46813. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46814. * @param rootUrl the url of the texture
  46815. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46816. * @returns the fallback texture
  46817. */
  46818. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46819. /**
  46820. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46821. * @param data contains the texture data
  46822. * @param texture defines the BabylonJS internal texture
  46823. * @param createPolynomials will be true if polynomials have been requested
  46824. * @param onLoad defines the callback to trigger once the texture is ready
  46825. * @param onError defines the callback to trigger in case of error
  46826. */
  46827. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46828. /**
  46829. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46830. * @param data contains the texture data
  46831. * @param texture defines the BabylonJS internal texture
  46832. * @param callback defines the method to call once ready to upload
  46833. */
  46834. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46835. }
  46836. }
  46837. declare module "babylonjs/Misc/khronosTextureContainer" {
  46838. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46839. /**
  46840. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46841. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46842. */
  46843. export class KhronosTextureContainer {
  46844. /** contents of the KTX container file */
  46845. arrayBuffer: any;
  46846. private static HEADER_LEN;
  46847. private static COMPRESSED_2D;
  46848. private static COMPRESSED_3D;
  46849. private static TEX_2D;
  46850. private static TEX_3D;
  46851. /**
  46852. * Gets the openGL type
  46853. */
  46854. glType: number;
  46855. /**
  46856. * Gets the openGL type size
  46857. */
  46858. glTypeSize: number;
  46859. /**
  46860. * Gets the openGL format
  46861. */
  46862. glFormat: number;
  46863. /**
  46864. * Gets the openGL internal format
  46865. */
  46866. glInternalFormat: number;
  46867. /**
  46868. * Gets the base internal format
  46869. */
  46870. glBaseInternalFormat: number;
  46871. /**
  46872. * Gets image width in pixel
  46873. */
  46874. pixelWidth: number;
  46875. /**
  46876. * Gets image height in pixel
  46877. */
  46878. pixelHeight: number;
  46879. /**
  46880. * Gets image depth in pixels
  46881. */
  46882. pixelDepth: number;
  46883. /**
  46884. * Gets the number of array elements
  46885. */
  46886. numberOfArrayElements: number;
  46887. /**
  46888. * Gets the number of faces
  46889. */
  46890. numberOfFaces: number;
  46891. /**
  46892. * Gets the number of mipmap levels
  46893. */
  46894. numberOfMipmapLevels: number;
  46895. /**
  46896. * Gets the bytes of key value data
  46897. */
  46898. bytesOfKeyValueData: number;
  46899. /**
  46900. * Gets the load type
  46901. */
  46902. loadType: number;
  46903. /**
  46904. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46905. */
  46906. isInvalid: boolean;
  46907. /**
  46908. * Creates a new KhronosTextureContainer
  46909. * @param arrayBuffer contents of the KTX container file
  46910. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46911. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46912. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46913. */
  46914. constructor(
  46915. /** contents of the KTX container file */
  46916. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46917. /**
  46918. * Uploads KTX content to a Babylon Texture.
  46919. * It is assumed that the texture has already been created & is currently bound
  46920. * @hidden
  46921. */
  46922. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46923. private _upload2DCompressedLevels;
  46924. }
  46925. }
  46926. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46927. import { Nullable } from "babylonjs/types";
  46928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46929. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46930. /**
  46931. * Implementation of the KTX Texture Loader.
  46932. * @hidden
  46933. */
  46934. export class _KTXTextureLoader implements IInternalTextureLoader {
  46935. /**
  46936. * Defines wether the loader supports cascade loading the different faces.
  46937. */
  46938. readonly supportCascades: boolean;
  46939. /**
  46940. * This returns if the loader support the current file information.
  46941. * @param extension defines the file extension of the file being loaded
  46942. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46943. * @param fallback defines the fallback internal texture if any
  46944. * @param isBase64 defines whether the texture is encoded as a base64
  46945. * @param isBuffer defines whether the texture data are stored as a buffer
  46946. * @returns true if the loader can load the specified file
  46947. */
  46948. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46949. /**
  46950. * Transform the url before loading if required.
  46951. * @param rootUrl the url of the texture
  46952. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46953. * @returns the transformed texture
  46954. */
  46955. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46956. /**
  46957. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46958. * @param rootUrl the url of the texture
  46959. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46960. * @returns the fallback texture
  46961. */
  46962. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46963. /**
  46964. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46965. * @param data contains the texture data
  46966. * @param texture defines the BabylonJS internal texture
  46967. * @param createPolynomials will be true if polynomials have been requested
  46968. * @param onLoad defines the callback to trigger once the texture is ready
  46969. * @param onError defines the callback to trigger in case of error
  46970. */
  46971. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46972. /**
  46973. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46974. * @param data contains the texture data
  46975. * @param texture defines the BabylonJS internal texture
  46976. * @param callback defines the method to call once ready to upload
  46977. */
  46978. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46979. }
  46980. }
  46981. declare module "babylonjs/Helpers/sceneHelpers" {
  46982. import { Nullable } from "babylonjs/types";
  46983. import { Mesh } from "babylonjs/Meshes/mesh";
  46984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46985. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46986. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46987. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46988. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46989. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46990. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46991. import "babylonjs/Meshes/Builders/boxBuilder";
  46992. /** @hidden */
  46993. export var _forceSceneHelpersToBundle: boolean;
  46994. module "babylonjs/scene" {
  46995. interface Scene {
  46996. /**
  46997. * Creates a default light for the scene.
  46998. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46999. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47000. */
  47001. createDefaultLight(replace?: boolean): void;
  47002. /**
  47003. * Creates a default camera for the scene.
  47004. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47005. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47006. * @param replace has default false, when true replaces the active camera in the scene
  47007. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47008. */
  47009. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47010. /**
  47011. * Creates a default camera and a default light.
  47012. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47013. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47014. * @param replace has the default false, when true replaces the active camera/light in the scene
  47015. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47016. */
  47017. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47018. /**
  47019. * Creates a new sky box
  47020. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47021. * @param environmentTexture defines the texture to use as environment texture
  47022. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47023. * @param scale defines the overall scale of the skybox
  47024. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47025. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47026. * @returns a new mesh holding the sky box
  47027. */
  47028. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47029. /**
  47030. * Creates a new environment
  47031. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47032. * @param options defines the options you can use to configure the environment
  47033. * @returns the new EnvironmentHelper
  47034. */
  47035. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47036. /**
  47037. * Creates a new VREXperienceHelper
  47038. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47039. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47040. * @returns a new VREXperienceHelper
  47041. */
  47042. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47043. /**
  47044. * Creates a new XREXperienceHelper
  47045. * @see http://doc.babylonjs.com/how_to/webxr
  47046. * @returns a promise for a new XREXperienceHelper
  47047. */
  47048. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47049. }
  47050. }
  47051. }
  47052. declare module "babylonjs/Helpers/videoDome" {
  47053. import { Scene } from "babylonjs/scene";
  47054. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47055. import { Mesh } from "babylonjs/Meshes/mesh";
  47056. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47057. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47058. import "babylonjs/Meshes/Builders/sphereBuilder";
  47059. /**
  47060. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47061. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47062. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47063. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47064. */
  47065. export class VideoDome extends TransformNode {
  47066. /**
  47067. * Define the video source as a Monoscopic panoramic 360 video.
  47068. */
  47069. static readonly MODE_MONOSCOPIC: number;
  47070. /**
  47071. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47072. */
  47073. static readonly MODE_TOPBOTTOM: number;
  47074. /**
  47075. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47076. */
  47077. static readonly MODE_SIDEBYSIDE: number;
  47078. private _useDirectMapping;
  47079. /**
  47080. * The video texture being displayed on the sphere
  47081. */
  47082. protected _videoTexture: VideoTexture;
  47083. /**
  47084. * Gets the video texture being displayed on the sphere
  47085. */
  47086. readonly videoTexture: VideoTexture;
  47087. /**
  47088. * The skybox material
  47089. */
  47090. protected _material: BackgroundMaterial;
  47091. /**
  47092. * The surface used for the skybox
  47093. */
  47094. protected _mesh: Mesh;
  47095. /**
  47096. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47097. * Also see the options.resolution property.
  47098. */
  47099. fovMultiplier: number;
  47100. private _videoMode;
  47101. /**
  47102. * Gets or set the current video mode for the video. It can be:
  47103. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47104. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47105. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47106. */
  47107. videoMode: number;
  47108. /**
  47109. * Oberserver used in Stereoscopic VR Mode.
  47110. */
  47111. private _onBeforeCameraRenderObserver;
  47112. /**
  47113. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47114. * @param name Element's name, child elements will append suffixes for their own names.
  47115. * @param urlsOrVideo defines the url(s) or the video element to use
  47116. * @param options An object containing optional or exposed sub element properties
  47117. */
  47118. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47119. resolution?: number;
  47120. clickToPlay?: boolean;
  47121. autoPlay?: boolean;
  47122. loop?: boolean;
  47123. size?: number;
  47124. poster?: string;
  47125. faceForward?: boolean;
  47126. useDirectMapping?: boolean;
  47127. }, scene: Scene);
  47128. private _changeVideoMode;
  47129. /**
  47130. * Releases resources associated with this node.
  47131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47133. */
  47134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47135. }
  47136. }
  47137. declare module "babylonjs/Helpers/index" {
  47138. export * from "babylonjs/Helpers/environmentHelper";
  47139. export * from "babylonjs/Helpers/photoDome";
  47140. export * from "babylonjs/Helpers/sceneHelpers";
  47141. export * from "babylonjs/Helpers/videoDome";
  47142. }
  47143. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47144. import { PerfCounter } from "babylonjs/Misc/tools";
  47145. import { IDisposable } from "babylonjs/scene";
  47146. import { Engine } from "babylonjs/Engines/engine";
  47147. /**
  47148. * This class can be used to get instrumentation data from a Babylon engine
  47149. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47150. */
  47151. export class EngineInstrumentation implements IDisposable {
  47152. /**
  47153. * Define the instrumented engine.
  47154. */
  47155. engine: Engine;
  47156. private _captureGPUFrameTime;
  47157. private _gpuFrameTimeToken;
  47158. private _gpuFrameTime;
  47159. private _captureShaderCompilationTime;
  47160. private _shaderCompilationTime;
  47161. private _onBeginFrameObserver;
  47162. private _onEndFrameObserver;
  47163. private _onBeforeShaderCompilationObserver;
  47164. private _onAfterShaderCompilationObserver;
  47165. /**
  47166. * Gets the perf counter used for GPU frame time
  47167. */
  47168. readonly gpuFrameTimeCounter: PerfCounter;
  47169. /**
  47170. * Gets the GPU frame time capture status
  47171. */
  47172. /**
  47173. * Enable or disable the GPU frame time capture
  47174. */
  47175. captureGPUFrameTime: boolean;
  47176. /**
  47177. * Gets the perf counter used for shader compilation time
  47178. */
  47179. readonly shaderCompilationTimeCounter: PerfCounter;
  47180. /**
  47181. * Gets the shader compilation time capture status
  47182. */
  47183. /**
  47184. * Enable or disable the shader compilation time capture
  47185. */
  47186. captureShaderCompilationTime: boolean;
  47187. /**
  47188. * Instantiates a new engine instrumentation.
  47189. * This class can be used to get instrumentation data from a Babylon engine
  47190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47191. * @param engine Defines the engine to instrument
  47192. */
  47193. constructor(
  47194. /**
  47195. * Define the instrumented engine.
  47196. */
  47197. engine: Engine);
  47198. /**
  47199. * Dispose and release associated resources.
  47200. */
  47201. dispose(): void;
  47202. }
  47203. }
  47204. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47205. import { PerfCounter } from "babylonjs/Misc/tools";
  47206. import { Scene, IDisposable } from "babylonjs/scene";
  47207. /**
  47208. * This class can be used to get instrumentation data from a Babylon engine
  47209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47210. */
  47211. export class SceneInstrumentation implements IDisposable {
  47212. /**
  47213. * Defines the scene to instrument
  47214. */
  47215. scene: Scene;
  47216. private _captureActiveMeshesEvaluationTime;
  47217. private _activeMeshesEvaluationTime;
  47218. private _captureRenderTargetsRenderTime;
  47219. private _renderTargetsRenderTime;
  47220. private _captureFrameTime;
  47221. private _frameTime;
  47222. private _captureRenderTime;
  47223. private _renderTime;
  47224. private _captureInterFrameTime;
  47225. private _interFrameTime;
  47226. private _captureParticlesRenderTime;
  47227. private _particlesRenderTime;
  47228. private _captureSpritesRenderTime;
  47229. private _spritesRenderTime;
  47230. private _capturePhysicsTime;
  47231. private _physicsTime;
  47232. private _captureAnimationsTime;
  47233. private _animationsTime;
  47234. private _captureCameraRenderTime;
  47235. private _cameraRenderTime;
  47236. private _onBeforeActiveMeshesEvaluationObserver;
  47237. private _onAfterActiveMeshesEvaluationObserver;
  47238. private _onBeforeRenderTargetsRenderObserver;
  47239. private _onAfterRenderTargetsRenderObserver;
  47240. private _onAfterRenderObserver;
  47241. private _onBeforeDrawPhaseObserver;
  47242. private _onAfterDrawPhaseObserver;
  47243. private _onBeforeAnimationsObserver;
  47244. private _onBeforeParticlesRenderingObserver;
  47245. private _onAfterParticlesRenderingObserver;
  47246. private _onBeforeSpritesRenderingObserver;
  47247. private _onAfterSpritesRenderingObserver;
  47248. private _onBeforePhysicsObserver;
  47249. private _onAfterPhysicsObserver;
  47250. private _onAfterAnimationsObserver;
  47251. private _onBeforeCameraRenderObserver;
  47252. private _onAfterCameraRenderObserver;
  47253. /**
  47254. * Gets the perf counter used for active meshes evaluation time
  47255. */
  47256. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47257. /**
  47258. * Gets the active meshes evaluation time capture status
  47259. */
  47260. /**
  47261. * Enable or disable the active meshes evaluation time capture
  47262. */
  47263. captureActiveMeshesEvaluationTime: boolean;
  47264. /**
  47265. * Gets the perf counter used for render targets render time
  47266. */
  47267. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47268. /**
  47269. * Gets the render targets render time capture status
  47270. */
  47271. /**
  47272. * Enable or disable the render targets render time capture
  47273. */
  47274. captureRenderTargetsRenderTime: boolean;
  47275. /**
  47276. * Gets the perf counter used for particles render time
  47277. */
  47278. readonly particlesRenderTimeCounter: PerfCounter;
  47279. /**
  47280. * Gets the particles render time capture status
  47281. */
  47282. /**
  47283. * Enable or disable the particles render time capture
  47284. */
  47285. captureParticlesRenderTime: boolean;
  47286. /**
  47287. * Gets the perf counter used for sprites render time
  47288. */
  47289. readonly spritesRenderTimeCounter: PerfCounter;
  47290. /**
  47291. * Gets the sprites render time capture status
  47292. */
  47293. /**
  47294. * Enable or disable the sprites render time capture
  47295. */
  47296. captureSpritesRenderTime: boolean;
  47297. /**
  47298. * Gets the perf counter used for physics time
  47299. */
  47300. readonly physicsTimeCounter: PerfCounter;
  47301. /**
  47302. * Gets the physics time capture status
  47303. */
  47304. /**
  47305. * Enable or disable the physics time capture
  47306. */
  47307. capturePhysicsTime: boolean;
  47308. /**
  47309. * Gets the perf counter used for animations time
  47310. */
  47311. readonly animationsTimeCounter: PerfCounter;
  47312. /**
  47313. * Gets the animations time capture status
  47314. */
  47315. /**
  47316. * Enable or disable the animations time capture
  47317. */
  47318. captureAnimationsTime: boolean;
  47319. /**
  47320. * Gets the perf counter used for frame time capture
  47321. */
  47322. readonly frameTimeCounter: PerfCounter;
  47323. /**
  47324. * Gets the frame time capture status
  47325. */
  47326. /**
  47327. * Enable or disable the frame time capture
  47328. */
  47329. captureFrameTime: boolean;
  47330. /**
  47331. * Gets the perf counter used for inter-frames time capture
  47332. */
  47333. readonly interFrameTimeCounter: PerfCounter;
  47334. /**
  47335. * Gets the inter-frames time capture status
  47336. */
  47337. /**
  47338. * Enable or disable the inter-frames time capture
  47339. */
  47340. captureInterFrameTime: boolean;
  47341. /**
  47342. * Gets the perf counter used for render time capture
  47343. */
  47344. readonly renderTimeCounter: PerfCounter;
  47345. /**
  47346. * Gets the render time capture status
  47347. */
  47348. /**
  47349. * Enable or disable the render time capture
  47350. */
  47351. captureRenderTime: boolean;
  47352. /**
  47353. * Gets the perf counter used for camera render time capture
  47354. */
  47355. readonly cameraRenderTimeCounter: PerfCounter;
  47356. /**
  47357. * Gets the camera render time capture status
  47358. */
  47359. /**
  47360. * Enable or disable the camera render time capture
  47361. */
  47362. captureCameraRenderTime: boolean;
  47363. /**
  47364. * Gets the perf counter used for draw calls
  47365. */
  47366. readonly drawCallsCounter: PerfCounter;
  47367. /**
  47368. * Gets the perf counter used for texture collisions
  47369. */
  47370. readonly textureCollisionsCounter: PerfCounter;
  47371. /**
  47372. * Instantiates a new scene instrumentation.
  47373. * This class can be used to get instrumentation data from a Babylon engine
  47374. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47375. * @param scene Defines the scene to instrument
  47376. */
  47377. constructor(
  47378. /**
  47379. * Defines the scene to instrument
  47380. */
  47381. scene: Scene);
  47382. /**
  47383. * Dispose and release associated resources.
  47384. */
  47385. dispose(): void;
  47386. }
  47387. }
  47388. declare module "babylonjs/Instrumentation/index" {
  47389. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47390. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47391. export * from "babylonjs/Instrumentation/timeToken";
  47392. }
  47393. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47394. /** @hidden */
  47395. export var glowMapGenerationPixelShader: {
  47396. name: string;
  47397. shader: string;
  47398. };
  47399. }
  47400. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47401. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47402. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47403. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47404. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47405. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47406. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47407. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47408. /** @hidden */
  47409. export var glowMapGenerationVertexShader: {
  47410. name: string;
  47411. shader: string;
  47412. };
  47413. }
  47414. declare module "babylonjs/Layers/effectLayer" {
  47415. import { Observable } from "babylonjs/Misc/observable";
  47416. import { Nullable } from "babylonjs/types";
  47417. import { Camera } from "babylonjs/Cameras/camera";
  47418. import { Scene } from "babylonjs/scene";
  47419. import { Color4, ISize } from "babylonjs/Maths/math";
  47420. import { Engine } from "babylonjs/Engines/engine";
  47421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47423. import { Mesh } from "babylonjs/Meshes/mesh";
  47424. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47427. import { Effect } from "babylonjs/Materials/effect";
  47428. import { Material } from "babylonjs/Materials/material";
  47429. import "babylonjs/Shaders/glowMapGeneration.fragment";
  47430. import "babylonjs/Shaders/glowMapGeneration.vertex";
  47431. /**
  47432. * Effect layer options. This helps customizing the behaviour
  47433. * of the effect layer.
  47434. */
  47435. export interface IEffectLayerOptions {
  47436. /**
  47437. * Multiplication factor apply to the canvas size to compute the render target size
  47438. * used to generated the objects (the smaller the faster).
  47439. */
  47440. mainTextureRatio: number;
  47441. /**
  47442. * Enforces a fixed size texture to ensure effect stability across devices.
  47443. */
  47444. mainTextureFixedSize?: number;
  47445. /**
  47446. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47447. */
  47448. alphaBlendingMode: number;
  47449. /**
  47450. * The camera attached to the layer.
  47451. */
  47452. camera: Nullable<Camera>;
  47453. /**
  47454. * The rendering group to draw the layer in.
  47455. */
  47456. renderingGroupId: number;
  47457. }
  47458. /**
  47459. * The effect layer Helps adding post process effect blended with the main pass.
  47460. *
  47461. * This can be for instance use to generate glow or higlight effects on the scene.
  47462. *
  47463. * The effect layer class can not be used directly and is intented to inherited from to be
  47464. * customized per effects.
  47465. */
  47466. export abstract class EffectLayer {
  47467. private _vertexBuffers;
  47468. private _indexBuffer;
  47469. private _cachedDefines;
  47470. private _effectLayerMapGenerationEffect;
  47471. private _effectLayerOptions;
  47472. private _mergeEffect;
  47473. protected _scene: Scene;
  47474. protected _engine: Engine;
  47475. protected _maxSize: number;
  47476. protected _mainTextureDesiredSize: ISize;
  47477. protected _mainTexture: RenderTargetTexture;
  47478. protected _shouldRender: boolean;
  47479. protected _postProcesses: PostProcess[];
  47480. protected _textures: BaseTexture[];
  47481. protected _emissiveTextureAndColor: {
  47482. texture: Nullable<BaseTexture>;
  47483. color: Color4;
  47484. };
  47485. /**
  47486. * The name of the layer
  47487. */
  47488. name: string;
  47489. /**
  47490. * The clear color of the texture used to generate the glow map.
  47491. */
  47492. neutralColor: Color4;
  47493. /**
  47494. * Specifies wether the highlight layer is enabled or not.
  47495. */
  47496. isEnabled: boolean;
  47497. /**
  47498. * Gets the camera attached to the layer.
  47499. */
  47500. readonly camera: Nullable<Camera>;
  47501. /**
  47502. * Gets the rendering group id the layer should render in.
  47503. */
  47504. readonly renderingGroupId: number;
  47505. /**
  47506. * An event triggered when the effect layer has been disposed.
  47507. */
  47508. onDisposeObservable: Observable<EffectLayer>;
  47509. /**
  47510. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47511. */
  47512. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47513. /**
  47514. * An event triggered when the generated texture is being merged in the scene.
  47515. */
  47516. onBeforeComposeObservable: Observable<EffectLayer>;
  47517. /**
  47518. * An event triggered when the generated texture has been merged in the scene.
  47519. */
  47520. onAfterComposeObservable: Observable<EffectLayer>;
  47521. /**
  47522. * An event triggered when the efffect layer changes its size.
  47523. */
  47524. onSizeChangedObservable: Observable<EffectLayer>;
  47525. /** @hidden */
  47526. static _SceneComponentInitialization: (scene: Scene) => void;
  47527. /**
  47528. * Instantiates a new effect Layer and references it in the scene.
  47529. * @param name The name of the layer
  47530. * @param scene The scene to use the layer in
  47531. */
  47532. constructor(
  47533. /** The Friendly of the effect in the scene */
  47534. name: string, scene: Scene);
  47535. /**
  47536. * Get the effect name of the layer.
  47537. * @return The effect name
  47538. */
  47539. abstract getEffectName(): string;
  47540. /**
  47541. * Checks for the readiness of the element composing the layer.
  47542. * @param subMesh the mesh to check for
  47543. * @param useInstances specify wether or not to use instances to render the mesh
  47544. * @return true if ready otherwise, false
  47545. */
  47546. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47547. /**
  47548. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47549. * @returns true if the effect requires stencil during the main canvas render pass.
  47550. */
  47551. abstract needStencil(): boolean;
  47552. /**
  47553. * Create the merge effect. This is the shader use to blit the information back
  47554. * to the main canvas at the end of the scene rendering.
  47555. * @returns The effect containing the shader used to merge the effect on the main canvas
  47556. */
  47557. protected abstract _createMergeEffect(): Effect;
  47558. /**
  47559. * Creates the render target textures and post processes used in the effect layer.
  47560. */
  47561. protected abstract _createTextureAndPostProcesses(): void;
  47562. /**
  47563. * Implementation specific of rendering the generating effect on the main canvas.
  47564. * @param effect The effect used to render through
  47565. */
  47566. protected abstract _internalRender(effect: Effect): void;
  47567. /**
  47568. * Sets the required values for both the emissive texture and and the main color.
  47569. */
  47570. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47571. /**
  47572. * Free any resources and references associated to a mesh.
  47573. * Internal use
  47574. * @param mesh The mesh to free.
  47575. */
  47576. abstract _disposeMesh(mesh: Mesh): void;
  47577. /**
  47578. * Serializes this layer (Glow or Highlight for example)
  47579. * @returns a serialized layer object
  47580. */
  47581. abstract serialize?(): any;
  47582. /**
  47583. * Initializes the effect layer with the required options.
  47584. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47585. */
  47586. protected _init(options: Partial<IEffectLayerOptions>): void;
  47587. /**
  47588. * Generates the index buffer of the full screen quad blending to the main canvas.
  47589. */
  47590. private _generateIndexBuffer;
  47591. /**
  47592. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47593. */
  47594. private _genrateVertexBuffer;
  47595. /**
  47596. * Sets the main texture desired size which is the closest power of two
  47597. * of the engine canvas size.
  47598. */
  47599. private _setMainTextureSize;
  47600. /**
  47601. * Creates the main texture for the effect layer.
  47602. */
  47603. protected _createMainTexture(): void;
  47604. /**
  47605. * Adds specific effects defines.
  47606. * @param defines The defines to add specifics to.
  47607. */
  47608. protected _addCustomEffectDefines(defines: string[]): void;
  47609. /**
  47610. * Checks for the readiness of the element composing the layer.
  47611. * @param subMesh the mesh to check for
  47612. * @param useInstances specify wether or not to use instances to render the mesh
  47613. * @param emissiveTexture the associated emissive texture used to generate the glow
  47614. * @return true if ready otherwise, false
  47615. */
  47616. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47617. /**
  47618. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47619. */
  47620. render(): void;
  47621. /**
  47622. * Determine if a given mesh will be used in the current effect.
  47623. * @param mesh mesh to test
  47624. * @returns true if the mesh will be used
  47625. */
  47626. hasMesh(mesh: AbstractMesh): boolean;
  47627. /**
  47628. * Returns true if the layer contains information to display, otherwise false.
  47629. * @returns true if the glow layer should be rendered
  47630. */
  47631. shouldRender(): boolean;
  47632. /**
  47633. * Returns true if the mesh should render, otherwise false.
  47634. * @param mesh The mesh to render
  47635. * @returns true if it should render otherwise false
  47636. */
  47637. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47638. /**
  47639. * Returns true if the mesh can be rendered, otherwise false.
  47640. * @param mesh The mesh to render
  47641. * @param material The material used on the mesh
  47642. * @returns true if it can be rendered otherwise false
  47643. */
  47644. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47645. /**
  47646. * Returns true if the mesh should render, otherwise false.
  47647. * @param mesh The mesh to render
  47648. * @returns true if it should render otherwise false
  47649. */
  47650. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47651. /**
  47652. * Renders the submesh passed in parameter to the generation map.
  47653. */
  47654. protected _renderSubMesh(subMesh: SubMesh): void;
  47655. /**
  47656. * Rebuild the required buffers.
  47657. * @hidden Internal use only.
  47658. */
  47659. _rebuild(): void;
  47660. /**
  47661. * Dispose only the render target textures and post process.
  47662. */
  47663. private _disposeTextureAndPostProcesses;
  47664. /**
  47665. * Dispose the highlight layer and free resources.
  47666. */
  47667. dispose(): void;
  47668. /**
  47669. * Gets the class name of the effect layer
  47670. * @returns the string with the class name of the effect layer
  47671. */
  47672. getClassName(): string;
  47673. /**
  47674. * Creates an effect layer from parsed effect layer data
  47675. * @param parsedEffectLayer defines effect layer data
  47676. * @param scene defines the current scene
  47677. * @param rootUrl defines the root URL containing the effect layer information
  47678. * @returns a parsed effect Layer
  47679. */
  47680. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47681. }
  47682. }
  47683. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47684. import { Scene } from "babylonjs/scene";
  47685. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47686. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47687. import { AbstractScene } from "babylonjs/abstractScene";
  47688. module "babylonjs/abstractScene" {
  47689. interface AbstractScene {
  47690. /**
  47691. * The list of effect layers (highlights/glow) added to the scene
  47692. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47693. * @see http://doc.babylonjs.com/how_to/glow_layer
  47694. */
  47695. effectLayers: Array<EffectLayer>;
  47696. /**
  47697. * Removes the given effect layer from this scene.
  47698. * @param toRemove defines the effect layer to remove
  47699. * @returns the index of the removed effect layer
  47700. */
  47701. removeEffectLayer(toRemove: EffectLayer): number;
  47702. /**
  47703. * Adds the given effect layer to this scene
  47704. * @param newEffectLayer defines the effect layer to add
  47705. */
  47706. addEffectLayer(newEffectLayer: EffectLayer): void;
  47707. }
  47708. }
  47709. /**
  47710. * Defines the layer scene component responsible to manage any effect layers
  47711. * in a given scene.
  47712. */
  47713. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47714. /**
  47715. * The component name helpfull to identify the component in the list of scene components.
  47716. */
  47717. readonly name: string;
  47718. /**
  47719. * The scene the component belongs to.
  47720. */
  47721. scene: Scene;
  47722. private _engine;
  47723. private _renderEffects;
  47724. private _needStencil;
  47725. private _previousStencilState;
  47726. /**
  47727. * Creates a new instance of the component for the given scene
  47728. * @param scene Defines the scene to register the component in
  47729. */
  47730. constructor(scene: Scene);
  47731. /**
  47732. * Registers the component in a given scene
  47733. */
  47734. register(): void;
  47735. /**
  47736. * Rebuilds the elements related to this component in case of
  47737. * context lost for instance.
  47738. */
  47739. rebuild(): void;
  47740. /**
  47741. * Serializes the component data to the specified json object
  47742. * @param serializationObject The object to serialize to
  47743. */
  47744. serialize(serializationObject: any): void;
  47745. /**
  47746. * Adds all the element from the container to the scene
  47747. * @param container the container holding the elements
  47748. */
  47749. addFromContainer(container: AbstractScene): void;
  47750. /**
  47751. * Removes all the elements in the container from the scene
  47752. * @param container contains the elements to remove
  47753. * @param dispose if the removed element should be disposed (default: false)
  47754. */
  47755. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47756. /**
  47757. * Disposes the component and the associated ressources.
  47758. */
  47759. dispose(): void;
  47760. private _isReadyForMesh;
  47761. private _renderMainTexture;
  47762. private _setStencil;
  47763. private _setStencilBack;
  47764. private _draw;
  47765. private _drawCamera;
  47766. private _drawRenderingGroup;
  47767. }
  47768. }
  47769. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47770. /** @hidden */
  47771. export var glowMapMergePixelShader: {
  47772. name: string;
  47773. shader: string;
  47774. };
  47775. }
  47776. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47777. /** @hidden */
  47778. export var glowMapMergeVertexShader: {
  47779. name: string;
  47780. shader: string;
  47781. };
  47782. }
  47783. declare module "babylonjs/Layers/glowLayer" {
  47784. import { Nullable } from "babylonjs/types";
  47785. import { Camera } from "babylonjs/Cameras/camera";
  47786. import { Scene } from "babylonjs/scene";
  47787. import { Color4 } from "babylonjs/Maths/math";
  47788. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47790. import { Mesh } from "babylonjs/Meshes/mesh";
  47791. import { Texture } from "babylonjs/Materials/Textures/texture";
  47792. import { Effect } from "babylonjs/Materials/effect";
  47793. import { Material } from "babylonjs/Materials/material";
  47794. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47795. import "babylonjs/Shaders/glowMapMerge.fragment";
  47796. import "babylonjs/Shaders/glowMapMerge.vertex";
  47797. import "babylonjs/Layers/effectLayerSceneComponent";
  47798. module "babylonjs/abstractScene" {
  47799. interface AbstractScene {
  47800. /**
  47801. * Return a the first highlight layer of the scene with a given name.
  47802. * @param name The name of the highlight layer to look for.
  47803. * @return The highlight layer if found otherwise null.
  47804. */
  47805. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47806. }
  47807. }
  47808. /**
  47809. * Glow layer options. This helps customizing the behaviour
  47810. * of the glow layer.
  47811. */
  47812. export interface IGlowLayerOptions {
  47813. /**
  47814. * Multiplication factor apply to the canvas size to compute the render target size
  47815. * used to generated the glowing objects (the smaller the faster).
  47816. */
  47817. mainTextureRatio: number;
  47818. /**
  47819. * Enforces a fixed size texture to ensure resize independant blur.
  47820. */
  47821. mainTextureFixedSize?: number;
  47822. /**
  47823. * How big is the kernel of the blur texture.
  47824. */
  47825. blurKernelSize: number;
  47826. /**
  47827. * The camera attached to the layer.
  47828. */
  47829. camera: Nullable<Camera>;
  47830. /**
  47831. * Enable MSAA by chosing the number of samples.
  47832. */
  47833. mainTextureSamples?: number;
  47834. /**
  47835. * The rendering group to draw the layer in.
  47836. */
  47837. renderingGroupId: number;
  47838. }
  47839. /**
  47840. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47841. *
  47842. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47843. * glowy meshes to your scene.
  47844. *
  47845. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47846. */
  47847. export class GlowLayer extends EffectLayer {
  47848. /**
  47849. * Effect Name of the layer.
  47850. */
  47851. static readonly EffectName: string;
  47852. /**
  47853. * The default blur kernel size used for the glow.
  47854. */
  47855. static DefaultBlurKernelSize: number;
  47856. /**
  47857. * The default texture size ratio used for the glow.
  47858. */
  47859. static DefaultTextureRatio: number;
  47860. /**
  47861. * Sets the kernel size of the blur.
  47862. */
  47863. /**
  47864. * Gets the kernel size of the blur.
  47865. */
  47866. blurKernelSize: number;
  47867. /**
  47868. * Sets the glow intensity.
  47869. */
  47870. /**
  47871. * Gets the glow intensity.
  47872. */
  47873. intensity: number;
  47874. private _options;
  47875. private _intensity;
  47876. private _horizontalBlurPostprocess1;
  47877. private _verticalBlurPostprocess1;
  47878. private _horizontalBlurPostprocess2;
  47879. private _verticalBlurPostprocess2;
  47880. private _blurTexture1;
  47881. private _blurTexture2;
  47882. private _postProcesses1;
  47883. private _postProcesses2;
  47884. private _includedOnlyMeshes;
  47885. private _excludedMeshes;
  47886. /**
  47887. * Callback used to let the user override the color selection on a per mesh basis
  47888. */
  47889. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47890. /**
  47891. * Callback used to let the user override the texture selection on a per mesh basis
  47892. */
  47893. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47894. /**
  47895. * Instantiates a new glow Layer and references it to the scene.
  47896. * @param name The name of the layer
  47897. * @param scene The scene to use the layer in
  47898. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47899. */
  47900. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47901. /**
  47902. * Get the effect name of the layer.
  47903. * @return The effect name
  47904. */
  47905. getEffectName(): string;
  47906. /**
  47907. * Create the merge effect. This is the shader use to blit the information back
  47908. * to the main canvas at the end of the scene rendering.
  47909. */
  47910. protected _createMergeEffect(): Effect;
  47911. /**
  47912. * Creates the render target textures and post processes used in the glow layer.
  47913. */
  47914. protected _createTextureAndPostProcesses(): void;
  47915. /**
  47916. * Checks for the readiness of the element composing the layer.
  47917. * @param subMesh the mesh to check for
  47918. * @param useInstances specify wether or not to use instances to render the mesh
  47919. * @param emissiveTexture the associated emissive texture used to generate the glow
  47920. * @return true if ready otherwise, false
  47921. */
  47922. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47923. /**
  47924. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47925. */
  47926. needStencil(): boolean;
  47927. /**
  47928. * Returns true if the mesh can be rendered, otherwise false.
  47929. * @param mesh The mesh to render
  47930. * @param material The material used on the mesh
  47931. * @returns true if it can be rendered otherwise false
  47932. */
  47933. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47934. /**
  47935. * Implementation specific of rendering the generating effect on the main canvas.
  47936. * @param effect The effect used to render through
  47937. */
  47938. protected _internalRender(effect: Effect): void;
  47939. /**
  47940. * Sets the required values for both the emissive texture and and the main color.
  47941. */
  47942. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47943. /**
  47944. * Returns true if the mesh should render, otherwise false.
  47945. * @param mesh The mesh to render
  47946. * @returns true if it should render otherwise false
  47947. */
  47948. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47949. /**
  47950. * Adds specific effects defines.
  47951. * @param defines The defines to add specifics to.
  47952. */
  47953. protected _addCustomEffectDefines(defines: string[]): void;
  47954. /**
  47955. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47956. * @param mesh The mesh to exclude from the glow layer
  47957. */
  47958. addExcludedMesh(mesh: Mesh): void;
  47959. /**
  47960. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47961. * @param mesh The mesh to remove
  47962. */
  47963. removeExcludedMesh(mesh: Mesh): void;
  47964. /**
  47965. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47966. * @param mesh The mesh to include in the glow layer
  47967. */
  47968. addIncludedOnlyMesh(mesh: Mesh): void;
  47969. /**
  47970. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47971. * @param mesh The mesh to remove
  47972. */
  47973. removeIncludedOnlyMesh(mesh: Mesh): void;
  47974. /**
  47975. * Determine if a given mesh will be used in the glow layer
  47976. * @param mesh The mesh to test
  47977. * @returns true if the mesh will be highlighted by the current glow layer
  47978. */
  47979. hasMesh(mesh: AbstractMesh): boolean;
  47980. /**
  47981. * Free any resources and references associated to a mesh.
  47982. * Internal use
  47983. * @param mesh The mesh to free.
  47984. * @hidden
  47985. */
  47986. _disposeMesh(mesh: Mesh): void;
  47987. /**
  47988. * Gets the class name of the effect layer
  47989. * @returns the string with the class name of the effect layer
  47990. */
  47991. getClassName(): string;
  47992. /**
  47993. * Serializes this glow layer
  47994. * @returns a serialized glow layer object
  47995. */
  47996. serialize(): any;
  47997. /**
  47998. * Creates a Glow Layer from parsed glow layer data
  47999. * @param parsedGlowLayer defines glow layer data
  48000. * @param scene defines the current scene
  48001. * @param rootUrl defines the root URL containing the glow layer information
  48002. * @returns a parsed Glow Layer
  48003. */
  48004. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48005. }
  48006. }
  48007. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48008. /** @hidden */
  48009. export var glowBlurPostProcessPixelShader: {
  48010. name: string;
  48011. shader: string;
  48012. };
  48013. }
  48014. declare module "babylonjs/Layers/highlightLayer" {
  48015. import { Observable } from "babylonjs/Misc/observable";
  48016. import { Nullable } from "babylonjs/types";
  48017. import { Camera } from "babylonjs/Cameras/camera";
  48018. import { Scene } from "babylonjs/scene";
  48019. import { Color3, Color4 } from "babylonjs/Maths/math";
  48020. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48022. import { Mesh } from "babylonjs/Meshes/mesh";
  48023. import { Effect } from "babylonjs/Materials/effect";
  48024. import { Material } from "babylonjs/Materials/material";
  48025. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48026. import "babylonjs/Shaders/glowMapMerge.fragment";
  48027. import "babylonjs/Shaders/glowMapMerge.vertex";
  48028. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48029. module "babylonjs/abstractScene" {
  48030. interface AbstractScene {
  48031. /**
  48032. * Return a the first highlight layer of the scene with a given name.
  48033. * @param name The name of the highlight layer to look for.
  48034. * @return The highlight layer if found otherwise null.
  48035. */
  48036. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48037. }
  48038. }
  48039. /**
  48040. * Highlight layer options. This helps customizing the behaviour
  48041. * of the highlight layer.
  48042. */
  48043. export interface IHighlightLayerOptions {
  48044. /**
  48045. * Multiplication factor apply to the canvas size to compute the render target size
  48046. * used to generated the glowing objects (the smaller the faster).
  48047. */
  48048. mainTextureRatio: number;
  48049. /**
  48050. * Enforces a fixed size texture to ensure resize independant blur.
  48051. */
  48052. mainTextureFixedSize?: number;
  48053. /**
  48054. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48055. * of the picture to blur (the smaller the faster).
  48056. */
  48057. blurTextureSizeRatio: number;
  48058. /**
  48059. * How big in texel of the blur texture is the vertical blur.
  48060. */
  48061. blurVerticalSize: number;
  48062. /**
  48063. * How big in texel of the blur texture is the horizontal blur.
  48064. */
  48065. blurHorizontalSize: number;
  48066. /**
  48067. * Alpha blending mode used to apply the blur. Default is combine.
  48068. */
  48069. alphaBlendingMode: number;
  48070. /**
  48071. * The camera attached to the layer.
  48072. */
  48073. camera: Nullable<Camera>;
  48074. /**
  48075. * Should we display highlight as a solid stroke?
  48076. */
  48077. isStroke?: boolean;
  48078. /**
  48079. * The rendering group to draw the layer in.
  48080. */
  48081. renderingGroupId: number;
  48082. }
  48083. /**
  48084. * The highlight layer Helps adding a glow effect around a mesh.
  48085. *
  48086. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48087. * glowy meshes to your scene.
  48088. *
  48089. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48090. */
  48091. export class HighlightLayer extends EffectLayer {
  48092. name: string;
  48093. /**
  48094. * Effect Name of the highlight layer.
  48095. */
  48096. static readonly EffectName: string;
  48097. /**
  48098. * The neutral color used during the preparation of the glow effect.
  48099. * This is black by default as the blend operation is a blend operation.
  48100. */
  48101. static NeutralColor: Color4;
  48102. /**
  48103. * Stencil value used for glowing meshes.
  48104. */
  48105. static GlowingMeshStencilReference: number;
  48106. /**
  48107. * Stencil value used for the other meshes in the scene.
  48108. */
  48109. static NormalMeshStencilReference: number;
  48110. /**
  48111. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48112. */
  48113. innerGlow: boolean;
  48114. /**
  48115. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48116. */
  48117. outerGlow: boolean;
  48118. /**
  48119. * Specifies the horizontal size of the blur.
  48120. */
  48121. /**
  48122. * Gets the horizontal size of the blur.
  48123. */
  48124. blurHorizontalSize: number;
  48125. /**
  48126. * Specifies the vertical size of the blur.
  48127. */
  48128. /**
  48129. * Gets the vertical size of the blur.
  48130. */
  48131. blurVerticalSize: number;
  48132. /**
  48133. * An event triggered when the highlight layer is being blurred.
  48134. */
  48135. onBeforeBlurObservable: Observable<HighlightLayer>;
  48136. /**
  48137. * An event triggered when the highlight layer has been blurred.
  48138. */
  48139. onAfterBlurObservable: Observable<HighlightLayer>;
  48140. private _instanceGlowingMeshStencilReference;
  48141. private _options;
  48142. private _downSamplePostprocess;
  48143. private _horizontalBlurPostprocess;
  48144. private _verticalBlurPostprocess;
  48145. private _blurTexture;
  48146. private _meshes;
  48147. private _excludedMeshes;
  48148. /**
  48149. * Instantiates a new highlight Layer and references it to the scene..
  48150. * @param name The name of the layer
  48151. * @param scene The scene to use the layer in
  48152. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48153. */
  48154. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48155. /**
  48156. * Get the effect name of the layer.
  48157. * @return The effect name
  48158. */
  48159. getEffectName(): string;
  48160. /**
  48161. * Create the merge effect. This is the shader use to blit the information back
  48162. * to the main canvas at the end of the scene rendering.
  48163. */
  48164. protected _createMergeEffect(): Effect;
  48165. /**
  48166. * Creates the render target textures and post processes used in the highlight layer.
  48167. */
  48168. protected _createTextureAndPostProcesses(): void;
  48169. /**
  48170. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48171. */
  48172. needStencil(): boolean;
  48173. /**
  48174. * Checks for the readiness of the element composing the layer.
  48175. * @param subMesh the mesh to check for
  48176. * @param useInstances specify wether or not to use instances to render the mesh
  48177. * @param emissiveTexture the associated emissive texture used to generate the glow
  48178. * @return true if ready otherwise, false
  48179. */
  48180. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48181. /**
  48182. * Implementation specific of rendering the generating effect on the main canvas.
  48183. * @param effect The effect used to render through
  48184. */
  48185. protected _internalRender(effect: Effect): void;
  48186. /**
  48187. * Returns true if the layer contains information to display, otherwise false.
  48188. */
  48189. shouldRender(): boolean;
  48190. /**
  48191. * Returns true if the mesh should render, otherwise false.
  48192. * @param mesh The mesh to render
  48193. * @returns true if it should render otherwise false
  48194. */
  48195. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48196. /**
  48197. * Sets the required values for both the emissive texture and and the main color.
  48198. */
  48199. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48200. /**
  48201. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48202. * @param mesh The mesh to exclude from the highlight layer
  48203. */
  48204. addExcludedMesh(mesh: Mesh): void;
  48205. /**
  48206. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48207. * @param mesh The mesh to highlight
  48208. */
  48209. removeExcludedMesh(mesh: Mesh): void;
  48210. /**
  48211. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48212. * @param mesh mesh to test
  48213. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48214. */
  48215. hasMesh(mesh: AbstractMesh): boolean;
  48216. /**
  48217. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48218. * @param mesh The mesh to highlight
  48219. * @param color The color of the highlight
  48220. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48221. */
  48222. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48223. /**
  48224. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48225. * @param mesh The mesh to highlight
  48226. */
  48227. removeMesh(mesh: Mesh): void;
  48228. /**
  48229. * Force the stencil to the normal expected value for none glowing parts
  48230. */
  48231. private _defaultStencilReference;
  48232. /**
  48233. * Free any resources and references associated to a mesh.
  48234. * Internal use
  48235. * @param mesh The mesh to free.
  48236. * @hidden
  48237. */
  48238. _disposeMesh(mesh: Mesh): void;
  48239. /**
  48240. * Dispose the highlight layer and free resources.
  48241. */
  48242. dispose(): void;
  48243. /**
  48244. * Gets the class name of the effect layer
  48245. * @returns the string with the class name of the effect layer
  48246. */
  48247. getClassName(): string;
  48248. /**
  48249. * Serializes this Highlight layer
  48250. * @returns a serialized Highlight layer object
  48251. */
  48252. serialize(): any;
  48253. /**
  48254. * Creates a Highlight layer from parsed Highlight layer data
  48255. * @param parsedHightlightLayer defines the Highlight layer data
  48256. * @param scene defines the current scene
  48257. * @param rootUrl defines the root URL containing the Highlight layer information
  48258. * @returns a parsed Highlight layer
  48259. */
  48260. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48261. }
  48262. }
  48263. declare module "babylonjs/Layers/index" {
  48264. export * from "babylonjs/Layers/effectLayer";
  48265. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48266. export * from "babylonjs/Layers/glowLayer";
  48267. export * from "babylonjs/Layers/highlightLayer";
  48268. export * from "babylonjs/Layers/layer";
  48269. export * from "babylonjs/Layers/layerSceneComponent";
  48270. }
  48271. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48272. /** @hidden */
  48273. export var lensFlarePixelShader: {
  48274. name: string;
  48275. shader: string;
  48276. };
  48277. }
  48278. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48279. /** @hidden */
  48280. export var lensFlareVertexShader: {
  48281. name: string;
  48282. shader: string;
  48283. };
  48284. }
  48285. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48286. import { Scene } from "babylonjs/scene";
  48287. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48289. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48290. import "babylonjs/Shaders/lensFlare.fragment";
  48291. import "babylonjs/Shaders/lensFlare.vertex";
  48292. /**
  48293. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48294. * It is usually composed of several `lensFlare`.
  48295. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48296. */
  48297. export class LensFlareSystem {
  48298. /**
  48299. * Define the name of the lens flare system
  48300. */
  48301. name: string;
  48302. /**
  48303. * List of lens flares used in this system.
  48304. */
  48305. lensFlares: LensFlare[];
  48306. /**
  48307. * Define a limit from the border the lens flare can be visible.
  48308. */
  48309. borderLimit: number;
  48310. /**
  48311. * Define a viewport border we do not want to see the lens flare in.
  48312. */
  48313. viewportBorder: number;
  48314. /**
  48315. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48316. */
  48317. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48318. /**
  48319. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48320. */
  48321. layerMask: number;
  48322. /**
  48323. * Define the id of the lens flare system in the scene.
  48324. * (equal to name by default)
  48325. */
  48326. id: string;
  48327. private _scene;
  48328. private _emitter;
  48329. private _vertexBuffers;
  48330. private _indexBuffer;
  48331. private _effect;
  48332. private _positionX;
  48333. private _positionY;
  48334. private _isEnabled;
  48335. /** @hidden */
  48336. static _SceneComponentInitialization: (scene: Scene) => void;
  48337. /**
  48338. * Instantiates a lens flare system.
  48339. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48340. * It is usually composed of several `lensFlare`.
  48341. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48342. * @param name Define the name of the lens flare system in the scene
  48343. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48344. * @param scene Define the scene the lens flare system belongs to
  48345. */
  48346. constructor(
  48347. /**
  48348. * Define the name of the lens flare system
  48349. */
  48350. name: string, emitter: any, scene: Scene);
  48351. /**
  48352. * Define if the lens flare system is enabled.
  48353. */
  48354. isEnabled: boolean;
  48355. /**
  48356. * Get the scene the effects belongs to.
  48357. * @returns the scene holding the lens flare system
  48358. */
  48359. getScene(): Scene;
  48360. /**
  48361. * Get the emitter of the lens flare system.
  48362. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48363. * @returns the emitter of the lens flare system
  48364. */
  48365. getEmitter(): any;
  48366. /**
  48367. * Set the emitter of the lens flare system.
  48368. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48369. * @param newEmitter Define the new emitter of the system
  48370. */
  48371. setEmitter(newEmitter: any): void;
  48372. /**
  48373. * Get the lens flare system emitter position.
  48374. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48375. * @returns the position
  48376. */
  48377. getEmitterPosition(): Vector3;
  48378. /**
  48379. * @hidden
  48380. */
  48381. computeEffectivePosition(globalViewport: Viewport): boolean;
  48382. /** @hidden */
  48383. _isVisible(): boolean;
  48384. /**
  48385. * @hidden
  48386. */
  48387. render(): boolean;
  48388. /**
  48389. * Dispose and release the lens flare with its associated resources.
  48390. */
  48391. dispose(): void;
  48392. /**
  48393. * Parse a lens flare system from a JSON repressentation
  48394. * @param parsedLensFlareSystem Define the JSON to parse
  48395. * @param scene Define the scene the parsed system should be instantiated in
  48396. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48397. * @returns the parsed system
  48398. */
  48399. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48400. /**
  48401. * Serialize the current Lens Flare System into a JSON representation.
  48402. * @returns the serialized JSON
  48403. */
  48404. serialize(): any;
  48405. }
  48406. }
  48407. declare module "babylonjs/LensFlares/lensFlare" {
  48408. import { Nullable } from "babylonjs/types";
  48409. import { Color3 } from "babylonjs/Maths/math";
  48410. import { Texture } from "babylonjs/Materials/Textures/texture";
  48411. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48412. /**
  48413. * This represents one of the lens effect in a `lensFlareSystem`.
  48414. * It controls one of the indiviual texture used in the effect.
  48415. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48416. */
  48417. export class LensFlare {
  48418. /**
  48419. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48420. */
  48421. size: number;
  48422. /**
  48423. * 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.
  48424. */
  48425. position: number;
  48426. /**
  48427. * Define the lens color.
  48428. */
  48429. color: Color3;
  48430. /**
  48431. * Define the lens texture.
  48432. */
  48433. texture: Nullable<Texture>;
  48434. /**
  48435. * Define the alpha mode to render this particular lens.
  48436. */
  48437. alphaMode: number;
  48438. private _system;
  48439. /**
  48440. * Creates a new Lens Flare.
  48441. * This represents one of the lens effect in a `lensFlareSystem`.
  48442. * It controls one of the indiviual texture used in the effect.
  48443. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48444. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48445. * @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.
  48446. * @param color Define the lens color
  48447. * @param imgUrl Define the lens texture url
  48448. * @param system Define the `lensFlareSystem` this flare is part of
  48449. * @returns The newly created Lens Flare
  48450. */
  48451. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48452. /**
  48453. * Instantiates a new Lens Flare.
  48454. * This represents one of the lens effect in a `lensFlareSystem`.
  48455. * It controls one of the indiviual texture used in the effect.
  48456. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48457. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48458. * @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.
  48459. * @param color Define the lens color
  48460. * @param imgUrl Define the lens texture url
  48461. * @param system Define the `lensFlareSystem` this flare is part of
  48462. */
  48463. constructor(
  48464. /**
  48465. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48466. */
  48467. size: number,
  48468. /**
  48469. * 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.
  48470. */
  48471. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48472. /**
  48473. * Dispose and release the lens flare with its associated resources.
  48474. */
  48475. dispose(): void;
  48476. }
  48477. }
  48478. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  48479. import { Nullable } from "babylonjs/types";
  48480. import { Scene } from "babylonjs/scene";
  48481. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48482. import { AbstractScene } from "babylonjs/abstractScene";
  48483. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48484. module "babylonjs/abstractScene" {
  48485. interface AbstractScene {
  48486. /**
  48487. * The list of lens flare system added to the scene
  48488. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48489. */
  48490. lensFlareSystems: Array<LensFlareSystem>;
  48491. /**
  48492. * Removes the given lens flare system from this scene.
  48493. * @param toRemove The lens flare system to remove
  48494. * @returns The index of the removed lens flare system
  48495. */
  48496. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48497. /**
  48498. * Adds the given lens flare system to this scene
  48499. * @param newLensFlareSystem The lens flare system to add
  48500. */
  48501. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48502. /**
  48503. * Gets a lens flare system using its name
  48504. * @param name defines the name to look for
  48505. * @returns the lens flare system or null if not found
  48506. */
  48507. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48508. /**
  48509. * Gets a lens flare system using its id
  48510. * @param id defines the id to look for
  48511. * @returns the lens flare system or null if not found
  48512. */
  48513. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48514. }
  48515. }
  48516. /**
  48517. * Defines the lens flare scene component responsible to manage any lens flares
  48518. * in a given scene.
  48519. */
  48520. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48521. /**
  48522. * The component name helpfull to identify the component in the list of scene components.
  48523. */
  48524. readonly name: string;
  48525. /**
  48526. * The scene the component belongs to.
  48527. */
  48528. scene: Scene;
  48529. /**
  48530. * Creates a new instance of the component for the given scene
  48531. * @param scene Defines the scene to register the component in
  48532. */
  48533. constructor(scene: Scene);
  48534. /**
  48535. * Registers the component in a given scene
  48536. */
  48537. register(): void;
  48538. /**
  48539. * Rebuilds the elements related to this component in case of
  48540. * context lost for instance.
  48541. */
  48542. rebuild(): void;
  48543. /**
  48544. * Adds all the element from the container to the scene
  48545. * @param container the container holding the elements
  48546. */
  48547. addFromContainer(container: AbstractScene): void;
  48548. /**
  48549. * Removes all the elements in the container from the scene
  48550. * @param container contains the elements to remove
  48551. * @param dispose if the removed element should be disposed (default: false)
  48552. */
  48553. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48554. /**
  48555. * Serializes the component data to the specified json object
  48556. * @param serializationObject The object to serialize to
  48557. */
  48558. serialize(serializationObject: any): void;
  48559. /**
  48560. * Disposes the component and the associated ressources.
  48561. */
  48562. dispose(): void;
  48563. private _draw;
  48564. }
  48565. }
  48566. declare module "babylonjs/LensFlares/index" {
  48567. export * from "babylonjs/LensFlares/lensFlare";
  48568. export * from "babylonjs/LensFlares/lensFlareSystem";
  48569. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48570. }
  48571. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48572. import { Scene } from "babylonjs/scene";
  48573. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48574. import { AbstractScene } from "babylonjs/abstractScene";
  48575. /**
  48576. * Defines the shadow generator component responsible to manage any shadow generators
  48577. * in a given scene.
  48578. */
  48579. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48580. /**
  48581. * The component name helpfull to identify the component in the list of scene components.
  48582. */
  48583. readonly name: string;
  48584. /**
  48585. * The scene the component belongs to.
  48586. */
  48587. scene: Scene;
  48588. /**
  48589. * Creates a new instance of the component for the given scene
  48590. * @param scene Defines the scene to register the component in
  48591. */
  48592. constructor(scene: Scene);
  48593. /**
  48594. * Registers the component in a given scene
  48595. */
  48596. register(): void;
  48597. /**
  48598. * Rebuilds the elements related to this component in case of
  48599. * context lost for instance.
  48600. */
  48601. rebuild(): void;
  48602. /**
  48603. * Serializes the component data to the specified json object
  48604. * @param serializationObject The object to serialize to
  48605. */
  48606. serialize(serializationObject: any): void;
  48607. /**
  48608. * Adds all the element from the container to the scene
  48609. * @param container the container holding the elements
  48610. */
  48611. addFromContainer(container: AbstractScene): void;
  48612. /**
  48613. * Removes all the elements in the container from the scene
  48614. * @param container contains the elements to remove
  48615. * @param dispose if the removed element should be disposed (default: false)
  48616. */
  48617. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48618. /**
  48619. * Rebuilds the elements related to this component in case of
  48620. * context lost for instance.
  48621. */
  48622. dispose(): void;
  48623. private _gatherRenderTargets;
  48624. }
  48625. }
  48626. declare module "babylonjs/Lights/Shadows/index" {
  48627. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48628. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48629. }
  48630. declare module "babylonjs/Lights/directionalLight" {
  48631. import { Camera } from "babylonjs/Cameras/camera";
  48632. import { Scene } from "babylonjs/scene";
  48633. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48635. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48636. import { Effect } from "babylonjs/Materials/effect";
  48637. /**
  48638. * A directional light is defined by a direction (what a surprise!).
  48639. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48640. * 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.
  48641. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48642. */
  48643. export class DirectionalLight extends ShadowLight {
  48644. private _shadowFrustumSize;
  48645. /**
  48646. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48647. */
  48648. /**
  48649. * Specifies a fix frustum size for the shadow generation.
  48650. */
  48651. shadowFrustumSize: number;
  48652. private _shadowOrthoScale;
  48653. /**
  48654. * Gets the shadow projection scale against the optimal computed one.
  48655. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48656. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48657. */
  48658. /**
  48659. * Sets the shadow projection scale against the optimal computed one.
  48660. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48661. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48662. */
  48663. shadowOrthoScale: number;
  48664. /**
  48665. * Automatically compute the projection matrix to best fit (including all the casters)
  48666. * on each frame.
  48667. */
  48668. autoUpdateExtends: boolean;
  48669. private _orthoLeft;
  48670. private _orthoRight;
  48671. private _orthoTop;
  48672. private _orthoBottom;
  48673. /**
  48674. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48675. * The directional light is emitted from everywhere in the given direction.
  48676. * It can cast shadows.
  48677. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48678. * @param name The friendly name of the light
  48679. * @param direction The direction of the light
  48680. * @param scene The scene the light belongs to
  48681. */
  48682. constructor(name: string, direction: Vector3, scene: Scene);
  48683. /**
  48684. * Returns the string "DirectionalLight".
  48685. * @return The class name
  48686. */
  48687. getClassName(): string;
  48688. /**
  48689. * Returns the integer 1.
  48690. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48691. */
  48692. getTypeID(): number;
  48693. /**
  48694. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48695. * Returns the DirectionalLight Shadow projection matrix.
  48696. */
  48697. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48698. /**
  48699. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48700. * Returns the DirectionalLight Shadow projection matrix.
  48701. */
  48702. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48703. /**
  48704. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48705. * Returns the DirectionalLight Shadow projection matrix.
  48706. */
  48707. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48708. protected _buildUniformLayout(): void;
  48709. /**
  48710. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48711. * @param effect The effect to update
  48712. * @param lightIndex The index of the light in the effect to update
  48713. * @returns The directional light
  48714. */
  48715. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48716. /**
  48717. * Gets the minZ used for shadow according to both the scene and the light.
  48718. *
  48719. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48720. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48721. * @param activeCamera The camera we are returning the min for
  48722. * @returns the depth min z
  48723. */
  48724. getDepthMinZ(activeCamera: Camera): number;
  48725. /**
  48726. * Gets the maxZ used for shadow according to both the scene and the light.
  48727. *
  48728. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48729. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48730. * @param activeCamera The camera we are returning the max for
  48731. * @returns the depth max z
  48732. */
  48733. getDepthMaxZ(activeCamera: Camera): number;
  48734. /**
  48735. * Prepares the list of defines specific to the light type.
  48736. * @param defines the list of defines
  48737. * @param lightIndex defines the index of the light for the effect
  48738. */
  48739. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48740. }
  48741. }
  48742. declare module "babylonjs/Lights/pointLight" {
  48743. import { Scene } from "babylonjs/scene";
  48744. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48746. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48747. import { Effect } from "babylonjs/Materials/effect";
  48748. /**
  48749. * A point light is a light defined by an unique point in world space.
  48750. * The light is emitted in every direction from this point.
  48751. * A good example of a point light is a standard light bulb.
  48752. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48753. */
  48754. export class PointLight extends ShadowLight {
  48755. private _shadowAngle;
  48756. /**
  48757. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48758. * This specifies what angle the shadow will use to be created.
  48759. *
  48760. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48761. */
  48762. /**
  48763. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48764. * This specifies what angle the shadow will use to be created.
  48765. *
  48766. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48767. */
  48768. shadowAngle: number;
  48769. /**
  48770. * Gets the direction if it has been set.
  48771. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48772. */
  48773. /**
  48774. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48775. */
  48776. direction: Vector3;
  48777. /**
  48778. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48779. * A PointLight emits the light in every direction.
  48780. * It can cast shadows.
  48781. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48782. * ```javascript
  48783. * var pointLight = new PointLight("pl", camera.position, scene);
  48784. * ```
  48785. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48786. * @param name The light friendly name
  48787. * @param position The position of the point light in the scene
  48788. * @param scene The scene the lights belongs to
  48789. */
  48790. constructor(name: string, position: Vector3, scene: Scene);
  48791. /**
  48792. * Returns the string "PointLight"
  48793. * @returns the class name
  48794. */
  48795. getClassName(): string;
  48796. /**
  48797. * Returns the integer 0.
  48798. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48799. */
  48800. getTypeID(): number;
  48801. /**
  48802. * Specifies wether or not the shadowmap should be a cube texture.
  48803. * @returns true if the shadowmap needs to be a cube texture.
  48804. */
  48805. needCube(): boolean;
  48806. /**
  48807. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48808. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48809. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48810. */
  48811. getShadowDirection(faceIndex?: number): Vector3;
  48812. /**
  48813. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48814. * - fov = PI / 2
  48815. * - aspect ratio : 1.0
  48816. * - z-near and far equal to the active camera minZ and maxZ.
  48817. * Returns the PointLight.
  48818. */
  48819. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48820. protected _buildUniformLayout(): void;
  48821. /**
  48822. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48823. * @param effect The effect to update
  48824. * @param lightIndex The index of the light in the effect to update
  48825. * @returns The point light
  48826. */
  48827. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48828. /**
  48829. * Prepares the list of defines specific to the light type.
  48830. * @param defines the list of defines
  48831. * @param lightIndex defines the index of the light for the effect
  48832. */
  48833. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48834. }
  48835. }
  48836. declare module "babylonjs/Lights/spotLight" {
  48837. import { Nullable } from "babylonjs/types";
  48838. import { Scene } from "babylonjs/scene";
  48839. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48841. import { Effect } from "babylonjs/Materials/effect";
  48842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48843. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48844. /**
  48845. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48846. * These values define a cone of light starting from the position, emitting toward the direction.
  48847. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48848. * and the exponent defines the speed of the decay of the light with distance (reach).
  48849. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48850. */
  48851. export class SpotLight extends ShadowLight {
  48852. private _angle;
  48853. private _innerAngle;
  48854. private _cosHalfAngle;
  48855. private _lightAngleScale;
  48856. private _lightAngleOffset;
  48857. /**
  48858. * Gets the cone angle of the spot light in Radians.
  48859. */
  48860. /**
  48861. * Sets the cone angle of the spot light in Radians.
  48862. */
  48863. angle: number;
  48864. /**
  48865. * Only used in gltf falloff mode, this defines the angle where
  48866. * the directional falloff will start before cutting at angle which could be seen
  48867. * as outer angle.
  48868. */
  48869. /**
  48870. * Only used in gltf falloff mode, this defines the angle where
  48871. * the directional falloff will start before cutting at angle which could be seen
  48872. * as outer angle.
  48873. */
  48874. innerAngle: number;
  48875. private _shadowAngleScale;
  48876. /**
  48877. * Allows scaling the angle of the light for shadow generation only.
  48878. */
  48879. /**
  48880. * Allows scaling the angle of the light for shadow generation only.
  48881. */
  48882. shadowAngleScale: number;
  48883. /**
  48884. * The light decay speed with the distance from the emission spot.
  48885. */
  48886. exponent: number;
  48887. private _projectionTextureMatrix;
  48888. /**
  48889. * Allows reading the projecton texture
  48890. */
  48891. readonly projectionTextureMatrix: Matrix;
  48892. protected _projectionTextureLightNear: number;
  48893. /**
  48894. * Gets the near clip of the Spotlight for texture projection.
  48895. */
  48896. /**
  48897. * Sets the near clip of the Spotlight for texture projection.
  48898. */
  48899. projectionTextureLightNear: number;
  48900. protected _projectionTextureLightFar: number;
  48901. /**
  48902. * Gets the far clip of the Spotlight for texture projection.
  48903. */
  48904. /**
  48905. * Sets the far clip of the Spotlight for texture projection.
  48906. */
  48907. projectionTextureLightFar: number;
  48908. protected _projectionTextureUpDirection: Vector3;
  48909. /**
  48910. * Gets the Up vector of the Spotlight for texture projection.
  48911. */
  48912. /**
  48913. * Sets the Up vector of the Spotlight for texture projection.
  48914. */
  48915. projectionTextureUpDirection: Vector3;
  48916. private _projectionTexture;
  48917. /**
  48918. * Gets the projection texture of the light.
  48919. */
  48920. /**
  48921. * Sets the projection texture of the light.
  48922. */
  48923. projectionTexture: Nullable<BaseTexture>;
  48924. private _projectionTextureViewLightDirty;
  48925. private _projectionTextureProjectionLightDirty;
  48926. private _projectionTextureDirty;
  48927. private _projectionTextureViewTargetVector;
  48928. private _projectionTextureViewLightMatrix;
  48929. private _projectionTextureProjectionLightMatrix;
  48930. private _projectionTextureScalingMatrix;
  48931. /**
  48932. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48933. * It can cast shadows.
  48934. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48935. * @param name The light friendly name
  48936. * @param position The position of the spot light in the scene
  48937. * @param direction The direction of the light in the scene
  48938. * @param angle The cone angle of the light in Radians
  48939. * @param exponent The light decay speed with the distance from the emission spot
  48940. * @param scene The scene the lights belongs to
  48941. */
  48942. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48943. /**
  48944. * Returns the string "SpotLight".
  48945. * @returns the class name
  48946. */
  48947. getClassName(): string;
  48948. /**
  48949. * Returns the integer 2.
  48950. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48951. */
  48952. getTypeID(): number;
  48953. /**
  48954. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48955. */
  48956. protected _setDirection(value: Vector3): void;
  48957. /**
  48958. * Overrides the position setter to recompute the projection texture view light Matrix.
  48959. */
  48960. protected _setPosition(value: Vector3): void;
  48961. /**
  48962. * 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.
  48963. * Returns the SpotLight.
  48964. */
  48965. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48966. protected _computeProjectionTextureViewLightMatrix(): void;
  48967. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48968. /**
  48969. * Main function for light texture projection matrix computing.
  48970. */
  48971. protected _computeProjectionTextureMatrix(): void;
  48972. protected _buildUniformLayout(): void;
  48973. private _computeAngleValues;
  48974. /**
  48975. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48976. * @param effect The effect to update
  48977. * @param lightIndex The index of the light in the effect to update
  48978. * @returns The spot light
  48979. */
  48980. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48981. /**
  48982. * Disposes the light and the associated resources.
  48983. */
  48984. dispose(): void;
  48985. /**
  48986. * Prepares the list of defines specific to the light type.
  48987. * @param defines the list of defines
  48988. * @param lightIndex defines the index of the light for the effect
  48989. */
  48990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48991. }
  48992. }
  48993. declare module "babylonjs/Lights/index" {
  48994. export * from "babylonjs/Lights/light";
  48995. export * from "babylonjs/Lights/shadowLight";
  48996. export * from "babylonjs/Lights/Shadows/index";
  48997. export * from "babylonjs/Lights/directionalLight";
  48998. export * from "babylonjs/Lights/hemisphericLight";
  48999. export * from "babylonjs/Lights/pointLight";
  49000. export * from "babylonjs/Lights/spotLight";
  49001. }
  49002. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49003. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49004. /**
  49005. * Header information of HDR texture files.
  49006. */
  49007. export interface HDRInfo {
  49008. /**
  49009. * The height of the texture in pixels.
  49010. */
  49011. height: number;
  49012. /**
  49013. * The width of the texture in pixels.
  49014. */
  49015. width: number;
  49016. /**
  49017. * The index of the beginning of the data in the binary file.
  49018. */
  49019. dataPosition: number;
  49020. }
  49021. /**
  49022. * This groups tools to convert HDR texture to native colors array.
  49023. */
  49024. export class HDRTools {
  49025. private static Ldexp;
  49026. private static Rgbe2float;
  49027. private static readStringLine;
  49028. /**
  49029. * Reads header information from an RGBE texture stored in a native array.
  49030. * More information on this format are available here:
  49031. * https://en.wikipedia.org/wiki/RGBE_image_format
  49032. *
  49033. * @param uint8array The binary file stored in native array.
  49034. * @return The header information.
  49035. */
  49036. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49037. /**
  49038. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49039. * This RGBE texture needs to store the information as a panorama.
  49040. *
  49041. * More information on this format are available here:
  49042. * https://en.wikipedia.org/wiki/RGBE_image_format
  49043. *
  49044. * @param buffer The binary file stored in an array buffer.
  49045. * @param size The expected size of the extracted cubemap.
  49046. * @return The Cube Map information.
  49047. */
  49048. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49049. /**
  49050. * Returns the pixels data extracted from an RGBE texture.
  49051. * This pixels will be stored left to right up to down in the R G B order in one array.
  49052. *
  49053. * More information on this format are available here:
  49054. * https://en.wikipedia.org/wiki/RGBE_image_format
  49055. *
  49056. * @param uint8array The binary file stored in an array buffer.
  49057. * @param hdrInfo The header information of the file.
  49058. * @return The pixels data in RGB right to left up to down order.
  49059. */
  49060. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49061. private static RGBE_ReadPixels_RLE;
  49062. }
  49063. }
  49064. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49065. import { Nullable } from "babylonjs/types";
  49066. import { Scene } from "babylonjs/scene";
  49067. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49069. /**
  49070. * This represents a texture coming from an HDR input.
  49071. *
  49072. * The only supported format is currently panorama picture stored in RGBE format.
  49073. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49074. */
  49075. export class HDRCubeTexture extends BaseTexture {
  49076. private static _facesMapping;
  49077. private _generateHarmonics;
  49078. private _noMipmap;
  49079. private _textureMatrix;
  49080. private _size;
  49081. private _onLoad;
  49082. private _onError;
  49083. /**
  49084. * The texture URL.
  49085. */
  49086. url: string;
  49087. /**
  49088. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49089. */
  49090. coordinatesMode: number;
  49091. protected _isBlocking: boolean;
  49092. /**
  49093. * Sets wether or not the texture is blocking during loading.
  49094. */
  49095. /**
  49096. * Gets wether or not the texture is blocking during loading.
  49097. */
  49098. isBlocking: boolean;
  49099. protected _rotationY: number;
  49100. /**
  49101. * Sets texture matrix rotation angle around Y axis in radians.
  49102. */
  49103. /**
  49104. * Gets texture matrix rotation angle around Y axis radians.
  49105. */
  49106. rotationY: number;
  49107. /**
  49108. * Gets or sets the center of the bounding box associated with the cube texture
  49109. * It must define where the camera used to render the texture was set
  49110. */
  49111. boundingBoxPosition: Vector3;
  49112. private _boundingBoxSize;
  49113. /**
  49114. * Gets or sets the size of the bounding box associated with the cube texture
  49115. * When defined, the cubemap will switch to local mode
  49116. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49117. * @example https://www.babylonjs-playground.com/#RNASML
  49118. */
  49119. boundingBoxSize: Vector3;
  49120. /**
  49121. * Instantiates an HDRTexture from the following parameters.
  49122. *
  49123. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49124. * @param scene The scene the texture will be used in
  49125. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49126. * @param noMipmap Forces to not generate the mipmap if true
  49127. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49128. * @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)
  49129. * @param reserved Reserved flag for internal use.
  49130. */
  49131. 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>);
  49132. /**
  49133. * Get the current class name of the texture useful for serialization or dynamic coding.
  49134. * @returns "HDRCubeTexture"
  49135. */
  49136. getClassName(): string;
  49137. /**
  49138. * Occurs when the file is raw .hdr file.
  49139. */
  49140. private loadTexture;
  49141. clone(): HDRCubeTexture;
  49142. delayLoad(): void;
  49143. /**
  49144. * Get the texture reflection matrix used to rotate/transform the reflection.
  49145. * @returns the reflection matrix
  49146. */
  49147. getReflectionTextureMatrix(): Matrix;
  49148. /**
  49149. * Set the texture reflection matrix used to rotate/transform the reflection.
  49150. * @param value Define the reflection matrix to set
  49151. */
  49152. setReflectionTextureMatrix(value: Matrix): void;
  49153. /**
  49154. * Parses a JSON representation of an HDR Texture in order to create the texture
  49155. * @param parsedTexture Define the JSON representation
  49156. * @param scene Define the scene the texture should be created in
  49157. * @param rootUrl Define the root url in case we need to load relative dependencies
  49158. * @returns the newly created texture after parsing
  49159. */
  49160. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49161. serialize(): any;
  49162. }
  49163. }
  49164. declare module "babylonjs/Physics/physicsEngine" {
  49165. import { Nullable } from "babylonjs/types";
  49166. import { Vector3 } from "babylonjs/Maths/math";
  49167. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49168. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49169. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49170. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49171. /**
  49172. * Class used to control physics engine
  49173. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49174. */
  49175. export class PhysicsEngine implements IPhysicsEngine {
  49176. private _physicsPlugin;
  49177. /**
  49178. * Global value used to control the smallest number supported by the simulation
  49179. */
  49180. static Epsilon: number;
  49181. private _impostors;
  49182. private _joints;
  49183. /**
  49184. * Gets the gravity vector used by the simulation
  49185. */
  49186. gravity: Vector3;
  49187. /**
  49188. * Factory used to create the default physics plugin.
  49189. * @returns The default physics plugin
  49190. */
  49191. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49192. /**
  49193. * Creates a new Physics Engine
  49194. * @param gravity defines the gravity vector used by the simulation
  49195. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49196. */
  49197. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49198. /**
  49199. * Sets the gravity vector used by the simulation
  49200. * @param gravity defines the gravity vector to use
  49201. */
  49202. setGravity(gravity: Vector3): void;
  49203. /**
  49204. * Set the time step of the physics engine.
  49205. * Default is 1/60.
  49206. * To slow it down, enter 1/600 for example.
  49207. * To speed it up, 1/30
  49208. * @param newTimeStep defines the new timestep to apply to this world.
  49209. */
  49210. setTimeStep(newTimeStep?: number): void;
  49211. /**
  49212. * Get the time step of the physics engine.
  49213. * @returns the current time step
  49214. */
  49215. getTimeStep(): number;
  49216. /**
  49217. * Release all resources
  49218. */
  49219. dispose(): void;
  49220. /**
  49221. * Gets the name of the current physics plugin
  49222. * @returns the name of the plugin
  49223. */
  49224. getPhysicsPluginName(): string;
  49225. /**
  49226. * Adding a new impostor for the impostor tracking.
  49227. * This will be done by the impostor itself.
  49228. * @param impostor the impostor to add
  49229. */
  49230. addImpostor(impostor: PhysicsImpostor): void;
  49231. /**
  49232. * Remove an impostor from the engine.
  49233. * This impostor and its mesh will not longer be updated by the physics engine.
  49234. * @param impostor the impostor to remove
  49235. */
  49236. removeImpostor(impostor: PhysicsImpostor): void;
  49237. /**
  49238. * Add a joint to the physics engine
  49239. * @param mainImpostor defines the main impostor to which the joint is added.
  49240. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49241. * @param joint defines the joint that will connect both impostors.
  49242. */
  49243. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49244. /**
  49245. * Removes a joint from the simulation
  49246. * @param mainImpostor defines the impostor used with the joint
  49247. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49248. * @param joint defines the joint to remove
  49249. */
  49250. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49251. /**
  49252. * Called by the scene. No need to call it.
  49253. * @param delta defines the timespam between frames
  49254. */
  49255. _step(delta: number): void;
  49256. /**
  49257. * Gets the current plugin used to run the simulation
  49258. * @returns current plugin
  49259. */
  49260. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49261. /**
  49262. * Gets the list of physic impostors
  49263. * @returns an array of PhysicsImpostor
  49264. */
  49265. getImpostors(): Array<PhysicsImpostor>;
  49266. /**
  49267. * Gets the impostor for a physics enabled object
  49268. * @param object defines the object impersonated by the impostor
  49269. * @returns the PhysicsImpostor or null if not found
  49270. */
  49271. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49272. /**
  49273. * Gets the impostor for a physics body object
  49274. * @param body defines physics body used by the impostor
  49275. * @returns the PhysicsImpostor or null if not found
  49276. */
  49277. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49278. /**
  49279. * Does a raycast in the physics world
  49280. * @param from when should the ray start?
  49281. * @param to when should the ray end?
  49282. * @returns PhysicsRaycastResult
  49283. */
  49284. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49285. }
  49286. }
  49287. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49288. import { Nullable } from "babylonjs/types";
  49289. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49291. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49292. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49293. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49294. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49295. /** @hidden */
  49296. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49297. private _useDeltaForWorldStep;
  49298. world: any;
  49299. name: string;
  49300. private _physicsMaterials;
  49301. private _fixedTimeStep;
  49302. private _cannonRaycastResult;
  49303. private _raycastResult;
  49304. BJSCANNON: any;
  49305. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49306. setGravity(gravity: Vector3): void;
  49307. setTimeStep(timeStep: number): void;
  49308. getTimeStep(): number;
  49309. executeStep(delta: number): void;
  49310. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49311. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49312. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49313. private _processChildMeshes;
  49314. removePhysicsBody(impostor: PhysicsImpostor): void;
  49315. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49316. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49317. private _addMaterial;
  49318. private _checkWithEpsilon;
  49319. private _createShape;
  49320. private _createHeightmap;
  49321. private _minus90X;
  49322. private _plus90X;
  49323. private _tmpPosition;
  49324. private _tmpDeltaPosition;
  49325. private _tmpUnityRotation;
  49326. private _updatePhysicsBodyTransformation;
  49327. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49328. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49329. isSupported(): boolean;
  49330. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49331. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49332. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49333. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49334. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49335. getBodyMass(impostor: PhysicsImpostor): number;
  49336. getBodyFriction(impostor: PhysicsImpostor): number;
  49337. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49338. getBodyRestitution(impostor: PhysicsImpostor): number;
  49339. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49340. sleepBody(impostor: PhysicsImpostor): void;
  49341. wakeUpBody(impostor: PhysicsImpostor): void;
  49342. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49343. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49344. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49345. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49346. getRadius(impostor: PhysicsImpostor): number;
  49347. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49348. dispose(): void;
  49349. private _extendNamespace;
  49350. /**
  49351. * Does a raycast in the physics world
  49352. * @param from when should the ray start?
  49353. * @param to when should the ray end?
  49354. * @returns PhysicsRaycastResult
  49355. */
  49356. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49357. }
  49358. }
  49359. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49360. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49361. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49362. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49364. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49365. import { Nullable } from "babylonjs/types";
  49366. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49367. /** @hidden */
  49368. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49369. world: any;
  49370. name: string;
  49371. BJSOIMO: any;
  49372. private _raycastResult;
  49373. constructor(iterations?: number, oimoInjection?: any);
  49374. setGravity(gravity: Vector3): void;
  49375. setTimeStep(timeStep: number): void;
  49376. getTimeStep(): number;
  49377. private _tmpImpostorsArray;
  49378. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49379. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49380. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49381. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49382. private _tmpPositionVector;
  49383. removePhysicsBody(impostor: PhysicsImpostor): void;
  49384. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49385. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49386. isSupported(): boolean;
  49387. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49388. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49389. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49390. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49391. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49392. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49393. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49394. getBodyMass(impostor: PhysicsImpostor): number;
  49395. getBodyFriction(impostor: PhysicsImpostor): number;
  49396. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49397. getBodyRestitution(impostor: PhysicsImpostor): number;
  49398. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49399. sleepBody(impostor: PhysicsImpostor): void;
  49400. wakeUpBody(impostor: PhysicsImpostor): void;
  49401. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49402. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49403. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49404. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49405. getRadius(impostor: PhysicsImpostor): number;
  49406. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49407. dispose(): void;
  49408. /**
  49409. * Does a raycast in the physics world
  49410. * @param from when should the ray start?
  49411. * @param to when should the ray end?
  49412. * @returns PhysicsRaycastResult
  49413. */
  49414. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49415. }
  49416. }
  49417. declare module "babylonjs/Probes/reflectionProbe" {
  49418. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49419. import { Vector3 } from "babylonjs/Maths/math";
  49420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49421. import { Nullable } from "babylonjs/types";
  49422. import { Scene } from "babylonjs/scene";
  49423. module "babylonjs/abstractScene" {
  49424. interface AbstractScene {
  49425. /**
  49426. * The list of reflection probes added to the scene
  49427. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49428. */
  49429. reflectionProbes: Array<ReflectionProbe>;
  49430. /**
  49431. * Removes the given reflection probe from this scene.
  49432. * @param toRemove The reflection probe to remove
  49433. * @returns The index of the removed reflection probe
  49434. */
  49435. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49436. /**
  49437. * Adds the given reflection probe to this scene.
  49438. * @param newReflectionProbe The reflection probe to add
  49439. */
  49440. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49441. }
  49442. }
  49443. /**
  49444. * Class used to generate realtime reflection / refraction cube textures
  49445. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49446. */
  49447. export class ReflectionProbe {
  49448. /** defines the name of the probe */
  49449. name: string;
  49450. private _scene;
  49451. private _renderTargetTexture;
  49452. private _projectionMatrix;
  49453. private _viewMatrix;
  49454. private _target;
  49455. private _add;
  49456. private _attachedMesh;
  49457. private _invertYAxis;
  49458. /** Gets or sets probe position (center of the cube map) */
  49459. position: Vector3;
  49460. /**
  49461. * Creates a new reflection probe
  49462. * @param name defines the name of the probe
  49463. * @param size defines the texture resolution (for each face)
  49464. * @param scene defines the hosting scene
  49465. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49466. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49467. */
  49468. constructor(
  49469. /** defines the name of the probe */
  49470. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49471. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49472. samples: number;
  49473. /** Gets or sets the refresh rate to use (on every frame by default) */
  49474. refreshRate: number;
  49475. /**
  49476. * Gets the hosting scene
  49477. * @returns a Scene
  49478. */
  49479. getScene(): Scene;
  49480. /** Gets the internal CubeTexture used to render to */
  49481. readonly cubeTexture: RenderTargetTexture;
  49482. /** Gets the list of meshes to render */
  49483. readonly renderList: Nullable<AbstractMesh[]>;
  49484. /**
  49485. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49486. * @param mesh defines the mesh to attach to
  49487. */
  49488. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49489. /**
  49490. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49491. * @param renderingGroupId The rendering group id corresponding to its index
  49492. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49493. */
  49494. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49495. /**
  49496. * Clean all associated resources
  49497. */
  49498. dispose(): void;
  49499. /**
  49500. * Converts the reflection probe information to a readable string for debug purpose.
  49501. * @param fullDetails Supports for multiple levels of logging within scene loading
  49502. * @returns the human readable reflection probe info
  49503. */
  49504. toString(fullDetails?: boolean): string;
  49505. /**
  49506. * Get the class name of the relfection probe.
  49507. * @returns "ReflectionProbe"
  49508. */
  49509. getClassName(): string;
  49510. /**
  49511. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49512. * @returns The JSON representation of the texture
  49513. */
  49514. serialize(): any;
  49515. /**
  49516. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49517. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49518. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49519. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49520. * @returns The parsed reflection probe if successful
  49521. */
  49522. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49523. }
  49524. }
  49525. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  49526. /** @hidden */
  49527. export var _BabylonLoaderRegistered: boolean;
  49528. }
  49529. declare module "babylonjs/Loading/Plugins/index" {
  49530. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  49531. }
  49532. declare module "babylonjs/Loading/index" {
  49533. export * from "babylonjs/Loading/loadingScreen";
  49534. export * from "babylonjs/Loading/Plugins/index";
  49535. export * from "babylonjs/Loading/sceneLoader";
  49536. export * from "babylonjs/Loading/sceneLoaderFlags";
  49537. }
  49538. declare module "babylonjs/Materials/Background/index" {
  49539. export * from "babylonjs/Materials/Background/backgroundMaterial";
  49540. }
  49541. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49542. import { Scene } from "babylonjs/scene";
  49543. import { Color3 } from "babylonjs/Maths/math";
  49544. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49546. /**
  49547. * The Physically based simple base material of BJS.
  49548. *
  49549. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49550. * It is used as the base class for both the specGloss and metalRough conventions.
  49551. */
  49552. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49553. /**
  49554. * Number of Simultaneous lights allowed on the material.
  49555. */
  49556. maxSimultaneousLights: number;
  49557. /**
  49558. * If sets to true, disables all the lights affecting the material.
  49559. */
  49560. disableLighting: boolean;
  49561. /**
  49562. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49563. */
  49564. environmentTexture: BaseTexture;
  49565. /**
  49566. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49567. */
  49568. invertNormalMapX: boolean;
  49569. /**
  49570. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49571. */
  49572. invertNormalMapY: boolean;
  49573. /**
  49574. * Normal map used in the model.
  49575. */
  49576. normalTexture: BaseTexture;
  49577. /**
  49578. * Emissivie color used to self-illuminate the model.
  49579. */
  49580. emissiveColor: Color3;
  49581. /**
  49582. * Emissivie texture used to self-illuminate the model.
  49583. */
  49584. emissiveTexture: BaseTexture;
  49585. /**
  49586. * Occlusion Channel Strenght.
  49587. */
  49588. occlusionStrength: number;
  49589. /**
  49590. * Occlusion Texture of the material (adding extra occlusion effects).
  49591. */
  49592. occlusionTexture: BaseTexture;
  49593. /**
  49594. * Defines the alpha limits in alpha test mode.
  49595. */
  49596. alphaCutOff: number;
  49597. /**
  49598. * Gets the current double sided mode.
  49599. */
  49600. /**
  49601. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49602. */
  49603. doubleSided: boolean;
  49604. /**
  49605. * Stores the pre-calculated light information of a mesh in a texture.
  49606. */
  49607. lightmapTexture: BaseTexture;
  49608. /**
  49609. * If true, the light map contains occlusion information instead of lighting info.
  49610. */
  49611. useLightmapAsShadowmap: boolean;
  49612. /**
  49613. * Instantiates a new PBRMaterial instance.
  49614. *
  49615. * @param name The material name
  49616. * @param scene The scene the material will be use in.
  49617. */
  49618. constructor(name: string, scene: Scene);
  49619. getClassName(): string;
  49620. }
  49621. }
  49622. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49623. import { Scene } from "babylonjs/scene";
  49624. import { Color3 } from "babylonjs/Maths/math";
  49625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49626. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49627. /**
  49628. * The PBR material of BJS following the metal roughness convention.
  49629. *
  49630. * This fits to the PBR convention in the GLTF definition:
  49631. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49632. */
  49633. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49634. /**
  49635. * The base color has two different interpretations depending on the value of metalness.
  49636. * When the material is a metal, the base color is the specific measured reflectance value
  49637. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49638. * of the material.
  49639. */
  49640. baseColor: Color3;
  49641. /**
  49642. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49643. * well as opacity information in the alpha channel.
  49644. */
  49645. baseTexture: BaseTexture;
  49646. /**
  49647. * Specifies the metallic scalar value of the material.
  49648. * Can also be used to scale the metalness values of the metallic texture.
  49649. */
  49650. metallic: number;
  49651. /**
  49652. * Specifies the roughness scalar value of the material.
  49653. * Can also be used to scale the roughness values of the metallic texture.
  49654. */
  49655. roughness: number;
  49656. /**
  49657. * Texture containing both the metallic value in the B channel and the
  49658. * roughness value in the G channel to keep better precision.
  49659. */
  49660. metallicRoughnessTexture: BaseTexture;
  49661. /**
  49662. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49663. *
  49664. * @param name The material name
  49665. * @param scene The scene the material will be use in.
  49666. */
  49667. constructor(name: string, scene: Scene);
  49668. /**
  49669. * Return the currrent class name of the material.
  49670. */
  49671. getClassName(): string;
  49672. /**
  49673. * Makes a duplicate of the current material.
  49674. * @param name - name to use for the new material.
  49675. */
  49676. clone(name: string): PBRMetallicRoughnessMaterial;
  49677. /**
  49678. * Serialize the material to a parsable JSON object.
  49679. */
  49680. serialize(): any;
  49681. /**
  49682. * Parses a JSON object correponding to the serialize function.
  49683. */
  49684. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49685. }
  49686. }
  49687. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49688. import { Scene } from "babylonjs/scene";
  49689. import { Color3 } from "babylonjs/Maths/math";
  49690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49691. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49692. /**
  49693. * The PBR material of BJS following the specular glossiness convention.
  49694. *
  49695. * This fits to the PBR convention in the GLTF definition:
  49696. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49697. */
  49698. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49699. /**
  49700. * Specifies the diffuse color of the material.
  49701. */
  49702. diffuseColor: Color3;
  49703. /**
  49704. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49705. * channel.
  49706. */
  49707. diffuseTexture: BaseTexture;
  49708. /**
  49709. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49710. */
  49711. specularColor: Color3;
  49712. /**
  49713. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49714. */
  49715. glossiness: number;
  49716. /**
  49717. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49718. */
  49719. specularGlossinessTexture: BaseTexture;
  49720. /**
  49721. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49722. *
  49723. * @param name The material name
  49724. * @param scene The scene the material will be use in.
  49725. */
  49726. constructor(name: string, scene: Scene);
  49727. /**
  49728. * Return the currrent class name of the material.
  49729. */
  49730. getClassName(): string;
  49731. /**
  49732. * Makes a duplicate of the current material.
  49733. * @param name - name to use for the new material.
  49734. */
  49735. clone(name: string): PBRSpecularGlossinessMaterial;
  49736. /**
  49737. * Serialize the material to a parsable JSON object.
  49738. */
  49739. serialize(): any;
  49740. /**
  49741. * Parses a JSON object correponding to the serialize function.
  49742. */
  49743. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49744. }
  49745. }
  49746. declare module "babylonjs/Materials/PBR/index" {
  49747. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49748. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49749. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49750. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49751. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49752. }
  49753. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49754. import { Nullable } from "babylonjs/types";
  49755. import { Scene } from "babylonjs/scene";
  49756. import { Matrix } from "babylonjs/Maths/math";
  49757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49758. /**
  49759. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49760. * It can help converting any input color in a desired output one. This can then be used to create effects
  49761. * from sepia, black and white to sixties or futuristic rendering...
  49762. *
  49763. * The only supported format is currently 3dl.
  49764. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49765. */
  49766. export class ColorGradingTexture extends BaseTexture {
  49767. /**
  49768. * The current texture matrix. (will always be identity in color grading texture)
  49769. */
  49770. private _textureMatrix;
  49771. /**
  49772. * The texture URL.
  49773. */
  49774. url: string;
  49775. /**
  49776. * Empty line regex stored for GC.
  49777. */
  49778. private static _noneEmptyLineRegex;
  49779. private _engine;
  49780. /**
  49781. * Instantiates a ColorGradingTexture from the following parameters.
  49782. *
  49783. * @param url The location of the color gradind data (currently only supporting 3dl)
  49784. * @param scene The scene the texture will be used in
  49785. */
  49786. constructor(url: string, scene: Scene);
  49787. /**
  49788. * Returns the texture matrix used in most of the material.
  49789. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49790. */
  49791. getTextureMatrix(): Matrix;
  49792. /**
  49793. * Occurs when the file being loaded is a .3dl LUT file.
  49794. */
  49795. private load3dlTexture;
  49796. /**
  49797. * Starts the loading process of the texture.
  49798. */
  49799. private loadTexture;
  49800. /**
  49801. * Clones the color gradind texture.
  49802. */
  49803. clone(): ColorGradingTexture;
  49804. /**
  49805. * Called during delayed load for textures.
  49806. */
  49807. delayLoad(): void;
  49808. /**
  49809. * Parses a color grading texture serialized by Babylon.
  49810. * @param parsedTexture The texture information being parsedTexture
  49811. * @param scene The scene to load the texture in
  49812. * @param rootUrl The root url of the data assets to load
  49813. * @return A color gradind texture
  49814. */
  49815. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49816. /**
  49817. * Serializes the LUT texture to json format.
  49818. */
  49819. serialize(): any;
  49820. }
  49821. }
  49822. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49824. import { Scene } from "babylonjs/scene";
  49825. import { Nullable } from "babylonjs/types";
  49826. /**
  49827. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49828. */
  49829. export class EquiRectangularCubeTexture extends BaseTexture {
  49830. /** The six faces of the cube. */
  49831. private static _FacesMapping;
  49832. private _noMipmap;
  49833. private _onLoad;
  49834. private _onError;
  49835. /** The size of the cubemap. */
  49836. private _size;
  49837. /** The buffer of the image. */
  49838. private _buffer;
  49839. /** The width of the input image. */
  49840. private _width;
  49841. /** The height of the input image. */
  49842. private _height;
  49843. /** The URL to the image. */
  49844. url: string;
  49845. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49846. coordinatesMode: number;
  49847. /**
  49848. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49849. * @param url The location of the image
  49850. * @param scene The scene the texture will be used in
  49851. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49852. * @param noMipmap Forces to not generate the mipmap if true
  49853. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49854. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49855. * @param onLoad — defines a callback called when texture is loaded
  49856. * @param onError — defines a callback called if there is an error
  49857. */
  49858. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49859. /**
  49860. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49861. */
  49862. private loadImage;
  49863. /**
  49864. * Convert the image buffer into a cubemap and create a CubeTexture.
  49865. */
  49866. private loadTexture;
  49867. /**
  49868. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49869. * @param buffer The ArrayBuffer that should be converted.
  49870. * @returns The buffer as Float32Array.
  49871. */
  49872. private getFloat32ArrayFromArrayBuffer;
  49873. /**
  49874. * Get the current class name of the texture useful for serialization or dynamic coding.
  49875. * @returns "EquiRectangularCubeTexture"
  49876. */
  49877. getClassName(): string;
  49878. /**
  49879. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49880. * @returns A clone of the current EquiRectangularCubeTexture.
  49881. */
  49882. clone(): EquiRectangularCubeTexture;
  49883. }
  49884. }
  49885. declare module "babylonjs/Misc/tga" {
  49886. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49887. /**
  49888. * Based on jsTGALoader - Javascript loader for TGA file
  49889. * By Vincent Thibault
  49890. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49891. */
  49892. export class TGATools {
  49893. private static _TYPE_INDEXED;
  49894. private static _TYPE_RGB;
  49895. private static _TYPE_GREY;
  49896. private static _TYPE_RLE_INDEXED;
  49897. private static _TYPE_RLE_RGB;
  49898. private static _TYPE_RLE_GREY;
  49899. private static _ORIGIN_MASK;
  49900. private static _ORIGIN_SHIFT;
  49901. private static _ORIGIN_BL;
  49902. private static _ORIGIN_BR;
  49903. private static _ORIGIN_UL;
  49904. private static _ORIGIN_UR;
  49905. /**
  49906. * Gets the header of a TGA file
  49907. * @param data defines the TGA data
  49908. * @returns the header
  49909. */
  49910. static GetTGAHeader(data: Uint8Array): any;
  49911. /**
  49912. * Uploads TGA content to a Babylon Texture
  49913. * @hidden
  49914. */
  49915. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49916. /** @hidden */
  49917. 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;
  49918. /** @hidden */
  49919. 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;
  49920. /** @hidden */
  49921. 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;
  49922. /** @hidden */
  49923. 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;
  49924. /** @hidden */
  49925. 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;
  49926. /** @hidden */
  49927. 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;
  49928. }
  49929. }
  49930. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49931. import { Nullable } from "babylonjs/types";
  49932. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49933. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49934. /**
  49935. * Implementation of the TGA Texture Loader.
  49936. * @hidden
  49937. */
  49938. export class _TGATextureLoader implements IInternalTextureLoader {
  49939. /**
  49940. * Defines wether the loader supports cascade loading the different faces.
  49941. */
  49942. readonly supportCascades: boolean;
  49943. /**
  49944. * This returns if the loader support the current file information.
  49945. * @param extension defines the file extension of the file being loaded
  49946. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49947. * @param fallback defines the fallback internal texture if any
  49948. * @param isBase64 defines whether the texture is encoded as a base64
  49949. * @param isBuffer defines whether the texture data are stored as a buffer
  49950. * @returns true if the loader can load the specified file
  49951. */
  49952. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49953. /**
  49954. * Transform the url before loading if required.
  49955. * @param rootUrl the url of the texture
  49956. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49957. * @returns the transformed texture
  49958. */
  49959. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49960. /**
  49961. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49962. * @param rootUrl the url of the texture
  49963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49964. * @returns the fallback texture
  49965. */
  49966. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49967. /**
  49968. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49969. * @param data contains the texture data
  49970. * @param texture defines the BabylonJS internal texture
  49971. * @param createPolynomials will be true if polynomials have been requested
  49972. * @param onLoad defines the callback to trigger once the texture is ready
  49973. * @param onError defines the callback to trigger in case of error
  49974. */
  49975. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49976. /**
  49977. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49978. * @param data contains the texture data
  49979. * @param texture defines the BabylonJS internal texture
  49980. * @param callback defines the method to call once ready to upload
  49981. */
  49982. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49983. }
  49984. }
  49985. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49986. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49987. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49988. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49989. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49990. }
  49991. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49992. import { Scene } from "babylonjs/scene";
  49993. import { Texture } from "babylonjs/Materials/Textures/texture";
  49994. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49995. /**
  49996. * 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.
  49997. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49998. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49999. */
  50000. export class CustomProceduralTexture extends ProceduralTexture {
  50001. private _animate;
  50002. private _time;
  50003. private _config;
  50004. private _texturePath;
  50005. /**
  50006. * Instantiates a new Custom Procedural Texture.
  50007. * 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.
  50008. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50009. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50010. * @param name Define the name of the texture
  50011. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50012. * @param size Define the size of the texture to create
  50013. * @param scene Define the scene the texture belongs to
  50014. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50015. * @param generateMipMaps Define if the texture should creates mip maps or not
  50016. */
  50017. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50018. private _loadJson;
  50019. /**
  50020. * Is the texture ready to be used ? (rendered at least once)
  50021. * @returns true if ready, otherwise, false.
  50022. */
  50023. isReady(): boolean;
  50024. /**
  50025. * Render the texture to its associated render target.
  50026. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50027. */
  50028. render(useCameraPostProcess?: boolean): void;
  50029. /**
  50030. * Update the list of dependant textures samplers in the shader.
  50031. */
  50032. updateTextures(): void;
  50033. /**
  50034. * Update the uniform values of the procedural texture in the shader.
  50035. */
  50036. updateShaderUniforms(): void;
  50037. /**
  50038. * Define if the texture animates or not.
  50039. */
  50040. animate: boolean;
  50041. }
  50042. }
  50043. declare module "babylonjs/Shaders/noise.fragment" {
  50044. /** @hidden */
  50045. export var noisePixelShader: {
  50046. name: string;
  50047. shader: string;
  50048. };
  50049. }
  50050. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  50051. import { Nullable } from "babylonjs/types";
  50052. import { Scene } from "babylonjs/scene";
  50053. import { Texture } from "babylonjs/Materials/Textures/texture";
  50054. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50055. import "babylonjs/Shaders/noise.fragment";
  50056. /**
  50057. * Class used to generate noise procedural textures
  50058. */
  50059. export class NoiseProceduralTexture extends ProceduralTexture {
  50060. private _time;
  50061. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50062. brightness: number;
  50063. /** Defines the number of octaves to process */
  50064. octaves: number;
  50065. /** Defines the level of persistence (0.8 by default) */
  50066. persistence: number;
  50067. /** Gets or sets animation speed factor (default is 1) */
  50068. animationSpeedFactor: number;
  50069. /**
  50070. * Creates a new NoiseProceduralTexture
  50071. * @param name defines the name fo the texture
  50072. * @param size defines the size of the texture (default is 256)
  50073. * @param scene defines the hosting scene
  50074. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50075. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50076. */
  50077. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50078. private _updateShaderUniforms;
  50079. protected _getDefines(): string;
  50080. /** Generate the current state of the procedural texture */
  50081. render(useCameraPostProcess?: boolean): void;
  50082. /**
  50083. * Serializes this noise procedural texture
  50084. * @returns a serialized noise procedural texture object
  50085. */
  50086. serialize(): any;
  50087. /**
  50088. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50089. * @param parsedTexture defines parsed texture data
  50090. * @param scene defines the current scene
  50091. * @param rootUrl defines the root URL containing noise procedural texture information
  50092. * @returns a parsed NoiseProceduralTexture
  50093. */
  50094. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50095. }
  50096. }
  50097. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  50098. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  50099. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  50100. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50101. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  50102. }
  50103. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  50104. import { Nullable } from "babylonjs/types";
  50105. import { Scene } from "babylonjs/scene";
  50106. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50108. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  50109. /**
  50110. * Raw cube texture where the raw buffers are passed in
  50111. */
  50112. export class RawCubeTexture extends CubeTexture {
  50113. /**
  50114. * Creates a cube texture where the raw buffers are passed in.
  50115. * @param scene defines the scene the texture is attached to
  50116. * @param data defines the array of data to use to create each face
  50117. * @param size defines the size of the textures
  50118. * @param format defines the format of the data
  50119. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50120. * @param generateMipMaps defines if the engine should generate the mip levels
  50121. * @param invertY defines if data must be stored with Y axis inverted
  50122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50123. * @param compression defines the compression used (null by default)
  50124. */
  50125. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50126. /**
  50127. * Updates the raw cube texture.
  50128. * @param data defines the data to store
  50129. * @param format defines the data format
  50130. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50131. * @param invertY defines if data must be stored with Y axis inverted
  50132. * @param compression defines the compression used (null by default)
  50133. * @param level defines which level of the texture to update
  50134. */
  50135. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50136. /**
  50137. * Updates a raw cube texture with RGBD encoded data.
  50138. * @param data defines the array of data [mipmap][face] to use to create each face
  50139. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50140. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50141. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50142. * @returns a promsie that resolves when the operation is complete
  50143. */
  50144. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50145. /**
  50146. * Clones the raw cube texture.
  50147. * @return a new cube texture
  50148. */
  50149. clone(): CubeTexture;
  50150. /** @hidden */
  50151. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50152. }
  50153. }
  50154. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  50155. import { Scene } from "babylonjs/scene";
  50156. import { Texture } from "babylonjs/Materials/Textures/texture";
  50157. /**
  50158. * Class used to store 3D textures containing user data
  50159. */
  50160. export class RawTexture3D extends Texture {
  50161. /** Gets or sets the texture format to use */
  50162. format: number;
  50163. private _engine;
  50164. /**
  50165. * Create a new RawTexture3D
  50166. * @param data defines the data of the texture
  50167. * @param width defines the width of the texture
  50168. * @param height defines the height of the texture
  50169. * @param depth defines the depth of the texture
  50170. * @param format defines the texture format to use
  50171. * @param scene defines the hosting scene
  50172. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50173. * @param invertY defines if texture must be stored with Y axis inverted
  50174. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50175. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50176. */
  50177. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50178. /** Gets or sets the texture format to use */
  50179. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50180. /**
  50181. * Update the texture with new data
  50182. * @param data defines the data to store in the texture
  50183. */
  50184. update(data: ArrayBufferView): void;
  50185. }
  50186. }
  50187. declare module "babylonjs/Materials/Textures/refractionTexture" {
  50188. import { Scene } from "babylonjs/scene";
  50189. import { Plane } from "babylonjs/Maths/math";
  50190. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50191. /**
  50192. * Creates a refraction texture used by refraction channel of the standard material.
  50193. * It is like a mirror but to see through a material.
  50194. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50195. */
  50196. export class RefractionTexture extends RenderTargetTexture {
  50197. /**
  50198. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50199. * 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.
  50200. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50201. */
  50202. refractionPlane: Plane;
  50203. /**
  50204. * Define how deep under the surface we should see.
  50205. */
  50206. depth: number;
  50207. /**
  50208. * Creates a refraction texture used by refraction channel of the standard material.
  50209. * It is like a mirror but to see through a material.
  50210. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50211. * @param name Define the texture name
  50212. * @param size Define the size of the underlying texture
  50213. * @param scene Define the scene the refraction belongs to
  50214. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50215. */
  50216. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50217. /**
  50218. * Clone the refraction texture.
  50219. * @returns the cloned texture
  50220. */
  50221. clone(): RefractionTexture;
  50222. /**
  50223. * Serialize the texture to a JSON representation you could use in Parse later on
  50224. * @returns the serialized JSON representation
  50225. */
  50226. serialize(): any;
  50227. }
  50228. }
  50229. declare module "babylonjs/Materials/Textures/index" {
  50230. export * from "babylonjs/Materials/Textures/baseTexture";
  50231. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  50232. export * from "babylonjs/Materials/Textures/cubeTexture";
  50233. export * from "babylonjs/Materials/Textures/dynamicTexture";
  50234. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  50235. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  50236. export * from "babylonjs/Materials/Textures/internalTexture";
  50237. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  50238. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  50239. export * from "babylonjs/Materials/Textures/Loaders/index";
  50240. export * from "babylonjs/Materials/Textures/mirrorTexture";
  50241. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  50242. export * from "babylonjs/Materials/Textures/Procedurals/index";
  50243. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  50244. export * from "babylonjs/Materials/Textures/rawTexture";
  50245. export * from "babylonjs/Materials/Textures/rawTexture3D";
  50246. export * from "babylonjs/Materials/Textures/refractionTexture";
  50247. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  50248. export * from "babylonjs/Materials/Textures/texture";
  50249. export * from "babylonjs/Materials/Textures/videoTexture";
  50250. }
  50251. declare module "babylonjs/Materials/index" {
  50252. export * from "babylonjs/Materials/Background/index";
  50253. export * from "babylonjs/Materials/colorCurves";
  50254. export * from "babylonjs/Materials/effect";
  50255. export * from "babylonjs/Materials/fresnelParameters";
  50256. export * from "babylonjs/Materials/imageProcessingConfiguration";
  50257. export * from "babylonjs/Materials/material";
  50258. export * from "babylonjs/Materials/materialDefines";
  50259. export * from "babylonjs/Materials/materialHelper";
  50260. export * from "babylonjs/Materials/multiMaterial";
  50261. export * from "babylonjs/Materials/PBR/index";
  50262. export * from "babylonjs/Materials/pushMaterial";
  50263. export * from "babylonjs/Materials/shaderMaterial";
  50264. export * from "babylonjs/Materials/standardMaterial";
  50265. export * from "babylonjs/Materials/Textures/index";
  50266. export * from "babylonjs/Materials/uniformBuffer";
  50267. export * from "babylonjs/Materials/materialFlags";
  50268. }
  50269. declare module "babylonjs/Maths/index" {
  50270. export * from "babylonjs/Maths/math.scalar";
  50271. export * from "babylonjs/Maths/math";
  50272. export * from "babylonjs/Maths/sphericalPolynomial";
  50273. }
  50274. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  50275. import { IDisposable } from "babylonjs/scene";
  50276. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50277. /**
  50278. * Configuration for Draco compression
  50279. */
  50280. export interface IDracoCompressionConfiguration {
  50281. /**
  50282. * Configuration for the decoder.
  50283. */
  50284. decoder?: {
  50285. /**
  50286. * The url to the WebAssembly module.
  50287. */
  50288. wasmUrl?: string;
  50289. /**
  50290. * The url to the WebAssembly binary.
  50291. */
  50292. wasmBinaryUrl?: string;
  50293. /**
  50294. * The url to the fallback JavaScript module.
  50295. */
  50296. fallbackUrl?: string;
  50297. };
  50298. }
  50299. /**
  50300. * Draco compression (https://google.github.io/draco/)
  50301. *
  50302. * This class wraps the Draco module.
  50303. *
  50304. * **Encoder**
  50305. *
  50306. * The encoder is not currently implemented.
  50307. *
  50308. * **Decoder**
  50309. *
  50310. * 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.
  50311. *
  50312. * To update the configuration, use the following code:
  50313. * ```javascript
  50314. * DracoCompression.Configuration = {
  50315. * decoder: {
  50316. * wasmUrl: "<url to the WebAssembly library>",
  50317. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50318. * fallbackUrl: "<url to the fallback JavaScript library>",
  50319. * }
  50320. * };
  50321. * ```
  50322. *
  50323. * 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.
  50324. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50325. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  50326. *
  50327. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  50328. * ```javascript
  50329. * var dracoCompression = new DracoCompression();
  50330. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  50331. * [VertexBuffer.PositionKind]: 0
  50332. * });
  50333. * ```
  50334. *
  50335. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50336. */
  50337. export class DracoCompression implements IDisposable {
  50338. private static _DecoderModulePromise;
  50339. /**
  50340. * The configuration. Defaults to the following urls:
  50341. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50342. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50343. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50344. */
  50345. static Configuration: IDracoCompressionConfiguration;
  50346. /**
  50347. * Returns true if the decoder is available.
  50348. */
  50349. static readonly DecoderAvailable: boolean;
  50350. /**
  50351. * Constructor
  50352. */
  50353. constructor();
  50354. /**
  50355. * Stop all async operations and release resources.
  50356. */
  50357. dispose(): void;
  50358. /**
  50359. * Decode Draco compressed mesh data to vertex data.
  50360. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50361. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50362. * @returns A promise that resolves with the decoded vertex data
  50363. */
  50364. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  50365. [kind: string]: number;
  50366. }): Promise<VertexData>;
  50367. private static _GetDecoderModule;
  50368. private static _LoadScriptAsync;
  50369. private static _LoadFileAsync;
  50370. }
  50371. }
  50372. declare module "babylonjs/Meshes/Compression/index" {
  50373. export * from "babylonjs/Meshes/Compression/dracoCompression";
  50374. }
  50375. declare module "babylonjs/Meshes/csg" {
  50376. import { Nullable } from "babylonjs/types";
  50377. import { Scene } from "babylonjs/scene";
  50378. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  50379. import { Mesh } from "babylonjs/Meshes/mesh";
  50380. import { Material } from "babylonjs/Materials/material";
  50381. /**
  50382. * Class for building Constructive Solid Geometry
  50383. */
  50384. export class CSG {
  50385. private polygons;
  50386. /**
  50387. * The world matrix
  50388. */
  50389. matrix: Matrix;
  50390. /**
  50391. * Stores the position
  50392. */
  50393. position: Vector3;
  50394. /**
  50395. * Stores the rotation
  50396. */
  50397. rotation: Vector3;
  50398. /**
  50399. * Stores the rotation quaternion
  50400. */
  50401. rotationQuaternion: Nullable<Quaternion>;
  50402. /**
  50403. * Stores the scaling vector
  50404. */
  50405. scaling: Vector3;
  50406. /**
  50407. * Convert the Mesh to CSG
  50408. * @param mesh The Mesh to convert to CSG
  50409. * @returns A new CSG from the Mesh
  50410. */
  50411. static FromMesh(mesh: Mesh): CSG;
  50412. /**
  50413. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50414. * @param polygons Polygons used to construct a CSG solid
  50415. */
  50416. private static FromPolygons;
  50417. /**
  50418. * Clones, or makes a deep copy, of the CSG
  50419. * @returns A new CSG
  50420. */
  50421. clone(): CSG;
  50422. /**
  50423. * Unions this CSG with another CSG
  50424. * @param csg The CSG to union against this CSG
  50425. * @returns The unioned CSG
  50426. */
  50427. union(csg: CSG): CSG;
  50428. /**
  50429. * Unions this CSG with another CSG in place
  50430. * @param csg The CSG to union against this CSG
  50431. */
  50432. unionInPlace(csg: CSG): void;
  50433. /**
  50434. * Subtracts this CSG with another CSG
  50435. * @param csg The CSG to subtract against this CSG
  50436. * @returns A new CSG
  50437. */
  50438. subtract(csg: CSG): CSG;
  50439. /**
  50440. * Subtracts this CSG with another CSG in place
  50441. * @param csg The CSG to subtact against this CSG
  50442. */
  50443. subtractInPlace(csg: CSG): void;
  50444. /**
  50445. * Intersect this CSG with another CSG
  50446. * @param csg The CSG to intersect against this CSG
  50447. * @returns A new CSG
  50448. */
  50449. intersect(csg: CSG): CSG;
  50450. /**
  50451. * Intersects this CSG with another CSG in place
  50452. * @param csg The CSG to intersect against this CSG
  50453. */
  50454. intersectInPlace(csg: CSG): void;
  50455. /**
  50456. * Return a new CSG solid with solid and empty space switched. This solid is
  50457. * not modified.
  50458. * @returns A new CSG solid with solid and empty space switched
  50459. */
  50460. inverse(): CSG;
  50461. /**
  50462. * Inverses the CSG in place
  50463. */
  50464. inverseInPlace(): void;
  50465. /**
  50466. * This is used to keep meshes transformations so they can be restored
  50467. * when we build back a Babylon Mesh
  50468. * NB : All CSG operations are performed in world coordinates
  50469. * @param csg The CSG to copy the transform attributes from
  50470. * @returns This CSG
  50471. */
  50472. copyTransformAttributes(csg: CSG): CSG;
  50473. /**
  50474. * Build Raw mesh from CSG
  50475. * Coordinates here are in world space
  50476. * @param name The name of the mesh geometry
  50477. * @param scene The Scene
  50478. * @param keepSubMeshes Specifies if the submeshes should be kept
  50479. * @returns A new Mesh
  50480. */
  50481. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50482. /**
  50483. * Build Mesh from CSG taking material and transforms into account
  50484. * @param name The name of the Mesh
  50485. * @param material The material of the Mesh
  50486. * @param scene The Scene
  50487. * @param keepSubMeshes Specifies if submeshes should be kept
  50488. * @returns The new Mesh
  50489. */
  50490. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50491. }
  50492. }
  50493. declare module "babylonjs/Meshes/trailMesh" {
  50494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50495. import { Mesh } from "babylonjs/Meshes/mesh";
  50496. import { Scene } from "babylonjs/scene";
  50497. /**
  50498. * Class used to create a trail following a mesh
  50499. */
  50500. export class TrailMesh extends Mesh {
  50501. private _generator;
  50502. private _autoStart;
  50503. private _running;
  50504. private _diameter;
  50505. private _length;
  50506. private _sectionPolygonPointsCount;
  50507. private _sectionVectors;
  50508. private _sectionNormalVectors;
  50509. private _beforeRenderObserver;
  50510. /**
  50511. * @constructor
  50512. * @param name The value used by scene.getMeshByName() to do a lookup.
  50513. * @param generator The mesh to generate a trail.
  50514. * @param scene The scene to add this mesh to.
  50515. * @param diameter Diameter of trailing mesh. Default is 1.
  50516. * @param length Length of trailing mesh. Default is 60.
  50517. * @param autoStart Automatically start trailing mesh. Default true.
  50518. */
  50519. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50520. /**
  50521. * "TrailMesh"
  50522. * @returns "TrailMesh"
  50523. */
  50524. getClassName(): string;
  50525. private _createMesh;
  50526. /**
  50527. * Start trailing mesh.
  50528. */
  50529. start(): void;
  50530. /**
  50531. * Stop trailing mesh.
  50532. */
  50533. stop(): void;
  50534. /**
  50535. * Update trailing mesh geometry.
  50536. */
  50537. update(): void;
  50538. /**
  50539. * Returns a new TrailMesh object.
  50540. * @param name is a string, the name given to the new mesh
  50541. * @param newGenerator use new generator object for cloned trail mesh
  50542. * @returns a new mesh
  50543. */
  50544. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50545. /**
  50546. * Serializes this trail mesh
  50547. * @param serializationObject object to write serialization to
  50548. */
  50549. serialize(serializationObject: any): void;
  50550. /**
  50551. * Parses a serialized trail mesh
  50552. * @param parsedMesh the serialized mesh
  50553. * @param scene the scene to create the trail mesh in
  50554. * @returns the created trail mesh
  50555. */
  50556. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50557. }
  50558. }
  50559. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50560. import { Nullable } from "babylonjs/types";
  50561. import { Scene } from "babylonjs/scene";
  50562. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50563. import { Mesh } from "babylonjs/Meshes/mesh";
  50564. /**
  50565. * Class containing static functions to help procedurally build meshes
  50566. */
  50567. export class RibbonBuilder {
  50568. /**
  50569. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50570. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50571. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50572. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50573. * * 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
  50574. * * 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
  50575. * * 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
  50576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50578. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50579. * * 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
  50580. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50581. * * 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
  50582. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50584. * @param name defines the name of the mesh
  50585. * @param options defines the options used to create the mesh
  50586. * @param scene defines the hosting scene
  50587. * @returns the ribbon mesh
  50588. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50589. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50590. */
  50591. static CreateRibbon(name: string, options: {
  50592. pathArray: Vector3[][];
  50593. closeArray?: boolean;
  50594. closePath?: boolean;
  50595. offset?: number;
  50596. updatable?: boolean;
  50597. sideOrientation?: number;
  50598. frontUVs?: Vector4;
  50599. backUVs?: Vector4;
  50600. instance?: Mesh;
  50601. invertUV?: boolean;
  50602. uvs?: Vector2[];
  50603. colors?: Color4[];
  50604. }, scene?: Nullable<Scene>): Mesh;
  50605. }
  50606. }
  50607. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50608. import { Vector4 } from "babylonjs/Maths/math";
  50609. import { Mesh } from "babylonjs/Meshes/mesh";
  50610. /**
  50611. * Class containing static functions to help procedurally build meshes
  50612. */
  50613. export class TorusKnotBuilder {
  50614. /**
  50615. * Creates a torus knot mesh
  50616. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50617. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50618. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50619. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50623. * @param name defines the name of the mesh
  50624. * @param options defines the options used to create the mesh
  50625. * @param scene defines the hosting scene
  50626. * @returns the torus knot mesh
  50627. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50628. */
  50629. static CreateTorusKnot(name: string, options: {
  50630. radius?: number;
  50631. tube?: number;
  50632. radialSegments?: number;
  50633. tubularSegments?: number;
  50634. p?: number;
  50635. q?: number;
  50636. updatable?: boolean;
  50637. sideOrientation?: number;
  50638. frontUVs?: Vector4;
  50639. backUVs?: Vector4;
  50640. }, scene: any): Mesh;
  50641. }
  50642. }
  50643. declare module "babylonjs/Meshes/polygonMesh" {
  50644. import { Scene } from "babylonjs/scene";
  50645. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50646. import { Mesh } from "babylonjs/Meshes/mesh";
  50647. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50648. /**
  50649. * Polygon
  50650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50651. */
  50652. export class Polygon {
  50653. /**
  50654. * Creates a rectangle
  50655. * @param xmin bottom X coord
  50656. * @param ymin bottom Y coord
  50657. * @param xmax top X coord
  50658. * @param ymax top Y coord
  50659. * @returns points that make the resulting rectation
  50660. */
  50661. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50662. /**
  50663. * Creates a circle
  50664. * @param radius radius of circle
  50665. * @param cx scale in x
  50666. * @param cy scale in y
  50667. * @param numberOfSides number of sides that make up the circle
  50668. * @returns points that make the resulting circle
  50669. */
  50670. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50671. /**
  50672. * Creates a polygon from input string
  50673. * @param input Input polygon data
  50674. * @returns the parsed points
  50675. */
  50676. static Parse(input: string): Vector2[];
  50677. /**
  50678. * Starts building a polygon from x and y coordinates
  50679. * @param x x coordinate
  50680. * @param y y coordinate
  50681. * @returns the started path2
  50682. */
  50683. static StartingAt(x: number, y: number): Path2;
  50684. }
  50685. /**
  50686. * Builds a polygon
  50687. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50688. */
  50689. export class PolygonMeshBuilder {
  50690. private _points;
  50691. private _outlinepoints;
  50692. private _holes;
  50693. private _name;
  50694. private _scene;
  50695. private _epoints;
  50696. private _eholes;
  50697. private _addToepoint;
  50698. /**
  50699. * Babylon reference to the earcut plugin.
  50700. */
  50701. bjsEarcut: any;
  50702. /**
  50703. * Creates a PolygonMeshBuilder
  50704. * @param name name of the builder
  50705. * @param contours Path of the polygon
  50706. * @param scene scene to add to when creating the mesh
  50707. * @param earcutInjection can be used to inject your own earcut reference
  50708. */
  50709. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50710. /**
  50711. * Adds a whole within the polygon
  50712. * @param hole Array of points defining the hole
  50713. * @returns this
  50714. */
  50715. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50716. /**
  50717. * Creates the polygon
  50718. * @param updatable If the mesh should be updatable
  50719. * @param depth The depth of the mesh created
  50720. * @returns the created mesh
  50721. */
  50722. build(updatable?: boolean, depth?: number): Mesh;
  50723. /**
  50724. * Creates the polygon
  50725. * @param depth The depth of the mesh created
  50726. * @returns the created VertexData
  50727. */
  50728. buildVertexData(depth?: number): VertexData;
  50729. /**
  50730. * Adds a side to the polygon
  50731. * @param positions points that make the polygon
  50732. * @param normals normals of the polygon
  50733. * @param uvs uvs of the polygon
  50734. * @param indices indices of the polygon
  50735. * @param bounds bounds of the polygon
  50736. * @param points points of the polygon
  50737. * @param depth depth of the polygon
  50738. * @param flip flip of the polygon
  50739. */
  50740. private addSide;
  50741. }
  50742. }
  50743. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50744. import { Scene } from "babylonjs/scene";
  50745. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50746. import { Mesh } from "babylonjs/Meshes/mesh";
  50747. /**
  50748. * Class containing static functions to help procedurally build meshes
  50749. */
  50750. export class PolygonBuilder {
  50751. /**
  50752. * Creates a polygon mesh
  50753. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50754. * * 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
  50755. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50758. * * Remember you can only change the shape positions, not their number when updating a polygon
  50759. * @param name defines the name of the mesh
  50760. * @param options defines the options used to create the mesh
  50761. * @param scene defines the hosting scene
  50762. * @param earcutInjection can be used to inject your own earcut reference
  50763. * @returns the polygon mesh
  50764. */
  50765. static CreatePolygon(name: string, options: {
  50766. shape: Vector3[];
  50767. holes?: Vector3[][];
  50768. depth?: number;
  50769. faceUV?: Vector4[];
  50770. faceColors?: Color4[];
  50771. updatable?: boolean;
  50772. sideOrientation?: number;
  50773. frontUVs?: Vector4;
  50774. backUVs?: Vector4;
  50775. }, scene: Scene, earcutInjection?: any): Mesh;
  50776. /**
  50777. * Creates an extruded polygon mesh, with depth in the Y direction.
  50778. * * 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)
  50779. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50780. * @param name defines the name of the mesh
  50781. * @param options defines the options used to create the mesh
  50782. * @param scene defines the hosting scene
  50783. * @param earcutInjection can be used to inject your own earcut reference
  50784. * @returns the polygon mesh
  50785. */
  50786. static ExtrudePolygon(name: string, options: {
  50787. shape: Vector3[];
  50788. holes?: Vector3[][];
  50789. depth?: number;
  50790. faceUV?: Vector4[];
  50791. faceColors?: Color4[];
  50792. updatable?: boolean;
  50793. sideOrientation?: number;
  50794. frontUVs?: Vector4;
  50795. backUVs?: Vector4;
  50796. }, scene: Scene, earcutInjection?: any): Mesh;
  50797. }
  50798. }
  50799. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50800. import { Nullable } from "babylonjs/types";
  50801. import { Scene } from "babylonjs/scene";
  50802. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50803. import { Mesh } from "babylonjs/Meshes/mesh";
  50804. /**
  50805. * Class containing static functions to help procedurally build meshes
  50806. */
  50807. export class ShapeBuilder {
  50808. /**
  50809. * 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.
  50810. * * 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.
  50811. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50812. * * 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.
  50813. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50814. * * 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
  50815. * * 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
  50816. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50821. * @param name defines the name of the mesh
  50822. * @param options defines the options used to create the mesh
  50823. * @param scene defines the hosting scene
  50824. * @returns the extruded shape mesh
  50825. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50827. */
  50828. static ExtrudeShape(name: string, options: {
  50829. shape: Vector3[];
  50830. path: Vector3[];
  50831. scale?: number;
  50832. rotation?: number;
  50833. cap?: number;
  50834. updatable?: boolean;
  50835. sideOrientation?: number;
  50836. frontUVs?: Vector4;
  50837. backUVs?: Vector4;
  50838. instance?: Mesh;
  50839. invertUV?: boolean;
  50840. }, scene?: Nullable<Scene>): Mesh;
  50841. /**
  50842. * Creates an custom extruded shape mesh.
  50843. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50844. * * 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.
  50845. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50846. * * 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
  50847. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50848. * * 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
  50849. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50850. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50851. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50852. * * 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
  50853. * * 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
  50854. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50859. * @param name defines the name of the mesh
  50860. * @param options defines the options used to create the mesh
  50861. * @param scene defines the hosting scene
  50862. * @returns the custom extruded shape mesh
  50863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50866. */
  50867. static ExtrudeShapeCustom(name: string, options: {
  50868. shape: Vector3[];
  50869. path: Vector3[];
  50870. scaleFunction?: any;
  50871. rotationFunction?: any;
  50872. ribbonCloseArray?: boolean;
  50873. ribbonClosePath?: boolean;
  50874. cap?: number;
  50875. updatable?: boolean;
  50876. sideOrientation?: number;
  50877. frontUVs?: Vector4;
  50878. backUVs?: Vector4;
  50879. instance?: Mesh;
  50880. invertUV?: boolean;
  50881. }, scene: Scene): Mesh;
  50882. private static _ExtrudeShapeGeneric;
  50883. }
  50884. }
  50885. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50886. import { Scene } from "babylonjs/scene";
  50887. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50888. import { Mesh } from "babylonjs/Meshes/mesh";
  50889. /**
  50890. * Class containing static functions to help procedurally build meshes
  50891. */
  50892. export class LatheBuilder {
  50893. /**
  50894. * Creates lathe mesh.
  50895. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50896. * * 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
  50897. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50898. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50899. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50900. * * 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
  50901. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50902. * * 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
  50903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50905. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50907. * @param name defines the name of the mesh
  50908. * @param options defines the options used to create the mesh
  50909. * @param scene defines the hosting scene
  50910. * @returns the lathe mesh
  50911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50912. */
  50913. static CreateLathe(name: string, options: {
  50914. shape: Vector3[];
  50915. radius?: number;
  50916. tessellation?: number;
  50917. clip?: number;
  50918. arc?: number;
  50919. closed?: boolean;
  50920. updatable?: boolean;
  50921. sideOrientation?: number;
  50922. frontUVs?: Vector4;
  50923. backUVs?: Vector4;
  50924. cap?: number;
  50925. invertUV?: boolean;
  50926. }, scene: Scene): Mesh;
  50927. }
  50928. }
  50929. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50930. import { Scene } from "babylonjs/scene";
  50931. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50932. import { Mesh } from "babylonjs/Meshes/mesh";
  50933. /**
  50934. * Class containing static functions to help procedurally build meshes
  50935. */
  50936. export class TubeBuilder {
  50937. /**
  50938. * Creates a tube mesh.
  50939. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50940. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50941. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50942. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50943. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50944. * * 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)
  50945. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50946. * * 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
  50947. * * 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
  50948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50950. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50952. * @param name defines the name of the mesh
  50953. * @param options defines the options used to create the mesh
  50954. * @param scene defines the hosting scene
  50955. * @returns the tube mesh
  50956. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50957. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50958. */
  50959. static CreateTube(name: string, options: {
  50960. path: Vector3[];
  50961. radius?: number;
  50962. tessellation?: number;
  50963. radiusFunction?: {
  50964. (i: number, distance: number): number;
  50965. };
  50966. cap?: number;
  50967. arc?: number;
  50968. updatable?: boolean;
  50969. sideOrientation?: number;
  50970. frontUVs?: Vector4;
  50971. backUVs?: Vector4;
  50972. instance?: Mesh;
  50973. invertUV?: boolean;
  50974. }, scene: Scene): Mesh;
  50975. }
  50976. }
  50977. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50978. import { Scene } from "babylonjs/scene";
  50979. import { Vector4 } from "babylonjs/Maths/math";
  50980. import { Mesh } from "babylonjs/Meshes/mesh";
  50981. /**
  50982. * Class containing static functions to help procedurally build meshes
  50983. */
  50984. export class IcoSphereBuilder {
  50985. /**
  50986. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50987. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50988. * * 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`)
  50989. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50990. * * 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
  50991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50994. * @param name defines the name of the mesh
  50995. * @param options defines the options used to create the mesh
  50996. * @param scene defines the hosting scene
  50997. * @returns the icosahedron mesh
  50998. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50999. */
  51000. static CreateIcoSphere(name: string, options: {
  51001. radius?: number;
  51002. radiusX?: number;
  51003. radiusY?: number;
  51004. radiusZ?: number;
  51005. flat?: boolean;
  51006. subdivisions?: number;
  51007. sideOrientation?: number;
  51008. frontUVs?: Vector4;
  51009. backUVs?: Vector4;
  51010. updatable?: boolean;
  51011. }, scene: Scene): Mesh;
  51012. }
  51013. }
  51014. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  51015. import { Vector3 } from "babylonjs/Maths/math";
  51016. import { Mesh } from "babylonjs/Meshes/mesh";
  51017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51018. /**
  51019. * Class containing static functions to help procedurally build meshes
  51020. */
  51021. export class DecalBuilder {
  51022. /**
  51023. * Creates a decal mesh.
  51024. * 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
  51025. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51026. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51027. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51028. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51029. * @param name defines the name of the mesh
  51030. * @param sourceMesh defines the mesh where the decal must be applied
  51031. * @param options defines the options used to create the mesh
  51032. * @param scene defines the hosting scene
  51033. * @returns the decal mesh
  51034. * @see https://doc.babylonjs.com/how_to/decals
  51035. */
  51036. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51037. position?: Vector3;
  51038. normal?: Vector3;
  51039. size?: Vector3;
  51040. angle?: number;
  51041. }): Mesh;
  51042. }
  51043. }
  51044. declare module "babylonjs/Meshes/meshBuilder" {
  51045. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  51046. import { Nullable } from "babylonjs/types";
  51047. import { Scene } from "babylonjs/scene";
  51048. import { Mesh } from "babylonjs/Meshes/mesh";
  51049. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51050. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51052. /**
  51053. * Class containing static functions to help procedurally build meshes
  51054. */
  51055. export class MeshBuilder {
  51056. /**
  51057. * Creates a box mesh
  51058. * * The parameter `size` sets the size (float) of each box side (default 1)
  51059. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51060. * * 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)
  51061. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51065. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51066. * @param name defines the name of the mesh
  51067. * @param options defines the options used to create the mesh
  51068. * @param scene defines the hosting scene
  51069. * @returns the box mesh
  51070. */
  51071. static CreateBox(name: string, options: {
  51072. size?: number;
  51073. width?: number;
  51074. height?: number;
  51075. depth?: number;
  51076. faceUV?: Vector4[];
  51077. faceColors?: Color4[];
  51078. sideOrientation?: number;
  51079. frontUVs?: Vector4;
  51080. backUVs?: Vector4;
  51081. updatable?: boolean;
  51082. }, scene?: Nullable<Scene>): Mesh;
  51083. /**
  51084. * Creates a sphere mesh
  51085. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51086. * * 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`)
  51087. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51088. * * 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
  51089. * * 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)
  51090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51093. * @param name defines the name of the mesh
  51094. * @param options defines the options used to create the mesh
  51095. * @param scene defines the hosting scene
  51096. * @returns the sphere mesh
  51097. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51098. */
  51099. static CreateSphere(name: string, options: {
  51100. segments?: number;
  51101. diameter?: number;
  51102. diameterX?: number;
  51103. diameterY?: number;
  51104. diameterZ?: number;
  51105. arc?: number;
  51106. slice?: number;
  51107. sideOrientation?: number;
  51108. frontUVs?: Vector4;
  51109. backUVs?: Vector4;
  51110. updatable?: boolean;
  51111. }, scene: any): Mesh;
  51112. /**
  51113. * Creates a plane polygonal mesh. By default, this is a disc
  51114. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  51115. * * 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
  51116. * * 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
  51117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51120. * @param name defines the name of the mesh
  51121. * @param options defines the options used to create the mesh
  51122. * @param scene defines the hosting scene
  51123. * @returns the plane polygonal mesh
  51124. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51125. */
  51126. static CreateDisc(name: string, options: {
  51127. radius?: number;
  51128. tessellation?: number;
  51129. arc?: number;
  51130. updatable?: boolean;
  51131. sideOrientation?: number;
  51132. frontUVs?: Vector4;
  51133. backUVs?: Vector4;
  51134. }, scene?: Nullable<Scene>): Mesh;
  51135. /**
  51136. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51137. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51138. * * 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`)
  51139. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51140. * * 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
  51141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51144. * @param name defines the name of the mesh
  51145. * @param options defines the options used to create the mesh
  51146. * @param scene defines the hosting scene
  51147. * @returns the icosahedron mesh
  51148. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51149. */
  51150. static CreateIcoSphere(name: string, options: {
  51151. radius?: number;
  51152. radiusX?: number;
  51153. radiusY?: number;
  51154. radiusZ?: number;
  51155. flat?: boolean;
  51156. subdivisions?: number;
  51157. sideOrientation?: number;
  51158. frontUVs?: Vector4;
  51159. backUVs?: Vector4;
  51160. updatable?: boolean;
  51161. }, scene: Scene): Mesh;
  51162. /**
  51163. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51164. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51165. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51166. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51167. * * 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
  51168. * * 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
  51169. * * 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
  51170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51173. * * 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
  51174. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51175. * * 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
  51176. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51178. * @param name defines the name of the mesh
  51179. * @param options defines the options used to create the mesh
  51180. * @param scene defines the hosting scene
  51181. * @returns the ribbon mesh
  51182. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51183. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51184. */
  51185. static CreateRibbon(name: string, options: {
  51186. pathArray: Vector3[][];
  51187. closeArray?: boolean;
  51188. closePath?: boolean;
  51189. offset?: number;
  51190. updatable?: boolean;
  51191. sideOrientation?: number;
  51192. frontUVs?: Vector4;
  51193. backUVs?: Vector4;
  51194. instance?: Mesh;
  51195. invertUV?: boolean;
  51196. uvs?: Vector2[];
  51197. colors?: Color4[];
  51198. }, scene?: Nullable<Scene>): Mesh;
  51199. /**
  51200. * Creates a cylinder or a cone mesh
  51201. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51202. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51203. * * 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.
  51204. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51205. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51206. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51207. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51208. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51209. * * 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).
  51210. * * 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
  51211. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51212. * * 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
  51213. * * 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.
  51214. * * If `enclose` is false, a ring surface is one element.
  51215. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51216. * * 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
  51217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51220. * @param name defines the name of the mesh
  51221. * @param options defines the options used to create the mesh
  51222. * @param scene defines the hosting scene
  51223. * @returns the cylinder mesh
  51224. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51225. */
  51226. static CreateCylinder(name: string, options: {
  51227. height?: number;
  51228. diameterTop?: number;
  51229. diameterBottom?: number;
  51230. diameter?: number;
  51231. tessellation?: number;
  51232. subdivisions?: number;
  51233. arc?: number;
  51234. faceColors?: Color4[];
  51235. faceUV?: Vector4[];
  51236. updatable?: boolean;
  51237. hasRings?: boolean;
  51238. enclose?: boolean;
  51239. sideOrientation?: number;
  51240. frontUVs?: Vector4;
  51241. backUVs?: Vector4;
  51242. }, scene: any): Mesh;
  51243. /**
  51244. * Creates a torus mesh
  51245. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51246. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51247. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51251. * @param name defines the name of the mesh
  51252. * @param options defines the options used to create the mesh
  51253. * @param scene defines the hosting scene
  51254. * @returns the torus mesh
  51255. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51256. */
  51257. static CreateTorus(name: string, options: {
  51258. diameter?: number;
  51259. thickness?: number;
  51260. tessellation?: number;
  51261. updatable?: boolean;
  51262. sideOrientation?: number;
  51263. frontUVs?: Vector4;
  51264. backUVs?: Vector4;
  51265. }, scene: any): Mesh;
  51266. /**
  51267. * Creates a torus knot mesh
  51268. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51269. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51270. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51271. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51275. * @param name defines the name of the mesh
  51276. * @param options defines the options used to create the mesh
  51277. * @param scene defines the hosting scene
  51278. * @returns the torus knot mesh
  51279. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51280. */
  51281. static CreateTorusKnot(name: string, options: {
  51282. radius?: number;
  51283. tube?: number;
  51284. radialSegments?: number;
  51285. tubularSegments?: number;
  51286. p?: number;
  51287. q?: number;
  51288. updatable?: boolean;
  51289. sideOrientation?: number;
  51290. frontUVs?: Vector4;
  51291. backUVs?: Vector4;
  51292. }, scene: any): Mesh;
  51293. /**
  51294. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51295. * * 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
  51296. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51297. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51298. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51299. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51300. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51301. * * 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
  51302. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51305. * @param name defines the name of the new line system
  51306. * @param options defines the options used to create the line system
  51307. * @param scene defines the hosting scene
  51308. * @returns a new line system mesh
  51309. */
  51310. static CreateLineSystem(name: string, options: {
  51311. lines: Vector3[][];
  51312. updatable?: boolean;
  51313. instance?: Nullable<LinesMesh>;
  51314. colors?: Nullable<Color4[][]>;
  51315. useVertexAlpha?: boolean;
  51316. }, scene: Nullable<Scene>): LinesMesh;
  51317. /**
  51318. * Creates a line mesh
  51319. * 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
  51320. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51321. * * The parameter `points` is an array successive Vector3
  51322. * * 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
  51323. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51324. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51325. * * When updating an instance, remember that only point positions can change, not the number of points
  51326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51328. * @param name defines the name of the new line system
  51329. * @param options defines the options used to create the line system
  51330. * @param scene defines the hosting scene
  51331. * @returns a new line mesh
  51332. */
  51333. static CreateLines(name: string, options: {
  51334. points: Vector3[];
  51335. updatable?: boolean;
  51336. instance?: Nullable<LinesMesh>;
  51337. colors?: Color4[];
  51338. useVertexAlpha?: boolean;
  51339. }, scene?: Nullable<Scene>): LinesMesh;
  51340. /**
  51341. * Creates a dashed line mesh
  51342. * * 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
  51343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51344. * * The parameter `points` is an array successive Vector3
  51345. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51346. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51347. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51348. * * 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
  51349. * * When updating an instance, remember that only point positions can change, not the number of points
  51350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51351. * @param name defines the name of the mesh
  51352. * @param options defines the options used to create the mesh
  51353. * @param scene defines the hosting scene
  51354. * @returns the dashed line mesh
  51355. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51356. */
  51357. static CreateDashedLines(name: string, options: {
  51358. points: Vector3[];
  51359. dashSize?: number;
  51360. gapSize?: number;
  51361. dashNb?: number;
  51362. updatable?: boolean;
  51363. instance?: LinesMesh;
  51364. }, scene?: Nullable<Scene>): LinesMesh;
  51365. /**
  51366. * 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.
  51367. * * 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.
  51368. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51369. * * 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.
  51370. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51371. * * 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
  51372. * * 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
  51373. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51378. * @param name defines the name of the mesh
  51379. * @param options defines the options used to create the mesh
  51380. * @param scene defines the hosting scene
  51381. * @returns the extruded shape mesh
  51382. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51384. */
  51385. static ExtrudeShape(name: string, options: {
  51386. shape: Vector3[];
  51387. path: Vector3[];
  51388. scale?: number;
  51389. rotation?: number;
  51390. cap?: number;
  51391. updatable?: boolean;
  51392. sideOrientation?: number;
  51393. frontUVs?: Vector4;
  51394. backUVs?: Vector4;
  51395. instance?: Mesh;
  51396. invertUV?: boolean;
  51397. }, scene?: Nullable<Scene>): Mesh;
  51398. /**
  51399. * Creates an custom extruded shape mesh.
  51400. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51401. * * 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.
  51402. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51403. * * 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
  51404. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51405. * * 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
  51406. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51407. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51408. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51409. * * 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
  51410. * * 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
  51411. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51416. * @param name defines the name of the mesh
  51417. * @param options defines the options used to create the mesh
  51418. * @param scene defines the hosting scene
  51419. * @returns the custom extruded shape mesh
  51420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51421. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51423. */
  51424. static ExtrudeShapeCustom(name: string, options: {
  51425. shape: Vector3[];
  51426. path: Vector3[];
  51427. scaleFunction?: any;
  51428. rotationFunction?: any;
  51429. ribbonCloseArray?: boolean;
  51430. ribbonClosePath?: boolean;
  51431. cap?: number;
  51432. updatable?: boolean;
  51433. sideOrientation?: number;
  51434. frontUVs?: Vector4;
  51435. backUVs?: Vector4;
  51436. instance?: Mesh;
  51437. invertUV?: boolean;
  51438. }, scene: Scene): Mesh;
  51439. /**
  51440. * Creates lathe mesh.
  51441. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51442. * * 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
  51443. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51444. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51445. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51446. * * 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
  51447. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51448. * * 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
  51449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51453. * @param name defines the name of the mesh
  51454. * @param options defines the options used to create the mesh
  51455. * @param scene defines the hosting scene
  51456. * @returns the lathe mesh
  51457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51458. */
  51459. static CreateLathe(name: string, options: {
  51460. shape: Vector3[];
  51461. radius?: number;
  51462. tessellation?: number;
  51463. clip?: number;
  51464. arc?: number;
  51465. closed?: boolean;
  51466. updatable?: boolean;
  51467. sideOrientation?: number;
  51468. frontUVs?: Vector4;
  51469. backUVs?: Vector4;
  51470. cap?: number;
  51471. invertUV?: boolean;
  51472. }, scene: Scene): Mesh;
  51473. /**
  51474. * Creates a plane mesh
  51475. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51476. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51477. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51481. * @param name defines the name of the mesh
  51482. * @param options defines the options used to create the mesh
  51483. * @param scene defines the hosting scene
  51484. * @returns the plane mesh
  51485. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51486. */
  51487. static CreatePlane(name: string, options: {
  51488. size?: number;
  51489. width?: number;
  51490. height?: number;
  51491. sideOrientation?: number;
  51492. frontUVs?: Vector4;
  51493. backUVs?: Vector4;
  51494. updatable?: boolean;
  51495. sourcePlane?: Plane;
  51496. }, scene: Scene): Mesh;
  51497. /**
  51498. * Creates a ground mesh
  51499. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51500. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51502. * @param name defines the name of the mesh
  51503. * @param options defines the options used to create the mesh
  51504. * @param scene defines the hosting scene
  51505. * @returns the ground mesh
  51506. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51507. */
  51508. static CreateGround(name: string, options: {
  51509. width?: number;
  51510. height?: number;
  51511. subdivisions?: number;
  51512. subdivisionsX?: number;
  51513. subdivisionsY?: number;
  51514. updatable?: boolean;
  51515. }, scene: any): Mesh;
  51516. /**
  51517. * Creates a tiled ground mesh
  51518. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51519. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51520. * * 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
  51521. * * 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
  51522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51523. * @param name defines the name of the mesh
  51524. * @param options defines the options used to create the mesh
  51525. * @param scene defines the hosting scene
  51526. * @returns the tiled ground mesh
  51527. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51528. */
  51529. static CreateTiledGround(name: string, options: {
  51530. xmin: number;
  51531. zmin: number;
  51532. xmax: number;
  51533. zmax: number;
  51534. subdivisions?: {
  51535. w: number;
  51536. h: number;
  51537. };
  51538. precision?: {
  51539. w: number;
  51540. h: number;
  51541. };
  51542. updatable?: boolean;
  51543. }, scene: Scene): Mesh;
  51544. /**
  51545. * Creates a ground mesh from a height map
  51546. * * The parameter `url` sets the URL of the height map image resource.
  51547. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51548. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51549. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51550. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51551. * * 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.
  51552. * * 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).
  51553. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51555. * @param name defines the name of the mesh
  51556. * @param url defines the url to the height map
  51557. * @param options defines the options used to create the mesh
  51558. * @param scene defines the hosting scene
  51559. * @returns the ground mesh
  51560. * @see https://doc.babylonjs.com/babylon101/height_map
  51561. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51562. */
  51563. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51564. width?: number;
  51565. height?: number;
  51566. subdivisions?: number;
  51567. minHeight?: number;
  51568. maxHeight?: number;
  51569. colorFilter?: Color3;
  51570. alphaFilter?: number;
  51571. updatable?: boolean;
  51572. onReady?: (mesh: GroundMesh) => void;
  51573. }, scene: Scene): GroundMesh;
  51574. /**
  51575. * Creates a polygon mesh
  51576. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51577. * * 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
  51578. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51581. * * Remember you can only change the shape positions, not their number when updating a polygon
  51582. * @param name defines the name of the mesh
  51583. * @param options defines the options used to create the mesh
  51584. * @param scene defines the hosting scene
  51585. * @param earcutInjection can be used to inject your own earcut reference
  51586. * @returns the polygon mesh
  51587. */
  51588. static CreatePolygon(name: string, options: {
  51589. shape: Vector3[];
  51590. holes?: Vector3[][];
  51591. depth?: number;
  51592. faceUV?: Vector4[];
  51593. faceColors?: Color4[];
  51594. updatable?: boolean;
  51595. sideOrientation?: number;
  51596. frontUVs?: Vector4;
  51597. backUVs?: Vector4;
  51598. }, scene: Scene, earcutInjection?: any): Mesh;
  51599. /**
  51600. * Creates an extruded polygon mesh, with depth in the Y direction.
  51601. * * 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)
  51602. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51603. * @param name defines the name of the mesh
  51604. * @param options defines the options used to create the mesh
  51605. * @param scene defines the hosting scene
  51606. * @param earcutInjection can be used to inject your own earcut reference
  51607. * @returns the polygon mesh
  51608. */
  51609. static ExtrudePolygon(name: string, options: {
  51610. shape: Vector3[];
  51611. holes?: Vector3[][];
  51612. depth?: number;
  51613. faceUV?: Vector4[];
  51614. faceColors?: Color4[];
  51615. updatable?: boolean;
  51616. sideOrientation?: number;
  51617. frontUVs?: Vector4;
  51618. backUVs?: Vector4;
  51619. }, scene: Scene, earcutInjection?: any): Mesh;
  51620. /**
  51621. * Creates a tube mesh.
  51622. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51623. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51624. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51625. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51626. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51627. * * 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)
  51628. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51629. * * 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
  51630. * * 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
  51631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51635. * @param name defines the name of the mesh
  51636. * @param options defines the options used to create the mesh
  51637. * @param scene defines the hosting scene
  51638. * @returns the tube mesh
  51639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51640. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51641. */
  51642. static CreateTube(name: string, options: {
  51643. path: Vector3[];
  51644. radius?: number;
  51645. tessellation?: number;
  51646. radiusFunction?: {
  51647. (i: number, distance: number): number;
  51648. };
  51649. cap?: number;
  51650. arc?: number;
  51651. updatable?: boolean;
  51652. sideOrientation?: number;
  51653. frontUVs?: Vector4;
  51654. backUVs?: Vector4;
  51655. instance?: Mesh;
  51656. invertUV?: boolean;
  51657. }, scene: Scene): Mesh;
  51658. /**
  51659. * Creates a polyhedron mesh
  51660. * * 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
  51661. * * The parameter `size` (positive float, default 1) sets the polygon size
  51662. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51663. * * 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`
  51664. * * 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
  51665. * * 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)`)
  51666. * * 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
  51667. * * 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
  51668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51671. * @param name defines the name of the mesh
  51672. * @param options defines the options used to create the mesh
  51673. * @param scene defines the hosting scene
  51674. * @returns the polyhedron mesh
  51675. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51676. */
  51677. static CreatePolyhedron(name: string, options: {
  51678. type?: number;
  51679. size?: number;
  51680. sizeX?: number;
  51681. sizeY?: number;
  51682. sizeZ?: number;
  51683. custom?: any;
  51684. faceUV?: Vector4[];
  51685. faceColors?: Color4[];
  51686. flat?: boolean;
  51687. updatable?: boolean;
  51688. sideOrientation?: number;
  51689. frontUVs?: Vector4;
  51690. backUVs?: Vector4;
  51691. }, scene: Scene): Mesh;
  51692. /**
  51693. * Creates a decal mesh.
  51694. * 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
  51695. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51696. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51697. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51698. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51699. * @param name defines the name of the mesh
  51700. * @param sourceMesh defines the mesh where the decal must be applied
  51701. * @param options defines the options used to create the mesh
  51702. * @param scene defines the hosting scene
  51703. * @returns the decal mesh
  51704. * @see https://doc.babylonjs.com/how_to/decals
  51705. */
  51706. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51707. position?: Vector3;
  51708. normal?: Vector3;
  51709. size?: Vector3;
  51710. angle?: number;
  51711. }): Mesh;
  51712. }
  51713. }
  51714. declare module "babylonjs/Meshes/meshSimplification" {
  51715. import { Mesh } from "babylonjs/Meshes/mesh";
  51716. /**
  51717. * A simplifier interface for future simplification implementations
  51718. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51719. */
  51720. export interface ISimplifier {
  51721. /**
  51722. * Simplification of a given mesh according to the given settings.
  51723. * Since this requires computation, it is assumed that the function runs async.
  51724. * @param settings The settings of the simplification, including quality and distance
  51725. * @param successCallback A callback that will be called after the mesh was simplified.
  51726. * @param errorCallback in case of an error, this callback will be called. optional.
  51727. */
  51728. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51729. }
  51730. /**
  51731. * Expected simplification settings.
  51732. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51733. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51734. */
  51735. export interface ISimplificationSettings {
  51736. /**
  51737. * Gets or sets the expected quality
  51738. */
  51739. quality: number;
  51740. /**
  51741. * Gets or sets the distance when this optimized version should be used
  51742. */
  51743. distance: number;
  51744. /**
  51745. * Gets an already optimized mesh
  51746. */
  51747. optimizeMesh?: boolean;
  51748. }
  51749. /**
  51750. * Class used to specify simplification options
  51751. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51752. */
  51753. export class SimplificationSettings implements ISimplificationSettings {
  51754. /** expected quality */
  51755. quality: number;
  51756. /** distance when this optimized version should be used */
  51757. distance: number;
  51758. /** already optimized mesh */
  51759. optimizeMesh?: boolean | undefined;
  51760. /**
  51761. * Creates a SimplificationSettings
  51762. * @param quality expected quality
  51763. * @param distance distance when this optimized version should be used
  51764. * @param optimizeMesh already optimized mesh
  51765. */
  51766. constructor(
  51767. /** expected quality */
  51768. quality: number,
  51769. /** distance when this optimized version should be used */
  51770. distance: number,
  51771. /** already optimized mesh */
  51772. optimizeMesh?: boolean | undefined);
  51773. }
  51774. /**
  51775. * Interface used to define a simplification task
  51776. */
  51777. export interface ISimplificationTask {
  51778. /**
  51779. * Array of settings
  51780. */
  51781. settings: Array<ISimplificationSettings>;
  51782. /**
  51783. * Simplification type
  51784. */
  51785. simplificationType: SimplificationType;
  51786. /**
  51787. * Mesh to simplify
  51788. */
  51789. mesh: Mesh;
  51790. /**
  51791. * Callback called on success
  51792. */
  51793. successCallback?: () => void;
  51794. /**
  51795. * Defines if parallel processing can be used
  51796. */
  51797. parallelProcessing: boolean;
  51798. }
  51799. /**
  51800. * Queue used to order the simplification tasks
  51801. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51802. */
  51803. export class SimplificationQueue {
  51804. private _simplificationArray;
  51805. /**
  51806. * Gets a boolean indicating that the process is still running
  51807. */
  51808. running: boolean;
  51809. /**
  51810. * Creates a new queue
  51811. */
  51812. constructor();
  51813. /**
  51814. * Adds a new simplification task
  51815. * @param task defines a task to add
  51816. */
  51817. addTask(task: ISimplificationTask): void;
  51818. /**
  51819. * Execute next task
  51820. */
  51821. executeNext(): void;
  51822. /**
  51823. * Execute a simplification task
  51824. * @param task defines the task to run
  51825. */
  51826. runSimplification(task: ISimplificationTask): void;
  51827. private getSimplifier;
  51828. }
  51829. /**
  51830. * The implemented types of simplification
  51831. * At the moment only Quadratic Error Decimation is implemented
  51832. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51833. */
  51834. export enum SimplificationType {
  51835. /** Quadratic error decimation */
  51836. QUADRATIC = 0
  51837. }
  51838. }
  51839. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51840. import { Scene } from "babylonjs/scene";
  51841. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51842. import { ISceneComponent } from "babylonjs/sceneComponent";
  51843. module "babylonjs/scene" {
  51844. interface Scene {
  51845. /** @hidden (Backing field) */
  51846. _simplificationQueue: SimplificationQueue;
  51847. /**
  51848. * Gets or sets the simplification queue attached to the scene
  51849. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51850. */
  51851. simplificationQueue: SimplificationQueue;
  51852. }
  51853. }
  51854. module "babylonjs/Meshes/mesh" {
  51855. interface Mesh {
  51856. /**
  51857. * Simplify the mesh according to the given array of settings.
  51858. * Function will return immediately and will simplify async
  51859. * @param settings a collection of simplification settings
  51860. * @param parallelProcessing should all levels calculate parallel or one after the other
  51861. * @param simplificationType the type of simplification to run
  51862. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51863. * @returns the current mesh
  51864. */
  51865. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51866. }
  51867. }
  51868. /**
  51869. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51870. * created in a scene
  51871. */
  51872. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51873. /**
  51874. * The component name helpfull to identify the component in the list of scene components.
  51875. */
  51876. readonly name: string;
  51877. /**
  51878. * The scene the component belongs to.
  51879. */
  51880. scene: Scene;
  51881. /**
  51882. * Creates a new instance of the component for the given scene
  51883. * @param scene Defines the scene to register the component in
  51884. */
  51885. constructor(scene: Scene);
  51886. /**
  51887. * Registers the component in a given scene
  51888. */
  51889. register(): void;
  51890. /**
  51891. * Rebuilds the elements related to this component in case of
  51892. * context lost for instance.
  51893. */
  51894. rebuild(): void;
  51895. /**
  51896. * Disposes the component and the associated ressources
  51897. */
  51898. dispose(): void;
  51899. private _beforeCameraUpdate;
  51900. }
  51901. }
  51902. declare module "babylonjs/Meshes/Builders/index" {
  51903. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51904. export * from "babylonjs/Meshes/Builders/discBuilder";
  51905. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51906. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51907. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51908. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51909. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51910. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51911. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51912. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51913. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51914. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51915. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51916. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51917. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51918. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51919. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51920. }
  51921. declare module "babylonjs/Meshes/index" {
  51922. export * from "babylonjs/Meshes/abstractMesh";
  51923. export * from "babylonjs/Meshes/buffer";
  51924. export * from "babylonjs/Meshes/Compression/index";
  51925. export * from "babylonjs/Meshes/csg";
  51926. export * from "babylonjs/Meshes/geometry";
  51927. export * from "babylonjs/Meshes/groundMesh";
  51928. export * from "babylonjs/Meshes/trailMesh";
  51929. export * from "babylonjs/Meshes/instancedMesh";
  51930. export * from "babylonjs/Meshes/linesMesh";
  51931. export * from "babylonjs/Meshes/mesh";
  51932. export * from "babylonjs/Meshes/mesh.vertexData";
  51933. export * from "babylonjs/Meshes/meshBuilder";
  51934. export * from "babylonjs/Meshes/meshSimplification";
  51935. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51936. export * from "babylonjs/Meshes/polygonMesh";
  51937. export * from "babylonjs/Meshes/subMesh";
  51938. export * from "babylonjs/Meshes/transformNode";
  51939. export * from "babylonjs/Meshes/Builders/index";
  51940. }
  51941. declare module "babylonjs/Morph/index" {
  51942. export * from "babylonjs/Morph/morphTarget";
  51943. export * from "babylonjs/Morph/morphTargetManager";
  51944. }
  51945. declare module "babylonjs/Offline/database" {
  51946. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51947. /**
  51948. * Class used to enable access to IndexedDB
  51949. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51950. */
  51951. export class Database implements IOfflineProvider {
  51952. private _callbackManifestChecked;
  51953. private _currentSceneUrl;
  51954. private _db;
  51955. private _enableSceneOffline;
  51956. private _enableTexturesOffline;
  51957. private _manifestVersionFound;
  51958. private _mustUpdateRessources;
  51959. private _hasReachedQuota;
  51960. private _isSupported;
  51961. private _idbFactory;
  51962. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51963. private static IsUASupportingBlobStorage;
  51964. /**
  51965. * Gets a boolean indicating if Database storate is enabled (off by default)
  51966. */
  51967. static IDBStorageEnabled: boolean;
  51968. /**
  51969. * Gets a boolean indicating if scene must be saved in the database
  51970. */
  51971. readonly enableSceneOffline: boolean;
  51972. /**
  51973. * Gets a boolean indicating if textures must be saved in the database
  51974. */
  51975. readonly enableTexturesOffline: boolean;
  51976. /**
  51977. * Creates a new Database
  51978. * @param urlToScene defines the url to load the scene
  51979. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51980. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51981. */
  51982. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51983. private static _ParseURL;
  51984. private static _ReturnFullUrlLocation;
  51985. private _checkManifestFile;
  51986. /**
  51987. * Open the database and make it available
  51988. * @param successCallback defines the callback to call on success
  51989. * @param errorCallback defines the callback to call on error
  51990. */
  51991. open(successCallback: () => void, errorCallback: () => void): void;
  51992. /**
  51993. * Loads an image from the database
  51994. * @param url defines the url to load from
  51995. * @param image defines the target DOM image
  51996. */
  51997. loadImage(url: string, image: HTMLImageElement): void;
  51998. private _loadImageFromDBAsync;
  51999. private _saveImageIntoDBAsync;
  52000. private _checkVersionFromDB;
  52001. private _loadVersionFromDBAsync;
  52002. private _saveVersionIntoDBAsync;
  52003. /**
  52004. * Loads a file from database
  52005. * @param url defines the URL to load from
  52006. * @param sceneLoaded defines a callback to call on success
  52007. * @param progressCallBack defines a callback to call when progress changed
  52008. * @param errorCallback defines a callback to call on error
  52009. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52010. */
  52011. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52012. private _loadFileAsync;
  52013. private _saveFileAsync;
  52014. /**
  52015. * Validates if xhr data is correct
  52016. * @param xhr defines the request to validate
  52017. * @param dataType defines the expected data type
  52018. * @returns true if data is correct
  52019. */
  52020. private static _ValidateXHRData;
  52021. }
  52022. }
  52023. declare module "babylonjs/Offline/index" {
  52024. export * from "babylonjs/Offline/database";
  52025. export * from "babylonjs/Offline/IOfflineProvider";
  52026. }
  52027. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  52028. /** @hidden */
  52029. export var gpuUpdateParticlesPixelShader: {
  52030. name: string;
  52031. shader: string;
  52032. };
  52033. }
  52034. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  52035. /** @hidden */
  52036. export var gpuUpdateParticlesVertexShader: {
  52037. name: string;
  52038. shader: string;
  52039. };
  52040. }
  52041. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  52042. /** @hidden */
  52043. export var clipPlaneFragmentDeclaration2: {
  52044. name: string;
  52045. shader: string;
  52046. };
  52047. }
  52048. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  52049. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  52050. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52051. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52052. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52053. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52054. /** @hidden */
  52055. export var gpuRenderParticlesPixelShader: {
  52056. name: string;
  52057. shader: string;
  52058. };
  52059. }
  52060. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  52061. /** @hidden */
  52062. export var clipPlaneVertexDeclaration2: {
  52063. name: string;
  52064. shader: string;
  52065. };
  52066. }
  52067. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  52068. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  52069. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52070. /** @hidden */
  52071. export var gpuRenderParticlesVertexShader: {
  52072. name: string;
  52073. shader: string;
  52074. };
  52075. }
  52076. declare module "babylonjs/Particles/gpuParticleSystem" {
  52077. import { Nullable } from "babylonjs/types";
  52078. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  52079. import { Observable } from "babylonjs/Misc/observable";
  52080. import { Color4, Color3 } from "babylonjs/Maths/math";
  52081. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52082. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  52083. import { Scene, IDisposable } from "babylonjs/scene";
  52084. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  52085. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  52086. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  52087. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  52088. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  52089. /**
  52090. * This represents a GPU particle system in Babylon
  52091. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  52092. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  52093. */
  52094. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  52095. /**
  52096. * The layer mask we are rendering the particles through.
  52097. */
  52098. layerMask: number;
  52099. private _capacity;
  52100. private _activeCount;
  52101. private _currentActiveCount;
  52102. private _accumulatedCount;
  52103. private _renderEffect;
  52104. private _updateEffect;
  52105. private _buffer0;
  52106. private _buffer1;
  52107. private _spriteBuffer;
  52108. private _updateVAO;
  52109. private _renderVAO;
  52110. private _targetIndex;
  52111. private _sourceBuffer;
  52112. private _targetBuffer;
  52113. private _engine;
  52114. private _currentRenderId;
  52115. private _started;
  52116. private _stopped;
  52117. private _timeDelta;
  52118. private _randomTexture;
  52119. private _randomTexture2;
  52120. private _attributesStrideSize;
  52121. private _updateEffectOptions;
  52122. private _randomTextureSize;
  52123. private _actualFrame;
  52124. private readonly _rawTextureWidth;
  52125. /**
  52126. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52127. */
  52128. static readonly IsSupported: boolean;
  52129. /**
  52130. * An event triggered when the system is disposed.
  52131. */
  52132. onDisposeObservable: Observable<GPUParticleSystem>;
  52133. /**
  52134. * Gets the maximum number of particles active at the same time.
  52135. * @returns The max number of active particles.
  52136. */
  52137. getCapacity(): number;
  52138. /**
  52139. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52140. * to override the particles.
  52141. */
  52142. forceDepthWrite: boolean;
  52143. /**
  52144. * Gets or set the number of active particles
  52145. */
  52146. activeParticleCount: number;
  52147. private _preWarmDone;
  52148. /**
  52149. * Is this system ready to be used/rendered
  52150. * @return true if the system is ready
  52151. */
  52152. isReady(): boolean;
  52153. /**
  52154. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52155. * @returns True if it has been started, otherwise false.
  52156. */
  52157. isStarted(): boolean;
  52158. /**
  52159. * Starts the particle system and begins to emit
  52160. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52161. */
  52162. start(delay?: number): void;
  52163. /**
  52164. * Stops the particle system.
  52165. */
  52166. stop(): void;
  52167. /**
  52168. * Remove all active particles
  52169. */
  52170. reset(): void;
  52171. /**
  52172. * Returns the string "GPUParticleSystem"
  52173. * @returns a string containing the class name
  52174. */
  52175. getClassName(): string;
  52176. private _colorGradientsTexture;
  52177. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52178. /**
  52179. * Adds a new color gradient
  52180. * @param gradient defines the gradient to use (between 0 and 1)
  52181. * @param color1 defines the color to affect to the specified gradient
  52182. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52183. * @returns the current particle system
  52184. */
  52185. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52186. /**
  52187. * Remove a specific color gradient
  52188. * @param gradient defines the gradient to remove
  52189. * @returns the current particle system
  52190. */
  52191. removeColorGradient(gradient: number): GPUParticleSystem;
  52192. private _angularSpeedGradientsTexture;
  52193. private _sizeGradientsTexture;
  52194. private _velocityGradientsTexture;
  52195. private _limitVelocityGradientsTexture;
  52196. private _dragGradientsTexture;
  52197. private _addFactorGradient;
  52198. /**
  52199. * Adds a new size gradient
  52200. * @param gradient defines the gradient to use (between 0 and 1)
  52201. * @param factor defines the size factor to affect to the specified gradient
  52202. * @returns the current particle system
  52203. */
  52204. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52205. /**
  52206. * Remove a specific size gradient
  52207. * @param gradient defines the gradient to remove
  52208. * @returns the current particle system
  52209. */
  52210. removeSizeGradient(gradient: number): GPUParticleSystem;
  52211. /**
  52212. * Adds a new angular speed gradient
  52213. * @param gradient defines the gradient to use (between 0 and 1)
  52214. * @param factor defines the angular speed to affect to the specified gradient
  52215. * @returns the current particle system
  52216. */
  52217. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52218. /**
  52219. * Remove a specific angular speed gradient
  52220. * @param gradient defines the gradient to remove
  52221. * @returns the current particle system
  52222. */
  52223. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52224. /**
  52225. * Adds a new velocity gradient
  52226. * @param gradient defines the gradient to use (between 0 and 1)
  52227. * @param factor defines the velocity to affect to the specified gradient
  52228. * @returns the current particle system
  52229. */
  52230. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52231. /**
  52232. * Remove a specific velocity gradient
  52233. * @param gradient defines the gradient to remove
  52234. * @returns the current particle system
  52235. */
  52236. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52237. /**
  52238. * Adds a new limit velocity gradient
  52239. * @param gradient defines the gradient to use (between 0 and 1)
  52240. * @param factor defines the limit velocity value to affect to the specified gradient
  52241. * @returns the current particle system
  52242. */
  52243. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52244. /**
  52245. * Remove a specific limit velocity gradient
  52246. * @param gradient defines the gradient to remove
  52247. * @returns the current particle system
  52248. */
  52249. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52250. /**
  52251. * Adds a new drag gradient
  52252. * @param gradient defines the gradient to use (between 0 and 1)
  52253. * @param factor defines the drag value to affect to the specified gradient
  52254. * @returns the current particle system
  52255. */
  52256. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52257. /**
  52258. * Remove a specific drag gradient
  52259. * @param gradient defines the gradient to remove
  52260. * @returns the current particle system
  52261. */
  52262. removeDragGradient(gradient: number): GPUParticleSystem;
  52263. /**
  52264. * Not supported by GPUParticleSystem
  52265. * @param gradient defines the gradient to use (between 0 and 1)
  52266. * @param factor defines the emit rate value to affect to the specified gradient
  52267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52268. * @returns the current particle system
  52269. */
  52270. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52271. /**
  52272. * Not supported by GPUParticleSystem
  52273. * @param gradient defines the gradient to remove
  52274. * @returns the current particle system
  52275. */
  52276. removeEmitRateGradient(gradient: number): IParticleSystem;
  52277. /**
  52278. * Not supported by GPUParticleSystem
  52279. * @param gradient defines the gradient to use (between 0 and 1)
  52280. * @param factor defines the start size value to affect to the specified gradient
  52281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52282. * @returns the current particle system
  52283. */
  52284. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52285. /**
  52286. * Not supported by GPUParticleSystem
  52287. * @param gradient defines the gradient to remove
  52288. * @returns the current particle system
  52289. */
  52290. removeStartSizeGradient(gradient: number): IParticleSystem;
  52291. /**
  52292. * Not supported by GPUParticleSystem
  52293. * @param gradient defines the gradient to use (between 0 and 1)
  52294. * @param min defines the color remap minimal range
  52295. * @param max defines the color remap maximal range
  52296. * @returns the current particle system
  52297. */
  52298. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52299. /**
  52300. * Not supported by GPUParticleSystem
  52301. * @param gradient defines the gradient to remove
  52302. * @returns the current particle system
  52303. */
  52304. removeColorRemapGradient(): IParticleSystem;
  52305. /**
  52306. * Not supported by GPUParticleSystem
  52307. * @param gradient defines the gradient to use (between 0 and 1)
  52308. * @param min defines the alpha remap minimal range
  52309. * @param max defines the alpha remap maximal range
  52310. * @returns the current particle system
  52311. */
  52312. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52313. /**
  52314. * Not supported by GPUParticleSystem
  52315. * @param gradient defines the gradient to remove
  52316. * @returns the current particle system
  52317. */
  52318. removeAlphaRemapGradient(): IParticleSystem;
  52319. /**
  52320. * Not supported by GPUParticleSystem
  52321. * @param gradient defines the gradient to use (between 0 and 1)
  52322. * @param color defines the color to affect to the specified gradient
  52323. * @returns the current particle system
  52324. */
  52325. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52326. /**
  52327. * Not supported by GPUParticleSystem
  52328. * @param gradient defines the gradient to remove
  52329. * @returns the current particle system
  52330. */
  52331. removeRampGradient(): IParticleSystem;
  52332. /**
  52333. * Not supported by GPUParticleSystem
  52334. * @returns the list of ramp gradients
  52335. */
  52336. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52337. /**
  52338. * Not supported by GPUParticleSystem
  52339. * Gets or sets a boolean indicating that ramp gradients must be used
  52340. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52341. */
  52342. useRampGradients: boolean;
  52343. /**
  52344. * Not supported by GPUParticleSystem
  52345. * @param gradient defines the gradient to use (between 0 and 1)
  52346. * @param factor defines the life time factor to affect to the specified gradient
  52347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52348. * @returns the current particle system
  52349. */
  52350. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52351. /**
  52352. * Not supported by GPUParticleSystem
  52353. * @param gradient defines the gradient to remove
  52354. * @returns the current particle system
  52355. */
  52356. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52357. /**
  52358. * Instantiates a GPU particle system.
  52359. * 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.
  52360. * @param name The name of the particle system
  52361. * @param options The options used to create the system
  52362. * @param scene The scene the particle system belongs to
  52363. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52364. */
  52365. constructor(name: string, options: Partial<{
  52366. capacity: number;
  52367. randomTextureSize: number;
  52368. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52369. protected _reset(): void;
  52370. private _createUpdateVAO;
  52371. private _createRenderVAO;
  52372. private _initialize;
  52373. /** @hidden */
  52374. _recreateUpdateEffect(): void;
  52375. /** @hidden */
  52376. _recreateRenderEffect(): void;
  52377. /**
  52378. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52379. * @param preWarm defines if we are in the pre-warmimg phase
  52380. */
  52381. animate(preWarm?: boolean): void;
  52382. private _createFactorGradientTexture;
  52383. private _createSizeGradientTexture;
  52384. private _createAngularSpeedGradientTexture;
  52385. private _createVelocityGradientTexture;
  52386. private _createLimitVelocityGradientTexture;
  52387. private _createDragGradientTexture;
  52388. private _createColorGradientTexture;
  52389. /**
  52390. * Renders the particle system in its current state
  52391. * @param preWarm defines if the system should only update the particles but not render them
  52392. * @returns the current number of particles
  52393. */
  52394. render(preWarm?: boolean): number;
  52395. /**
  52396. * Rebuilds the particle system
  52397. */
  52398. rebuild(): void;
  52399. private _releaseBuffers;
  52400. private _releaseVAOs;
  52401. /**
  52402. * Disposes the particle system and free the associated resources
  52403. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52404. */
  52405. dispose(disposeTexture?: boolean): void;
  52406. /**
  52407. * Clones the particle system.
  52408. * @param name The name of the cloned object
  52409. * @param newEmitter The new emitter to use
  52410. * @returns the cloned particle system
  52411. */
  52412. clone(name: string, newEmitter: any): GPUParticleSystem;
  52413. /**
  52414. * Serializes the particle system to a JSON object.
  52415. * @returns the JSON object
  52416. */
  52417. serialize(): any;
  52418. /**
  52419. * Parses a JSON object to create a GPU particle system.
  52420. * @param parsedParticleSystem The JSON object to parse
  52421. * @param scene The scene to create the particle system in
  52422. * @param rootUrl The root url to use to load external dependencies like texture
  52423. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52424. * @returns the parsed GPU particle system
  52425. */
  52426. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52427. }
  52428. }
  52429. declare module "babylonjs/Particles/particleSystemSet" {
  52430. import { Nullable } from "babylonjs/types";
  52431. import { Color3 } from "babylonjs/Maths/math";
  52432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52434. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52435. import { Scene, IDisposable } from "babylonjs/scene";
  52436. /**
  52437. * Represents a set of particle systems working together to create a specific effect
  52438. */
  52439. export class ParticleSystemSet implements IDisposable {
  52440. private _emitterCreationOptions;
  52441. private _emitterNode;
  52442. /**
  52443. * Gets the particle system list
  52444. */
  52445. systems: IParticleSystem[];
  52446. /**
  52447. * Gets the emitter node used with this set
  52448. */
  52449. readonly emitterNode: Nullable<TransformNode>;
  52450. /**
  52451. * Creates a new emitter mesh as a sphere
  52452. * @param options defines the options used to create the sphere
  52453. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52454. * @param scene defines the hosting scene
  52455. */
  52456. setEmitterAsSphere(options: {
  52457. diameter: number;
  52458. segments: number;
  52459. color: Color3;
  52460. }, renderingGroupId: number, scene: Scene): void;
  52461. /**
  52462. * Starts all particle systems of the set
  52463. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52464. */
  52465. start(emitter?: AbstractMesh): void;
  52466. /**
  52467. * Release all associated resources
  52468. */
  52469. dispose(): void;
  52470. /**
  52471. * Serialize the set into a JSON compatible object
  52472. * @returns a JSON compatible representation of the set
  52473. */
  52474. serialize(): any;
  52475. /**
  52476. * Parse a new ParticleSystemSet from a serialized source
  52477. * @param data defines a JSON compatible representation of the set
  52478. * @param scene defines the hosting scene
  52479. * @param gpu defines if we want GPU particles or CPU particles
  52480. * @returns a new ParticleSystemSet
  52481. */
  52482. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52483. }
  52484. }
  52485. declare module "babylonjs/Particles/particleHelper" {
  52486. import { Nullable } from "babylonjs/types";
  52487. import { Scene } from "babylonjs/scene";
  52488. import { Vector3 } from "babylonjs/Maths/math";
  52489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52490. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52491. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  52492. /**
  52493. * This class is made for on one-liner static method to help creating particle system set.
  52494. */
  52495. export class ParticleHelper {
  52496. /**
  52497. * Gets or sets base Assets URL
  52498. */
  52499. static BaseAssetsUrl: string;
  52500. /**
  52501. * Create a default particle system that you can tweak
  52502. * @param emitter defines the emitter to use
  52503. * @param capacity defines the system capacity (default is 500 particles)
  52504. * @param scene defines the hosting scene
  52505. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52506. * @returns the new Particle system
  52507. */
  52508. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52509. /**
  52510. * This is the main static method (one-liner) of this helper to create different particle systems
  52511. * @param type This string represents the type to the particle system to create
  52512. * @param scene The scene where the particle system should live
  52513. * @param gpu If the system will use gpu
  52514. * @returns the ParticleSystemSet created
  52515. */
  52516. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52517. /**
  52518. * Static function used to export a particle system to a ParticleSystemSet variable.
  52519. * Please note that the emitter shape is not exported
  52520. * @param systems defines the particle systems to export
  52521. * @returns the created particle system set
  52522. */
  52523. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52524. }
  52525. }
  52526. declare module "babylonjs/Particles/particleSystemComponent" {
  52527. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52528. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52529. import "babylonjs/Shaders/particles.vertex";
  52530. module "babylonjs/Engines/engine" {
  52531. interface Engine {
  52532. /**
  52533. * Create an effect to use with particle systems.
  52534. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52535. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52536. * @param uniformsNames defines a list of attribute names
  52537. * @param samplers defines an array of string used to represent textures
  52538. * @param defines defines the string containing the defines to use to compile the shaders
  52539. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52540. * @param onCompiled defines a function to call when the effect creation is successful
  52541. * @param onError defines a function to call when the effect creation has failed
  52542. * @returns the new Effect
  52543. */
  52544. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52545. }
  52546. }
  52547. module "babylonjs/Meshes/mesh" {
  52548. interface Mesh {
  52549. /**
  52550. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52551. * @returns an array of IParticleSystem
  52552. */
  52553. getEmittedParticleSystems(): IParticleSystem[];
  52554. /**
  52555. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52556. * @returns an array of IParticleSystem
  52557. */
  52558. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52559. }
  52560. }
  52561. /**
  52562. * @hidden
  52563. */
  52564. export var _IDoNeedToBeInTheBuild: number;
  52565. }
  52566. declare module "babylonjs/Particles/index" {
  52567. export * from "babylonjs/Particles/baseParticleSystem";
  52568. export * from "babylonjs/Particles/EmitterTypes/index";
  52569. export * from "babylonjs/Particles/gpuParticleSystem";
  52570. export * from "babylonjs/Particles/IParticleSystem";
  52571. export * from "babylonjs/Particles/particle";
  52572. export * from "babylonjs/Particles/particleHelper";
  52573. export * from "babylonjs/Particles/particleSystem";
  52574. export * from "babylonjs/Particles/particleSystemComponent";
  52575. export * from "babylonjs/Particles/particleSystemSet";
  52576. export * from "babylonjs/Particles/solidParticle";
  52577. export * from "babylonjs/Particles/solidParticleSystem";
  52578. export * from "babylonjs/Particles/subEmitter";
  52579. }
  52580. declare module "babylonjs/Physics/physicsEngineComponent" {
  52581. import { Nullable } from "babylonjs/types";
  52582. import { Observable, Observer } from "babylonjs/Misc/observable";
  52583. import { Vector3 } from "babylonjs/Maths/math";
  52584. import { Mesh } from "babylonjs/Meshes/mesh";
  52585. import { ISceneComponent } from "babylonjs/sceneComponent";
  52586. import { Scene } from "babylonjs/scene";
  52587. import { Node } from "babylonjs/node";
  52588. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52589. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52590. module "babylonjs/scene" {
  52591. interface Scene {
  52592. /** @hidden (Backing field) */
  52593. _physicsEngine: Nullable<IPhysicsEngine>;
  52594. /**
  52595. * Gets the current physics engine
  52596. * @returns a IPhysicsEngine or null if none attached
  52597. */
  52598. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52599. /**
  52600. * Enables physics to the current scene
  52601. * @param gravity defines the scene's gravity for the physics engine
  52602. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52603. * @return a boolean indicating if the physics engine was initialized
  52604. */
  52605. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52606. /**
  52607. * Disables and disposes the physics engine associated with the scene
  52608. */
  52609. disablePhysicsEngine(): void;
  52610. /**
  52611. * Gets a boolean indicating if there is an active physics engine
  52612. * @returns a boolean indicating if there is an active physics engine
  52613. */
  52614. isPhysicsEnabled(): boolean;
  52615. /**
  52616. * Deletes a physics compound impostor
  52617. * @param compound defines the compound to delete
  52618. */
  52619. deleteCompoundImpostor(compound: any): void;
  52620. /**
  52621. * An event triggered when physic simulation is about to be run
  52622. */
  52623. onBeforePhysicsObservable: Observable<Scene>;
  52624. /**
  52625. * An event triggered when physic simulation has been done
  52626. */
  52627. onAfterPhysicsObservable: Observable<Scene>;
  52628. }
  52629. }
  52630. module "babylonjs/Meshes/abstractMesh" {
  52631. interface AbstractMesh {
  52632. /** @hidden */
  52633. _physicsImpostor: Nullable<PhysicsImpostor>;
  52634. /**
  52635. * Gets or sets impostor used for physic simulation
  52636. * @see http://doc.babylonjs.com/features/physics_engine
  52637. */
  52638. physicsImpostor: Nullable<PhysicsImpostor>;
  52639. /**
  52640. * Gets the current physics impostor
  52641. * @see http://doc.babylonjs.com/features/physics_engine
  52642. * @returns a physics impostor or null
  52643. */
  52644. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52645. /** Apply a physic impulse to the mesh
  52646. * @param force defines the force to apply
  52647. * @param contactPoint defines where to apply the force
  52648. * @returns the current mesh
  52649. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52650. */
  52651. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52652. /**
  52653. * Creates a physic joint between two meshes
  52654. * @param otherMesh defines the other mesh to use
  52655. * @param pivot1 defines the pivot to use on this mesh
  52656. * @param pivot2 defines the pivot to use on the other mesh
  52657. * @param options defines additional options (can be plugin dependent)
  52658. * @returns the current mesh
  52659. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52660. */
  52661. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52662. /** @hidden */
  52663. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52664. }
  52665. }
  52666. /**
  52667. * Defines the physics engine scene component responsible to manage a physics engine
  52668. */
  52669. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52670. /**
  52671. * The component name helpful to identify the component in the list of scene components.
  52672. */
  52673. readonly name: string;
  52674. /**
  52675. * The scene the component belongs to.
  52676. */
  52677. scene: Scene;
  52678. /**
  52679. * Creates a new instance of the component for the given scene
  52680. * @param scene Defines the scene to register the component in
  52681. */
  52682. constructor(scene: Scene);
  52683. /**
  52684. * Registers the component in a given scene
  52685. */
  52686. register(): void;
  52687. /**
  52688. * Rebuilds the elements related to this component in case of
  52689. * context lost for instance.
  52690. */
  52691. rebuild(): void;
  52692. /**
  52693. * Disposes the component and the associated ressources
  52694. */
  52695. dispose(): void;
  52696. }
  52697. }
  52698. declare module "babylonjs/Physics/physicsHelper" {
  52699. import { Nullable } from "babylonjs/types";
  52700. import { Vector3 } from "babylonjs/Maths/math";
  52701. import { Mesh } from "babylonjs/Meshes/mesh";
  52702. import { Scene } from "babylonjs/scene";
  52703. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52704. /**
  52705. * A helper for physics simulations
  52706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52707. */
  52708. export class PhysicsHelper {
  52709. private _scene;
  52710. private _physicsEngine;
  52711. /**
  52712. * Initializes the Physics helper
  52713. * @param scene Babylon.js scene
  52714. */
  52715. constructor(scene: Scene);
  52716. /**
  52717. * Applies a radial explosion impulse
  52718. * @param origin the origin of the explosion
  52719. * @param radiusOrEventOptions the radius or the options of radial explosion
  52720. * @param strength the explosion strength
  52721. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52722. * @returns A physics radial explosion event, or null
  52723. */
  52724. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52725. /**
  52726. * Applies a radial explosion force
  52727. * @param origin the origin of the explosion
  52728. * @param radiusOrEventOptions the radius or the options of radial explosion
  52729. * @param strength the explosion strength
  52730. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52731. * @returns A physics radial explosion event, or null
  52732. */
  52733. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52734. /**
  52735. * Creates a gravitational field
  52736. * @param origin the origin of the explosion
  52737. * @param radiusOrEventOptions the radius or the options of radial explosion
  52738. * @param strength the explosion strength
  52739. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52740. * @returns A physics gravitational field event, or null
  52741. */
  52742. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52743. /**
  52744. * Creates a physics updraft event
  52745. * @param origin the origin of the updraft
  52746. * @param radiusOrEventOptions the radius or the options of the updraft
  52747. * @param strength the strength of the updraft
  52748. * @param height the height of the updraft
  52749. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52750. * @returns A physics updraft event, or null
  52751. */
  52752. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52753. /**
  52754. * Creates a physics vortex event
  52755. * @param origin the of the vortex
  52756. * @param radiusOrEventOptions the radius or the options of the vortex
  52757. * @param strength the strength of the vortex
  52758. * @param height the height of the vortex
  52759. * @returns a Physics vortex event, or null
  52760. * A physics vortex event or null
  52761. */
  52762. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52763. }
  52764. /**
  52765. * Represents a physics radial explosion event
  52766. */
  52767. class PhysicsRadialExplosionEvent {
  52768. private _scene;
  52769. private _options;
  52770. private _sphere;
  52771. private _dataFetched;
  52772. /**
  52773. * Initializes a radial explosioin event
  52774. * @param _scene BabylonJS scene
  52775. * @param _options The options for the vortex event
  52776. */
  52777. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52778. /**
  52779. * Returns the data related to the radial explosion event (sphere).
  52780. * @returns The radial explosion event data
  52781. */
  52782. getData(): PhysicsRadialExplosionEventData;
  52783. /**
  52784. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52785. * @param impostor A physics imposter
  52786. * @param origin the origin of the explosion
  52787. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52788. */
  52789. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  52790. /**
  52791. * Disposes the sphere.
  52792. * @param force Specifies if the sphere should be disposed by force
  52793. */
  52794. dispose(force?: boolean): void;
  52795. /*** Helpers ***/
  52796. private _prepareSphere;
  52797. private _intersectsWithSphere;
  52798. }
  52799. /**
  52800. * Represents a gravitational field event
  52801. */
  52802. class PhysicsGravitationalFieldEvent {
  52803. private _physicsHelper;
  52804. private _scene;
  52805. private _origin;
  52806. private _options;
  52807. private _tickCallback;
  52808. private _sphere;
  52809. private _dataFetched;
  52810. /**
  52811. * Initializes the physics gravitational field event
  52812. * @param _physicsHelper A physics helper
  52813. * @param _scene BabylonJS scene
  52814. * @param _origin The origin position of the gravitational field event
  52815. * @param _options The options for the vortex event
  52816. */
  52817. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52818. /**
  52819. * Returns the data related to the gravitational field event (sphere).
  52820. * @returns A gravitational field event
  52821. */
  52822. getData(): PhysicsGravitationalFieldEventData;
  52823. /**
  52824. * Enables the gravitational field.
  52825. */
  52826. enable(): void;
  52827. /**
  52828. * Disables the gravitational field.
  52829. */
  52830. disable(): void;
  52831. /**
  52832. * Disposes the sphere.
  52833. * @param force The force to dispose from the gravitational field event
  52834. */
  52835. dispose(force?: boolean): void;
  52836. private _tick;
  52837. }
  52838. /**
  52839. * Represents a physics updraft event
  52840. */
  52841. class PhysicsUpdraftEvent {
  52842. private _scene;
  52843. private _origin;
  52844. private _options;
  52845. private _physicsEngine;
  52846. private _originTop;
  52847. private _originDirection;
  52848. private _tickCallback;
  52849. private _cylinder;
  52850. private _cylinderPosition;
  52851. private _dataFetched;
  52852. /**
  52853. * Initializes the physics updraft event
  52854. * @param _scene BabylonJS scene
  52855. * @param _origin The origin position of the updraft
  52856. * @param _options The options for the updraft event
  52857. */
  52858. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52859. /**
  52860. * Returns the data related to the updraft event (cylinder).
  52861. * @returns A physics updraft event
  52862. */
  52863. getData(): PhysicsUpdraftEventData;
  52864. /**
  52865. * Enables the updraft.
  52866. */
  52867. enable(): void;
  52868. /**
  52869. * Disables the updraft.
  52870. */
  52871. disable(): void;
  52872. /**
  52873. * Disposes the cylinder.
  52874. * @param force Specifies if the updraft should be disposed by force
  52875. */
  52876. dispose(force?: boolean): void;
  52877. private getImpostorForceAndContactPoint;
  52878. private _tick;
  52879. /*** Helpers ***/
  52880. private _prepareCylinder;
  52881. private _intersectsWithCylinder;
  52882. }
  52883. /**
  52884. * Represents a physics vortex event
  52885. */
  52886. class PhysicsVortexEvent {
  52887. private _scene;
  52888. private _origin;
  52889. private _options;
  52890. private _physicsEngine;
  52891. private _originTop;
  52892. private _tickCallback;
  52893. private _cylinder;
  52894. private _cylinderPosition;
  52895. private _dataFetched;
  52896. /**
  52897. * Initializes the physics vortex event
  52898. * @param _scene The BabylonJS scene
  52899. * @param _origin The origin position of the vortex
  52900. * @param _options The options for the vortex event
  52901. */
  52902. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52903. /**
  52904. * Returns the data related to the vortex event (cylinder).
  52905. * @returns The physics vortex event data
  52906. */
  52907. getData(): PhysicsVortexEventData;
  52908. /**
  52909. * Enables the vortex.
  52910. */
  52911. enable(): void;
  52912. /**
  52913. * Disables the cortex.
  52914. */
  52915. disable(): void;
  52916. /**
  52917. * Disposes the sphere.
  52918. * @param force
  52919. */
  52920. dispose(force?: boolean): void;
  52921. private getImpostorForceAndContactPoint;
  52922. private _tick;
  52923. /*** Helpers ***/
  52924. private _prepareCylinder;
  52925. private _intersectsWithCylinder;
  52926. }
  52927. /**
  52928. * Options fot the radial explosion event
  52929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52930. */
  52931. export class PhysicsRadialExplosionEventOptions {
  52932. /**
  52933. * The radius of the sphere for the radial explosion.
  52934. */
  52935. radius: number;
  52936. /**
  52937. * The strenth of the explosion.
  52938. */
  52939. strength: number;
  52940. /**
  52941. * The strenght of the force in correspondence to the distance of the affected object
  52942. */
  52943. falloff: PhysicsRadialImpulseFalloff;
  52944. /**
  52945. * Sphere options for the radial explosion.
  52946. */
  52947. sphere: {
  52948. segments: number;
  52949. diameter: number;
  52950. };
  52951. }
  52952. /**
  52953. * Options fot the updraft event
  52954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52955. */
  52956. export class PhysicsUpdraftEventOptions {
  52957. /**
  52958. * The radius of the cylinder for the vortex
  52959. */
  52960. radius: number;
  52961. /**
  52962. * The strenth of the updraft.
  52963. */
  52964. strength: number;
  52965. /**
  52966. * The height of the cylinder for the updraft.
  52967. */
  52968. height: number;
  52969. /**
  52970. * The mode for the the updraft.
  52971. */
  52972. updraftMode: PhysicsUpdraftMode;
  52973. }
  52974. /**
  52975. * Options fot the vortex event
  52976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52977. */
  52978. export class PhysicsVortexEventOptions {
  52979. /**
  52980. * The radius of the cylinder for the vortex
  52981. */
  52982. radius: number;
  52983. /**
  52984. * The strenth of the vortex.
  52985. */
  52986. strength: number;
  52987. /**
  52988. * The height of the cylinder for the vortex.
  52989. */
  52990. height: number;
  52991. /**
  52992. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52993. */
  52994. centripetalForceThreshold: number;
  52995. /**
  52996. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52997. */
  52998. centripetalForceMultiplier: number;
  52999. /**
  53000. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53001. */
  53002. centrifugalForceMultiplier: number;
  53003. /**
  53004. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53005. */
  53006. updraftForceMultiplier: number;
  53007. }
  53008. /**
  53009. * The strenght of the force in correspondence to the distance of the affected object
  53010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53011. */
  53012. export enum PhysicsRadialImpulseFalloff {
  53013. /** Defines that impulse is constant in strength across it's whole radius */
  53014. Constant = 0,
  53015. /** Defines that impulse gets weaker if it's further from the origin */
  53016. Linear = 1
  53017. }
  53018. /**
  53019. * The strength of the force in correspondence to the distance of the affected object
  53020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53021. */
  53022. export enum PhysicsUpdraftMode {
  53023. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53024. Center = 0,
  53025. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53026. Perpendicular = 1
  53027. }
  53028. /**
  53029. * Interface for a physics force and contact point
  53030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53031. */
  53032. export interface PhysicsForceAndContactPoint {
  53033. /**
  53034. * The force applied at the contact point
  53035. */
  53036. force: Vector3;
  53037. /**
  53038. * The contact point
  53039. */
  53040. contactPoint: Vector3;
  53041. }
  53042. /**
  53043. * Interface for radial explosion event data
  53044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53045. */
  53046. export interface PhysicsRadialExplosionEventData {
  53047. /**
  53048. * A sphere used for the radial explosion event
  53049. */
  53050. sphere: Mesh;
  53051. }
  53052. /**
  53053. * Interface for gravitational field event data
  53054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53055. */
  53056. export interface PhysicsGravitationalFieldEventData {
  53057. /**
  53058. * A sphere mesh used for the gravitational field event
  53059. */
  53060. sphere: Mesh;
  53061. }
  53062. /**
  53063. * Interface for updraft event data
  53064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53065. */
  53066. export interface PhysicsUpdraftEventData {
  53067. /**
  53068. * A cylinder used for the updraft event
  53069. */
  53070. cylinder: Mesh;
  53071. }
  53072. /**
  53073. * Interface for vortex event data
  53074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53075. */
  53076. export interface PhysicsVortexEventData {
  53077. /**
  53078. * A cylinder used for the vortex event
  53079. */
  53080. cylinder: Mesh;
  53081. }
  53082. }
  53083. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53084. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  53085. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53086. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53087. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53088. import { Nullable } from "babylonjs/types";
  53089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53090. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53091. /**
  53092. * AmmoJS Physics plugin
  53093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53094. * @see https://github.com/kripken/ammo.js/
  53095. */
  53096. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53097. private _useDeltaForWorldStep;
  53098. /**
  53099. * Reference to the Ammo library
  53100. */
  53101. bjsAMMO: any;
  53102. /**
  53103. * Created ammoJS world which physics bodies are added to
  53104. */
  53105. world: any;
  53106. /**
  53107. * Name of the plugin
  53108. */
  53109. name: string;
  53110. private _timeStep;
  53111. private _fixedTimeStep;
  53112. private _maxSteps;
  53113. private _tmpQuaternion;
  53114. private _tmpAmmoTransform;
  53115. private _tmpAmmoQuaternion;
  53116. private _tmpAmmoConcreteContactResultCallback;
  53117. private _collisionConfiguration;
  53118. private _dispatcher;
  53119. private _overlappingPairCache;
  53120. private _solver;
  53121. private _softBodySolver;
  53122. private _tmpAmmoVectorA;
  53123. private _tmpAmmoVectorB;
  53124. private _tmpAmmoVectorC;
  53125. private _tmpAmmoVectorD;
  53126. private _tmpContactCallbackResult;
  53127. private _tmpAmmoVectorRCA;
  53128. private _tmpAmmoVectorRCB;
  53129. private _raycastResult;
  53130. private static readonly DISABLE_COLLISION_FLAG;
  53131. private static readonly KINEMATIC_FLAG;
  53132. private static readonly DISABLE_DEACTIVATION_FLAG;
  53133. /**
  53134. * Initializes the ammoJS plugin
  53135. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53136. * @param ammoInjection can be used to inject your own ammo reference
  53137. */
  53138. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  53139. /**
  53140. * Sets the gravity of the physics world (m/(s^2))
  53141. * @param gravity Gravity to set
  53142. */
  53143. setGravity(gravity: Vector3): void;
  53144. /**
  53145. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53146. * @param timeStep timestep to use in seconds
  53147. */
  53148. setTimeStep(timeStep: number): void;
  53149. /**
  53150. * 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)
  53151. * @param fixedTimeStep fixedTimeStep to use in seconds
  53152. */
  53153. setFixedTimeStep(fixedTimeStep: number): void;
  53154. /**
  53155. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53156. * @param maxSteps the maximum number of steps by the physics engine per frame
  53157. */
  53158. setMaxSteps(maxSteps: number): void;
  53159. /**
  53160. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53161. * @returns the current timestep in seconds
  53162. */
  53163. getTimeStep(): number;
  53164. private _isImpostorInContact;
  53165. private _isImpostorPairInContact;
  53166. private _stepSimulation;
  53167. /**
  53168. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53169. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53170. * After the step the babylon meshes are set to the position of the physics imposters
  53171. * @param delta amount of time to step forward
  53172. * @param impostors array of imposters to update before/after the step
  53173. */
  53174. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53175. /**
  53176. * Update babylon mesh to match physics world object
  53177. * @param impostor imposter to match
  53178. */
  53179. private _afterSoftStep;
  53180. /**
  53181. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53182. * @param impostor imposter to match
  53183. */
  53184. private _ropeStep;
  53185. /**
  53186. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53187. * @param impostor imposter to match
  53188. */
  53189. private _softbodyOrClothStep;
  53190. private _tmpVector;
  53191. private _tmpMatrix;
  53192. /**
  53193. * Applies an impulse on the imposter
  53194. * @param impostor imposter to apply impulse to
  53195. * @param force amount of force to be applied to the imposter
  53196. * @param contactPoint the location to apply the impulse on the imposter
  53197. */
  53198. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53199. /**
  53200. * Applies a force on the imposter
  53201. * @param impostor imposter to apply force
  53202. * @param force amount of force to be applied to the imposter
  53203. * @param contactPoint the location to apply the force on the imposter
  53204. */
  53205. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53206. /**
  53207. * Creates a physics body using the plugin
  53208. * @param impostor the imposter to create the physics body on
  53209. */
  53210. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53211. /**
  53212. * Removes the physics body from the imposter and disposes of the body's memory
  53213. * @param impostor imposter to remove the physics body from
  53214. */
  53215. removePhysicsBody(impostor: PhysicsImpostor): void;
  53216. /**
  53217. * Generates a joint
  53218. * @param impostorJoint the imposter joint to create the joint with
  53219. */
  53220. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53221. /**
  53222. * Removes a joint
  53223. * @param impostorJoint the imposter joint to remove the joint from
  53224. */
  53225. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53226. private _addMeshVerts;
  53227. /**
  53228. * Initialise the soft body vertices to match its object's (mesh) vertices
  53229. * Softbody vertices (nodes) are in world space and to match this
  53230. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53231. * @param impostor to create the softbody for
  53232. */
  53233. private _softVertexData;
  53234. /**
  53235. * Create an impostor's soft body
  53236. * @param impostor to create the softbody for
  53237. */
  53238. private _createSoftbody;
  53239. /**
  53240. * Create cloth for an impostor
  53241. * @param impostor to create the softbody for
  53242. */
  53243. private _createCloth;
  53244. /**
  53245. * Create rope for an impostor
  53246. * @param impostor to create the softbody for
  53247. */
  53248. private _createRope;
  53249. private _addHullVerts;
  53250. private _createShape;
  53251. /**
  53252. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53253. * @param impostor imposter containing the physics body and babylon object
  53254. */
  53255. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53256. /**
  53257. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53258. * @param impostor imposter containing the physics body and babylon object
  53259. * @param newPosition new position
  53260. * @param newRotation new rotation
  53261. */
  53262. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53263. /**
  53264. * If this plugin is supported
  53265. * @returns true if its supported
  53266. */
  53267. isSupported(): boolean;
  53268. /**
  53269. * Sets the linear velocity of the physics body
  53270. * @param impostor imposter to set the velocity on
  53271. * @param velocity velocity to set
  53272. */
  53273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53274. /**
  53275. * Sets the angular velocity of the physics body
  53276. * @param impostor imposter to set the velocity on
  53277. * @param velocity velocity to set
  53278. */
  53279. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53280. /**
  53281. * gets the linear velocity
  53282. * @param impostor imposter to get linear velocity from
  53283. * @returns linear velocity
  53284. */
  53285. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53286. /**
  53287. * gets the angular velocity
  53288. * @param impostor imposter to get angular velocity from
  53289. * @returns angular velocity
  53290. */
  53291. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53292. /**
  53293. * Sets the mass of physics body
  53294. * @param impostor imposter to set the mass on
  53295. * @param mass mass to set
  53296. */
  53297. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53298. /**
  53299. * Gets the mass of the physics body
  53300. * @param impostor imposter to get the mass from
  53301. * @returns mass
  53302. */
  53303. getBodyMass(impostor: PhysicsImpostor): number;
  53304. /**
  53305. * Gets friction of the impostor
  53306. * @param impostor impostor to get friction from
  53307. * @returns friction value
  53308. */
  53309. getBodyFriction(impostor: PhysicsImpostor): number;
  53310. /**
  53311. * Sets friction of the impostor
  53312. * @param impostor impostor to set friction on
  53313. * @param friction friction value
  53314. */
  53315. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53316. /**
  53317. * Gets restitution of the impostor
  53318. * @param impostor impostor to get restitution from
  53319. * @returns restitution value
  53320. */
  53321. getBodyRestitution(impostor: PhysicsImpostor): number;
  53322. /**
  53323. * Sets resitution of the impostor
  53324. * @param impostor impostor to set resitution on
  53325. * @param restitution resitution value
  53326. */
  53327. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53328. /**
  53329. * Gets pressure inside the impostor
  53330. * @param impostor impostor to get pressure from
  53331. * @returns pressure value
  53332. */
  53333. getBodyPressure(impostor: PhysicsImpostor): number;
  53334. /**
  53335. * Sets pressure inside a soft body impostor
  53336. * Cloth and rope must remain 0 pressure
  53337. * @param impostor impostor to set pressure on
  53338. * @param pressure pressure value
  53339. */
  53340. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53341. /**
  53342. * Gets stiffness of the impostor
  53343. * @param impostor impostor to get stiffness from
  53344. * @returns pressure value
  53345. */
  53346. getBodyStiffness(impostor: PhysicsImpostor): number;
  53347. /**
  53348. * Sets stiffness of the impostor
  53349. * @param impostor impostor to set stiffness on
  53350. * @param stiffness stiffness value from 0 to 1
  53351. */
  53352. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53353. /**
  53354. * Gets velocityIterations of the impostor
  53355. * @param impostor impostor to get velocity iterations from
  53356. * @returns velocityIterations value
  53357. */
  53358. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53359. /**
  53360. * Sets velocityIterations of the impostor
  53361. * @param impostor impostor to set velocity iterations on
  53362. * @param velocityIterations velocityIterations value
  53363. */
  53364. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53365. /**
  53366. * Gets positionIterations of the impostor
  53367. * @param impostor impostor to get position iterations from
  53368. * @returns positionIterations value
  53369. */
  53370. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53371. /**
  53372. * Sets positionIterations of the impostor
  53373. * @param impostor impostor to set position on
  53374. * @param positionIterations positionIterations value
  53375. */
  53376. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53377. /**
  53378. * Append an anchor to a cloth object
  53379. * @param impostor is the cloth impostor to add anchor to
  53380. * @param otherImpostor is the rigid impostor to anchor to
  53381. * @param width ratio across width from 0 to 1
  53382. * @param height ratio up height from 0 to 1
  53383. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53384. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53385. */
  53386. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53387. /**
  53388. * Append an hook to a rope object
  53389. * @param impostor is the rope impostor to add hook to
  53390. * @param otherImpostor is the rigid impostor to hook to
  53391. * @param length ratio along the rope from 0 to 1
  53392. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53393. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53394. */
  53395. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53396. /**
  53397. * Sleeps the physics body and stops it from being active
  53398. * @param impostor impostor to sleep
  53399. */
  53400. sleepBody(impostor: PhysicsImpostor): void;
  53401. /**
  53402. * Activates the physics body
  53403. * @param impostor impostor to activate
  53404. */
  53405. wakeUpBody(impostor: PhysicsImpostor): void;
  53406. /**
  53407. * Updates the distance parameters of the joint
  53408. * @param joint joint to update
  53409. * @param maxDistance maximum distance of the joint
  53410. * @param minDistance minimum distance of the joint
  53411. */
  53412. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53413. /**
  53414. * Sets a motor on the joint
  53415. * @param joint joint to set motor on
  53416. * @param speed speed of the motor
  53417. * @param maxForce maximum force of the motor
  53418. * @param motorIndex index of the motor
  53419. */
  53420. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53421. /**
  53422. * Sets the motors limit
  53423. * @param joint joint to set limit on
  53424. * @param upperLimit upper limit
  53425. * @param lowerLimit lower limit
  53426. */
  53427. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53428. /**
  53429. * Syncs the position and rotation of a mesh with the impostor
  53430. * @param mesh mesh to sync
  53431. * @param impostor impostor to update the mesh with
  53432. */
  53433. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53434. /**
  53435. * Gets the radius of the impostor
  53436. * @param impostor impostor to get radius from
  53437. * @returns the radius
  53438. */
  53439. getRadius(impostor: PhysicsImpostor): number;
  53440. /**
  53441. * Gets the box size of the impostor
  53442. * @param impostor impostor to get box size from
  53443. * @param result the resulting box size
  53444. */
  53445. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53446. /**
  53447. * Disposes of the impostor
  53448. */
  53449. dispose(): void;
  53450. /**
  53451. * Does a raycast in the physics world
  53452. * @param from when should the ray start?
  53453. * @param to when should the ray end?
  53454. * @returns PhysicsRaycastResult
  53455. */
  53456. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53457. }
  53458. }
  53459. declare module "babylonjs/Physics/Plugins/index" {
  53460. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53461. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53462. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53463. }
  53464. declare module "babylonjs/Physics/index" {
  53465. export * from "babylonjs/Physics/IPhysicsEngine";
  53466. export * from "babylonjs/Physics/physicsEngine";
  53467. export * from "babylonjs/Physics/physicsEngineComponent";
  53468. export * from "babylonjs/Physics/physicsHelper";
  53469. export * from "babylonjs/Physics/physicsImpostor";
  53470. export * from "babylonjs/Physics/physicsJoint";
  53471. export * from "babylonjs/Physics/Plugins/index";
  53472. }
  53473. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53474. /** @hidden */
  53475. export var blackAndWhitePixelShader: {
  53476. name: string;
  53477. shader: string;
  53478. };
  53479. }
  53480. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53482. import { Camera } from "babylonjs/Cameras/camera";
  53483. import { Engine } from "babylonjs/Engines/engine";
  53484. import "babylonjs/Shaders/blackAndWhite.fragment";
  53485. /**
  53486. * Post process used to render in black and white
  53487. */
  53488. export class BlackAndWhitePostProcess extends PostProcess {
  53489. /**
  53490. * Linear about to convert he result to black and white (default: 1)
  53491. */
  53492. degree: number;
  53493. /**
  53494. * Creates a black and white post process
  53495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53496. * @param name The name of the effect.
  53497. * @param options The required width/height ratio to downsize to before computing the render pass.
  53498. * @param camera The camera to apply the render pass to.
  53499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53500. * @param engine The engine which the post process will be applied. (default: current engine)
  53501. * @param reusable If the post process can be reused on the same frame. (default: false)
  53502. */
  53503. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53504. }
  53505. }
  53506. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53507. import { Nullable } from "babylonjs/types";
  53508. import { Camera } from "babylonjs/Cameras/camera";
  53509. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53510. import { Engine } from "babylonjs/Engines/engine";
  53511. /**
  53512. * This represents a set of one or more post processes in Babylon.
  53513. * A post process can be used to apply a shader to a texture after it is rendered.
  53514. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53515. */
  53516. export class PostProcessRenderEffect {
  53517. private _postProcesses;
  53518. private _getPostProcesses;
  53519. private _singleInstance;
  53520. private _cameras;
  53521. private _indicesForCamera;
  53522. /**
  53523. * Name of the effect
  53524. * @hidden
  53525. */
  53526. _name: string;
  53527. /**
  53528. * Instantiates a post process render effect.
  53529. * A post process can be used to apply a shader to a texture after it is rendered.
  53530. * @param engine The engine the effect is tied to
  53531. * @param name The name of the effect
  53532. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53533. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53534. */
  53535. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53536. /**
  53537. * Checks if all the post processes in the effect are supported.
  53538. */
  53539. readonly isSupported: boolean;
  53540. /**
  53541. * Updates the current state of the effect
  53542. * @hidden
  53543. */
  53544. _update(): void;
  53545. /**
  53546. * Attaches the effect on cameras
  53547. * @param cameras The camera to attach to.
  53548. * @hidden
  53549. */
  53550. _attachCameras(cameras: Camera): void;
  53551. /**
  53552. * Attaches the effect on cameras
  53553. * @param cameras The camera to attach to.
  53554. * @hidden
  53555. */
  53556. _attachCameras(cameras: Camera[]): void;
  53557. /**
  53558. * Detatches the effect on cameras
  53559. * @param cameras The camera to detatch from.
  53560. * @hidden
  53561. */
  53562. _detachCameras(cameras: Camera): void;
  53563. /**
  53564. * Detatches the effect on cameras
  53565. * @param cameras The camera to detatch from.
  53566. * @hidden
  53567. */
  53568. _detachCameras(cameras: Camera[]): void;
  53569. /**
  53570. * Enables the effect on given cameras
  53571. * @param cameras The camera to enable.
  53572. * @hidden
  53573. */
  53574. _enable(cameras: Camera): void;
  53575. /**
  53576. * Enables the effect on given cameras
  53577. * @param cameras The camera to enable.
  53578. * @hidden
  53579. */
  53580. _enable(cameras: Nullable<Camera[]>): void;
  53581. /**
  53582. * Disables the effect on the given cameras
  53583. * @param cameras The camera to disable.
  53584. * @hidden
  53585. */
  53586. _disable(cameras: Camera): void;
  53587. /**
  53588. * Disables the effect on the given cameras
  53589. * @param cameras The camera to disable.
  53590. * @hidden
  53591. */
  53592. _disable(cameras: Nullable<Camera[]>): void;
  53593. /**
  53594. * Gets a list of the post processes contained in the effect.
  53595. * @param camera The camera to get the post processes on.
  53596. * @returns The list of the post processes in the effect.
  53597. */
  53598. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53599. }
  53600. }
  53601. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53602. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53603. /** @hidden */
  53604. export var extractHighlightsPixelShader: {
  53605. name: string;
  53606. shader: string;
  53607. };
  53608. }
  53609. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53610. import { Nullable } from "babylonjs/types";
  53611. import { Camera } from "babylonjs/Cameras/camera";
  53612. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53613. import { Engine } from "babylonjs/Engines/engine";
  53614. import "babylonjs/Shaders/extractHighlights.fragment";
  53615. /**
  53616. * 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.
  53617. */
  53618. export class ExtractHighlightsPostProcess extends PostProcess {
  53619. /**
  53620. * The luminance threshold, pixels below this value will be set to black.
  53621. */
  53622. threshold: number;
  53623. /** @hidden */
  53624. _exposure: number;
  53625. /**
  53626. * Post process which has the input texture to be used when performing highlight extraction
  53627. * @hidden
  53628. */
  53629. _inputPostProcess: Nullable<PostProcess>;
  53630. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53631. }
  53632. }
  53633. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53634. /** @hidden */
  53635. export var bloomMergePixelShader: {
  53636. name: string;
  53637. shader: string;
  53638. };
  53639. }
  53640. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53641. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53642. import { Nullable } from "babylonjs/types";
  53643. import { Engine } from "babylonjs/Engines/engine";
  53644. import { Camera } from "babylonjs/Cameras/camera";
  53645. import "babylonjs/Shaders/bloomMerge.fragment";
  53646. /**
  53647. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53648. */
  53649. export class BloomMergePostProcess extends PostProcess {
  53650. /** Weight of the bloom to be added to the original input. */
  53651. weight: number;
  53652. /**
  53653. * Creates a new instance of @see BloomMergePostProcess
  53654. * @param name The name of the effect.
  53655. * @param originalFromInput Post process which's input will be used for the merge.
  53656. * @param blurred Blurred highlights post process which's output will be used.
  53657. * @param weight Weight of the bloom to be added to the original input.
  53658. * @param options The required width/height ratio to downsize to before computing the render pass.
  53659. * @param camera The camera to apply the render pass to.
  53660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53661. * @param engine The engine which the post process will be applied. (default: current engine)
  53662. * @param reusable If the post process can be reused on the same frame. (default: false)
  53663. * @param textureType Type of textures used when performing the post process. (default: 0)
  53664. * @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)
  53665. */
  53666. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53667. /** Weight of the bloom to be added to the original input. */
  53668. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53669. }
  53670. }
  53671. declare module "babylonjs/PostProcesses/bloomEffect" {
  53672. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53673. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53674. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53675. import { Camera } from "babylonjs/Cameras/camera";
  53676. import { Scene } from "babylonjs/scene";
  53677. /**
  53678. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53679. */
  53680. export class BloomEffect extends PostProcessRenderEffect {
  53681. private bloomScale;
  53682. /**
  53683. * @hidden Internal
  53684. */
  53685. _effects: Array<PostProcess>;
  53686. /**
  53687. * @hidden Internal
  53688. */
  53689. _downscale: ExtractHighlightsPostProcess;
  53690. private _blurX;
  53691. private _blurY;
  53692. private _merge;
  53693. /**
  53694. * The luminance threshold to find bright areas of the image to bloom.
  53695. */
  53696. threshold: number;
  53697. /**
  53698. * The strength of the bloom.
  53699. */
  53700. weight: number;
  53701. /**
  53702. * Specifies the size of the bloom blur kernel, relative to the final output size
  53703. */
  53704. kernel: number;
  53705. /**
  53706. * Creates a new instance of @see BloomEffect
  53707. * @param scene The scene the effect belongs to.
  53708. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53709. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53710. * @param bloomWeight The the strength of bloom.
  53711. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53712. * @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)
  53713. */
  53714. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53715. /**
  53716. * Disposes each of the internal effects for a given camera.
  53717. * @param camera The camera to dispose the effect on.
  53718. */
  53719. disposeEffects(camera: Camera): void;
  53720. /**
  53721. * @hidden Internal
  53722. */
  53723. _updateEffects(): void;
  53724. /**
  53725. * Internal
  53726. * @returns if all the contained post processes are ready.
  53727. * @hidden
  53728. */
  53729. _isReady(): boolean;
  53730. }
  53731. }
  53732. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53733. /** @hidden */
  53734. export var chromaticAberrationPixelShader: {
  53735. name: string;
  53736. shader: string;
  53737. };
  53738. }
  53739. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53740. import { Vector2 } from "babylonjs/Maths/math";
  53741. import { Nullable } from "babylonjs/types";
  53742. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53743. import { Camera } from "babylonjs/Cameras/camera";
  53744. import { Engine } from "babylonjs/Engines/engine";
  53745. import "babylonjs/Shaders/chromaticAberration.fragment";
  53746. /**
  53747. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53748. */
  53749. export class ChromaticAberrationPostProcess extends PostProcess {
  53750. /**
  53751. * The amount of seperation of rgb channels (default: 30)
  53752. */
  53753. aberrationAmount: number;
  53754. /**
  53755. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53756. */
  53757. radialIntensity: number;
  53758. /**
  53759. * 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))
  53760. */
  53761. direction: Vector2;
  53762. /**
  53763. * 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))
  53764. */
  53765. centerPosition: Vector2;
  53766. /**
  53767. * Creates a new instance ChromaticAberrationPostProcess
  53768. * @param name The name of the effect.
  53769. * @param screenWidth The width of the screen to apply the effect on.
  53770. * @param screenHeight The height of the screen to apply the effect on.
  53771. * @param options The required width/height ratio to downsize to before computing the render pass.
  53772. * @param camera The camera to apply the render pass to.
  53773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53774. * @param engine The engine which the post process will be applied. (default: current engine)
  53775. * @param reusable If the post process can be reused on the same frame. (default: false)
  53776. * @param textureType Type of textures used when performing the post process. (default: 0)
  53777. * @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)
  53778. */
  53779. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53780. }
  53781. }
  53782. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53783. /** @hidden */
  53784. export var circleOfConfusionPixelShader: {
  53785. name: string;
  53786. shader: string;
  53787. };
  53788. }
  53789. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53790. import { Nullable } from "babylonjs/types";
  53791. import { Engine } from "babylonjs/Engines/engine";
  53792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53793. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53794. import { Camera } from "babylonjs/Cameras/camera";
  53795. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53796. /**
  53797. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53798. */
  53799. export class CircleOfConfusionPostProcess extends PostProcess {
  53800. /**
  53801. * 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.
  53802. */
  53803. lensSize: number;
  53804. /**
  53805. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53806. */
  53807. fStop: number;
  53808. /**
  53809. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53810. */
  53811. focusDistance: number;
  53812. /**
  53813. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53814. */
  53815. focalLength: number;
  53816. private _depthTexture;
  53817. /**
  53818. * Creates a new instance CircleOfConfusionPostProcess
  53819. * @param name The name of the effect.
  53820. * @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.
  53821. * @param options The required width/height ratio to downsize to before computing the render pass.
  53822. * @param camera The camera to apply the render pass to.
  53823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53824. * @param engine The engine which the post process will be applied. (default: current engine)
  53825. * @param reusable If the post process can be reused on the same frame. (default: false)
  53826. * @param textureType Type of textures used when performing the post process. (default: 0)
  53827. * @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)
  53828. */
  53829. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53830. /**
  53831. * 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.
  53832. */
  53833. depthTexture: RenderTargetTexture;
  53834. }
  53835. }
  53836. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53837. /** @hidden */
  53838. export var colorCorrectionPixelShader: {
  53839. name: string;
  53840. shader: string;
  53841. };
  53842. }
  53843. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53845. import { Engine } from "babylonjs/Engines/engine";
  53846. import { Camera } from "babylonjs/Cameras/camera";
  53847. import "babylonjs/Shaders/colorCorrection.fragment";
  53848. /**
  53849. *
  53850. * This post-process allows the modification of rendered colors by using
  53851. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53852. *
  53853. * The object needs to be provided an url to a texture containing the color
  53854. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53855. * Use an image editing software to tweak the LUT to match your needs.
  53856. *
  53857. * For an example of a color LUT, see here:
  53858. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53859. * For explanations on color grading, see here:
  53860. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53861. *
  53862. */
  53863. export class ColorCorrectionPostProcess extends PostProcess {
  53864. private _colorTableTexture;
  53865. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53866. }
  53867. }
  53868. declare module "babylonjs/Shaders/convolution.fragment" {
  53869. /** @hidden */
  53870. export var convolutionPixelShader: {
  53871. name: string;
  53872. shader: string;
  53873. };
  53874. }
  53875. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53877. import { Nullable } from "babylonjs/types";
  53878. import { Camera } from "babylonjs/Cameras/camera";
  53879. import { Engine } from "babylonjs/Engines/engine";
  53880. import "babylonjs/Shaders/convolution.fragment";
  53881. /**
  53882. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53883. * input texture to perform effects such as edge detection or sharpening
  53884. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53885. */
  53886. export class ConvolutionPostProcess extends PostProcess {
  53887. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53888. kernel: number[];
  53889. /**
  53890. * Creates a new instance ConvolutionPostProcess
  53891. * @param name The name of the effect.
  53892. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53893. * @param options The required width/height ratio to downsize to before computing the render pass.
  53894. * @param camera The camera to apply the render pass to.
  53895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53896. * @param engine The engine which the post process will be applied. (default: current engine)
  53897. * @param reusable If the post process can be reused on the same frame. (default: false)
  53898. * @param textureType Type of textures used when performing the post process. (default: 0)
  53899. */
  53900. constructor(name: string,
  53901. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53902. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53903. /**
  53904. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53905. */
  53906. static EdgeDetect0Kernel: number[];
  53907. /**
  53908. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53909. */
  53910. static EdgeDetect1Kernel: number[];
  53911. /**
  53912. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53913. */
  53914. static EdgeDetect2Kernel: number[];
  53915. /**
  53916. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53917. */
  53918. static SharpenKernel: number[];
  53919. /**
  53920. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53921. */
  53922. static EmbossKernel: number[];
  53923. /**
  53924. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53925. */
  53926. static GaussianKernel: number[];
  53927. }
  53928. }
  53929. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53930. import { Nullable } from "babylonjs/types";
  53931. import { Vector2 } from "babylonjs/Maths/math";
  53932. import { Camera } from "babylonjs/Cameras/camera";
  53933. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53934. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53935. import { Engine } from "babylonjs/Engines/engine";
  53936. import { Scene } from "babylonjs/scene";
  53937. /**
  53938. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53939. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53940. * based on samples that have a large difference in distance than the center pixel.
  53941. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53942. */
  53943. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53944. direction: Vector2;
  53945. /**
  53946. * Creates a new instance CircleOfConfusionPostProcess
  53947. * @param name The name of the effect.
  53948. * @param scene The scene the effect belongs to.
  53949. * @param direction The direction the blur should be applied.
  53950. * @param kernel The size of the kernel used to blur.
  53951. * @param options The required width/height ratio to downsize to before computing the render pass.
  53952. * @param camera The camera to apply the render pass to.
  53953. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53954. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53956. * @param engine The engine which the post process will be applied. (default: current engine)
  53957. * @param reusable If the post process can be reused on the same frame. (default: false)
  53958. * @param textureType Type of textures used when performing the post process. (default: 0)
  53959. * @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)
  53960. */
  53961. 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);
  53962. }
  53963. }
  53964. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53965. /** @hidden */
  53966. export var depthOfFieldMergePixelShader: {
  53967. name: string;
  53968. shader: string;
  53969. };
  53970. }
  53971. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53972. import { Nullable } from "babylonjs/types";
  53973. import { Camera } from "babylonjs/Cameras/camera";
  53974. import { Effect } from "babylonjs/Materials/effect";
  53975. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53976. import { Engine } from "babylonjs/Engines/engine";
  53977. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53978. /**
  53979. * Options to be set when merging outputs from the default pipeline.
  53980. */
  53981. export class DepthOfFieldMergePostProcessOptions {
  53982. /**
  53983. * The original image to merge on top of
  53984. */
  53985. originalFromInput: PostProcess;
  53986. /**
  53987. * Parameters to perform the merge of the depth of field effect
  53988. */
  53989. depthOfField?: {
  53990. circleOfConfusion: PostProcess;
  53991. blurSteps: Array<PostProcess>;
  53992. };
  53993. /**
  53994. * Parameters to perform the merge of bloom effect
  53995. */
  53996. bloom?: {
  53997. blurred: PostProcess;
  53998. weight: number;
  53999. };
  54000. }
  54001. /**
  54002. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54003. */
  54004. export class DepthOfFieldMergePostProcess extends PostProcess {
  54005. private blurSteps;
  54006. /**
  54007. * Creates a new instance of DepthOfFieldMergePostProcess
  54008. * @param name The name of the effect.
  54009. * @param originalFromInput Post process which's input will be used for the merge.
  54010. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54011. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54012. * @param options The required width/height ratio to downsize to before computing the render pass.
  54013. * @param camera The camera to apply the render pass to.
  54014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54015. * @param engine The engine which the post process will be applied. (default: current engine)
  54016. * @param reusable If the post process can be reused on the same frame. (default: false)
  54017. * @param textureType Type of textures used when performing the post process. (default: 0)
  54018. * @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)
  54019. */
  54020. 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);
  54021. /**
  54022. * Updates the effect with the current post process compile time values and recompiles the shader.
  54023. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54024. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54025. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54026. * @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
  54027. * @param onCompiled Called when the shader has been compiled.
  54028. * @param onError Called if there is an error when compiling a shader.
  54029. */
  54030. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54031. }
  54032. }
  54033. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54034. import { Nullable } from "babylonjs/types";
  54035. import { Camera } from "babylonjs/Cameras/camera";
  54036. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54037. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54038. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54039. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54040. import { Scene } from "babylonjs/scene";
  54041. /**
  54042. * Specifies the level of max blur that should be applied when using the depth of field effect
  54043. */
  54044. export enum DepthOfFieldEffectBlurLevel {
  54045. /**
  54046. * Subtle blur
  54047. */
  54048. Low = 0,
  54049. /**
  54050. * Medium blur
  54051. */
  54052. Medium = 1,
  54053. /**
  54054. * Large blur
  54055. */
  54056. High = 2
  54057. }
  54058. /**
  54059. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54060. */
  54061. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54062. private _circleOfConfusion;
  54063. /**
  54064. * @hidden Internal, blurs from high to low
  54065. */
  54066. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54067. private _depthOfFieldBlurY;
  54068. private _dofMerge;
  54069. /**
  54070. * @hidden Internal post processes in depth of field effect
  54071. */
  54072. _effects: Array<PostProcess>;
  54073. /**
  54074. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54075. */
  54076. focalLength: number;
  54077. /**
  54078. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54079. */
  54080. fStop: number;
  54081. /**
  54082. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54083. */
  54084. focusDistance: number;
  54085. /**
  54086. * 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.
  54087. */
  54088. lensSize: number;
  54089. /**
  54090. * Creates a new instance DepthOfFieldEffect
  54091. * @param scene The scene the effect belongs to.
  54092. * @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.
  54093. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54094. * @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)
  54095. */
  54096. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54097. /**
  54098. * 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.
  54099. */
  54100. depthTexture: RenderTargetTexture;
  54101. /**
  54102. * Disposes each of the internal effects for a given camera.
  54103. * @param camera The camera to dispose the effect on.
  54104. */
  54105. disposeEffects(camera: Camera): void;
  54106. /**
  54107. * @hidden Internal
  54108. */
  54109. _updateEffects(): void;
  54110. /**
  54111. * Internal
  54112. * @returns if all the contained post processes are ready.
  54113. * @hidden
  54114. */
  54115. _isReady(): boolean;
  54116. }
  54117. }
  54118. declare module "babylonjs/Shaders/displayPass.fragment" {
  54119. /** @hidden */
  54120. export var displayPassPixelShader: {
  54121. name: string;
  54122. shader: string;
  54123. };
  54124. }
  54125. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54126. import { Nullable } from "babylonjs/types";
  54127. import { Camera } from "babylonjs/Cameras/camera";
  54128. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54129. import { Engine } from "babylonjs/Engines/engine";
  54130. import "babylonjs/Shaders/displayPass.fragment";
  54131. /**
  54132. * DisplayPassPostProcess which produces an output the same as it's input
  54133. */
  54134. export class DisplayPassPostProcess extends PostProcess {
  54135. /**
  54136. * Creates the DisplayPassPostProcess
  54137. * @param name The name of the effect.
  54138. * @param options The required width/height ratio to downsize to before computing the render pass.
  54139. * @param camera The camera to apply the render pass to.
  54140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54141. * @param engine The engine which the post process will be applied. (default: current engine)
  54142. * @param reusable If the post process can be reused on the same frame. (default: false)
  54143. */
  54144. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54145. }
  54146. }
  54147. declare module "babylonjs/Shaders/filter.fragment" {
  54148. /** @hidden */
  54149. export var filterPixelShader: {
  54150. name: string;
  54151. shader: string;
  54152. };
  54153. }
  54154. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54155. import { Nullable } from "babylonjs/types";
  54156. import { Matrix } from "babylonjs/Maths/math";
  54157. import { Camera } from "babylonjs/Cameras/camera";
  54158. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54159. import { Engine } from "babylonjs/Engines/engine";
  54160. import "babylonjs/Shaders/filter.fragment";
  54161. /**
  54162. * Applies a kernel filter to the image
  54163. */
  54164. export class FilterPostProcess extends PostProcess {
  54165. /** The matrix to be applied to the image */
  54166. kernelMatrix: Matrix;
  54167. /**
  54168. *
  54169. * @param name The name of the effect.
  54170. * @param kernelMatrix The matrix to be applied to the image
  54171. * @param options The required width/height ratio to downsize to before computing the render pass.
  54172. * @param camera The camera to apply the render pass to.
  54173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54174. * @param engine The engine which the post process will be applied. (default: current engine)
  54175. * @param reusable If the post process can be reused on the same frame. (default: false)
  54176. */
  54177. constructor(name: string,
  54178. /** The matrix to be applied to the image */
  54179. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54180. }
  54181. }
  54182. declare module "babylonjs/Shaders/fxaa.fragment" {
  54183. /** @hidden */
  54184. export var fxaaPixelShader: {
  54185. name: string;
  54186. shader: string;
  54187. };
  54188. }
  54189. declare module "babylonjs/Shaders/fxaa.vertex" {
  54190. /** @hidden */
  54191. export var fxaaVertexShader: {
  54192. name: string;
  54193. shader: string;
  54194. };
  54195. }
  54196. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54197. import { Nullable } from "babylonjs/types";
  54198. import { Camera } from "babylonjs/Cameras/camera";
  54199. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54200. import { Engine } from "babylonjs/Engines/engine";
  54201. import "babylonjs/Shaders/fxaa.fragment";
  54202. import "babylonjs/Shaders/fxaa.vertex";
  54203. /**
  54204. * Fxaa post process
  54205. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54206. */
  54207. export class FxaaPostProcess extends PostProcess {
  54208. /** @hidden */
  54209. texelWidth: number;
  54210. /** @hidden */
  54211. texelHeight: number;
  54212. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54213. private _getDefines;
  54214. }
  54215. }
  54216. declare module "babylonjs/Shaders/grain.fragment" {
  54217. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54218. /** @hidden */
  54219. export var grainPixelShader: {
  54220. name: string;
  54221. shader: string;
  54222. };
  54223. }
  54224. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54225. import { Nullable } from "babylonjs/types";
  54226. import { Camera } from "babylonjs/Cameras/camera";
  54227. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54228. import { Engine } from "babylonjs/Engines/engine";
  54229. import "babylonjs/Shaders/grain.fragment";
  54230. /**
  54231. * The GrainPostProcess adds noise to the image at mid luminance levels
  54232. */
  54233. export class GrainPostProcess extends PostProcess {
  54234. /**
  54235. * The intensity of the grain added (default: 30)
  54236. */
  54237. intensity: number;
  54238. /**
  54239. * If the grain should be randomized on every frame
  54240. */
  54241. animated: boolean;
  54242. /**
  54243. * Creates a new instance of @see GrainPostProcess
  54244. * @param name The name of the effect.
  54245. * @param options The required width/height ratio to downsize to before computing the render pass.
  54246. * @param camera The camera to apply the render pass to.
  54247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54248. * @param engine The engine which the post process will be applied. (default: current engine)
  54249. * @param reusable If the post process can be reused on the same frame. (default: false)
  54250. * @param textureType Type of textures used when performing the post process. (default: 0)
  54251. * @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)
  54252. */
  54253. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54254. }
  54255. }
  54256. declare module "babylonjs/Shaders/highlights.fragment" {
  54257. /** @hidden */
  54258. export var highlightsPixelShader: {
  54259. name: string;
  54260. shader: string;
  54261. };
  54262. }
  54263. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54264. import { Nullable } from "babylonjs/types";
  54265. import { Camera } from "babylonjs/Cameras/camera";
  54266. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54267. import { Engine } from "babylonjs/Engines/engine";
  54268. import "babylonjs/Shaders/highlights.fragment";
  54269. /**
  54270. * Extracts highlights from the image
  54271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54272. */
  54273. export class HighlightsPostProcess extends PostProcess {
  54274. /**
  54275. * Extracts highlights from the image
  54276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54277. * @param name The name of the effect.
  54278. * @param options The required width/height ratio to downsize to before computing the render pass.
  54279. * @param camera The camera to apply the render pass to.
  54280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54281. * @param engine The engine which the post process will be applied. (default: current engine)
  54282. * @param reusable If the post process can be reused on the same frame. (default: false)
  54283. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54284. */
  54285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54286. }
  54287. }
  54288. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54289. /** @hidden */
  54290. export var mrtFragmentDeclaration: {
  54291. name: string;
  54292. shader: string;
  54293. };
  54294. }
  54295. declare module "babylonjs/Shaders/geometry.fragment" {
  54296. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54297. /** @hidden */
  54298. export var geometryPixelShader: {
  54299. name: string;
  54300. shader: string;
  54301. };
  54302. }
  54303. declare module "babylonjs/Shaders/geometry.vertex" {
  54304. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54305. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54306. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54307. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54308. /** @hidden */
  54309. export var geometryVertexShader: {
  54310. name: string;
  54311. shader: string;
  54312. };
  54313. }
  54314. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54315. import { Matrix } from "babylonjs/Maths/math";
  54316. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54317. import { Mesh } from "babylonjs/Meshes/mesh";
  54318. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54319. import { Effect } from "babylonjs/Materials/effect";
  54320. import { Scene } from "babylonjs/scene";
  54321. import "babylonjs/Shaders/geometry.fragment";
  54322. import "babylonjs/Shaders/geometry.vertex";
  54323. /**
  54324. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54325. */
  54326. export class GeometryBufferRenderer {
  54327. /**
  54328. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54329. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54330. */
  54331. static readonly POSITION_TEXTURE_TYPE: number;
  54332. /**
  54333. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54334. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54335. */
  54336. static readonly VELOCITY_TEXTURE_TYPE: number;
  54337. /**
  54338. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54339. * in order to compute objects velocities when enableVelocity is set to "true"
  54340. * @hidden
  54341. */
  54342. _previousTransformationMatrices: {
  54343. [index: number]: Matrix;
  54344. };
  54345. private _scene;
  54346. private _multiRenderTarget;
  54347. private _ratio;
  54348. private _enablePosition;
  54349. private _enableVelocity;
  54350. private _positionIndex;
  54351. private _velocityIndex;
  54352. protected _effect: Effect;
  54353. protected _cachedDefines: string;
  54354. /**
  54355. * Set the render list (meshes to be rendered) used in the G buffer.
  54356. */
  54357. renderList: Mesh[];
  54358. /**
  54359. * Gets wether or not G buffer are supported by the running hardware.
  54360. * This requires draw buffer supports
  54361. */
  54362. readonly isSupported: boolean;
  54363. /**
  54364. * Returns the index of the given texture type in the G-Buffer textures array
  54365. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54366. * @returns the index of the given texture type in the G-Buffer textures array
  54367. */
  54368. getTextureIndex(textureType: number): number;
  54369. /**
  54370. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54371. */
  54372. /**
  54373. * Sets whether or not objects positions are enabled for the G buffer.
  54374. */
  54375. enablePosition: boolean;
  54376. /**
  54377. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54378. */
  54379. /**
  54380. * Sets wether or not objects velocities are enabled for the G buffer.
  54381. */
  54382. enableVelocity: boolean;
  54383. /**
  54384. * Gets the scene associated with the buffer.
  54385. */
  54386. readonly scene: Scene;
  54387. /**
  54388. * Gets the ratio used by the buffer during its creation.
  54389. * How big is the buffer related to the main canvas.
  54390. */
  54391. readonly ratio: number;
  54392. /** @hidden */
  54393. static _SceneComponentInitialization: (scene: Scene) => void;
  54394. /**
  54395. * Creates a new G Buffer for the scene
  54396. * @param scene The scene the buffer belongs to
  54397. * @param ratio How big is the buffer related to the main canvas.
  54398. */
  54399. constructor(scene: Scene, ratio?: number);
  54400. /**
  54401. * Checks wether everything is ready to render a submesh to the G buffer.
  54402. * @param subMesh the submesh to check readiness for
  54403. * @param useInstances is the mesh drawn using instance or not
  54404. * @returns true if ready otherwise false
  54405. */
  54406. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54407. /**
  54408. * Gets the current underlying G Buffer.
  54409. * @returns the buffer
  54410. */
  54411. getGBuffer(): MultiRenderTarget;
  54412. /**
  54413. * Gets the number of samples used to render the buffer (anti aliasing).
  54414. */
  54415. /**
  54416. * Sets the number of samples used to render the buffer (anti aliasing).
  54417. */
  54418. samples: number;
  54419. /**
  54420. * Disposes the renderer and frees up associated resources.
  54421. */
  54422. dispose(): void;
  54423. protected _createRenderTargets(): void;
  54424. }
  54425. }
  54426. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54427. import { Nullable } from "babylonjs/types";
  54428. import { Scene } from "babylonjs/scene";
  54429. import { ISceneComponent } from "babylonjs/sceneComponent";
  54430. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54431. module "babylonjs/scene" {
  54432. interface Scene {
  54433. /** @hidden (Backing field) */
  54434. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54435. /**
  54436. * Gets or Sets the current geometry buffer associated to the scene.
  54437. */
  54438. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54439. /**
  54440. * Enables a GeometryBufferRender and associates it with the scene
  54441. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54442. * @returns the GeometryBufferRenderer
  54443. */
  54444. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54445. /**
  54446. * Disables the GeometryBufferRender associated with the scene
  54447. */
  54448. disableGeometryBufferRenderer(): void;
  54449. }
  54450. }
  54451. /**
  54452. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54453. * in several rendering techniques.
  54454. */
  54455. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54456. /**
  54457. * The component name helpful to identify the component in the list of scene components.
  54458. */
  54459. readonly name: string;
  54460. /**
  54461. * The scene the component belongs to.
  54462. */
  54463. scene: Scene;
  54464. /**
  54465. * Creates a new instance of the component for the given scene
  54466. * @param scene Defines the scene to register the component in
  54467. */
  54468. constructor(scene: Scene);
  54469. /**
  54470. * Registers the component in a given scene
  54471. */
  54472. register(): void;
  54473. /**
  54474. * Rebuilds the elements related to this component in case of
  54475. * context lost for instance.
  54476. */
  54477. rebuild(): void;
  54478. /**
  54479. * Disposes the component and the associated ressources
  54480. */
  54481. dispose(): void;
  54482. private _gatherRenderTargets;
  54483. }
  54484. }
  54485. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54486. /** @hidden */
  54487. export var motionBlurPixelShader: {
  54488. name: string;
  54489. shader: string;
  54490. };
  54491. }
  54492. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54493. import { Nullable } from "babylonjs/types";
  54494. import { Camera } from "babylonjs/Cameras/camera";
  54495. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54496. import { Scene } from "babylonjs/scene";
  54497. import "babylonjs/Animations/animatable";
  54498. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54499. import "babylonjs/Shaders/motionBlur.fragment";
  54500. import { Engine } from "babylonjs/Engines/engine";
  54501. /**
  54502. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54503. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54504. * As an example, all you have to do is to create the post-process:
  54505. * var mb = new BABYLON.MotionBlurPostProcess(
  54506. * 'mb', // The name of the effect.
  54507. * scene, // The scene containing the objects to blur according to their velocity.
  54508. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54509. * camera // The camera to apply the render pass to.
  54510. * );
  54511. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54512. */
  54513. export class MotionBlurPostProcess extends PostProcess {
  54514. /**
  54515. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54516. */
  54517. motionStrength: number;
  54518. /**
  54519. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54520. */
  54521. /**
  54522. * Sets the number of iterations to be used for motion blur quality
  54523. */
  54524. motionBlurSamples: number;
  54525. private _motionBlurSamples;
  54526. private _geometryBufferRenderer;
  54527. /**
  54528. * Creates a new instance MotionBlurPostProcess
  54529. * @param name The name of the effect.
  54530. * @param scene The scene containing the objects to blur according to their velocity.
  54531. * @param options The required width/height ratio to downsize to before computing the render pass.
  54532. * @param camera The camera to apply the render pass to.
  54533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54534. * @param engine The engine which the post process will be applied. (default: current engine)
  54535. * @param reusable If the post process can be reused on the same frame. (default: false)
  54536. * @param textureType Type of textures used when performing the post process. (default: 0)
  54537. * @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)
  54538. */
  54539. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54540. /**
  54541. * Disposes the post process.
  54542. * @param camera The camera to dispose the post process on.
  54543. */
  54544. dispose(camera?: Camera): void;
  54545. }
  54546. }
  54547. declare module "babylonjs/Shaders/refraction.fragment" {
  54548. /** @hidden */
  54549. export var refractionPixelShader: {
  54550. name: string;
  54551. shader: string;
  54552. };
  54553. }
  54554. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54555. import { Color3 } from "babylonjs/Maths/math";
  54556. import { Camera } from "babylonjs/Cameras/camera";
  54557. import { Texture } from "babylonjs/Materials/Textures/texture";
  54558. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54559. import { Engine } from "babylonjs/Engines/engine";
  54560. import "babylonjs/Shaders/refraction.fragment";
  54561. /**
  54562. * Post process which applies a refractin texture
  54563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54564. */
  54565. export class RefractionPostProcess extends PostProcess {
  54566. /** the base color of the refraction (used to taint the rendering) */
  54567. color: Color3;
  54568. /** simulated refraction depth */
  54569. depth: number;
  54570. /** the coefficient of the base color (0 to remove base color tainting) */
  54571. colorLevel: number;
  54572. private _refTexture;
  54573. private _ownRefractionTexture;
  54574. /**
  54575. * Gets or sets the refraction texture
  54576. * Please note that you are responsible for disposing the texture if you set it manually
  54577. */
  54578. refractionTexture: Texture;
  54579. /**
  54580. * Initializes the RefractionPostProcess
  54581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54582. * @param name The name of the effect.
  54583. * @param refractionTextureUrl Url of the refraction texture to use
  54584. * @param color the base color of the refraction (used to taint the rendering)
  54585. * @param depth simulated refraction depth
  54586. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54587. * @param camera The camera to apply the render pass to.
  54588. * @param options The required width/height ratio to downsize to before computing the render pass.
  54589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54590. * @param engine The engine which the post process will be applied. (default: current engine)
  54591. * @param reusable If the post process can be reused on the same frame. (default: false)
  54592. */
  54593. constructor(name: string, refractionTextureUrl: string,
  54594. /** the base color of the refraction (used to taint the rendering) */
  54595. color: Color3,
  54596. /** simulated refraction depth */
  54597. depth: number,
  54598. /** the coefficient of the base color (0 to remove base color tainting) */
  54599. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54600. /**
  54601. * Disposes of the post process
  54602. * @param camera Camera to dispose post process on
  54603. */
  54604. dispose(camera: Camera): void;
  54605. }
  54606. }
  54607. declare module "babylonjs/Shaders/sharpen.fragment" {
  54608. /** @hidden */
  54609. export var sharpenPixelShader: {
  54610. name: string;
  54611. shader: string;
  54612. };
  54613. }
  54614. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54615. import { Nullable } from "babylonjs/types";
  54616. import { Camera } from "babylonjs/Cameras/camera";
  54617. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54618. import "babylonjs/Shaders/sharpen.fragment";
  54619. import { Engine } from "babylonjs/Engines/engine";
  54620. /**
  54621. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54622. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54623. */
  54624. export class SharpenPostProcess extends PostProcess {
  54625. /**
  54626. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54627. */
  54628. colorAmount: number;
  54629. /**
  54630. * How much sharpness should be applied (default: 0.3)
  54631. */
  54632. edgeAmount: number;
  54633. /**
  54634. * Creates a new instance ConvolutionPostProcess
  54635. * @param name The name of the effect.
  54636. * @param options The required width/height ratio to downsize to before computing the render pass.
  54637. * @param camera The camera to apply the render pass to.
  54638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54639. * @param engine The engine which the post process will be applied. (default: current engine)
  54640. * @param reusable If the post process can be reused on the same frame. (default: false)
  54641. * @param textureType Type of textures used when performing the post process. (default: 0)
  54642. * @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)
  54643. */
  54644. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54645. }
  54646. }
  54647. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  54648. import { Nullable } from "babylonjs/types";
  54649. import { Camera } from "babylonjs/Cameras/camera";
  54650. import { Engine } from "babylonjs/Engines/engine";
  54651. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54652. import { IInspectable } from "babylonjs/Misc/iInspectable";
  54653. /**
  54654. * PostProcessRenderPipeline
  54655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54656. */
  54657. export class PostProcessRenderPipeline {
  54658. private engine;
  54659. private _renderEffects;
  54660. private _renderEffectsForIsolatedPass;
  54661. /**
  54662. * List of inspectable custom properties (used by the Inspector)
  54663. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54664. */
  54665. inspectableCustomProperties: IInspectable[];
  54666. /**
  54667. * @hidden
  54668. */
  54669. protected _cameras: Camera[];
  54670. /** @hidden */
  54671. _name: string;
  54672. /**
  54673. * Gets pipeline name
  54674. */
  54675. readonly name: string;
  54676. /**
  54677. * Initializes a PostProcessRenderPipeline
  54678. * @param engine engine to add the pipeline to
  54679. * @param name name of the pipeline
  54680. */
  54681. constructor(engine: Engine, name: string);
  54682. /**
  54683. * Gets the class name
  54684. * @returns "PostProcessRenderPipeline"
  54685. */
  54686. getClassName(): string;
  54687. /**
  54688. * If all the render effects in the pipeline are supported
  54689. */
  54690. readonly isSupported: boolean;
  54691. /**
  54692. * Adds an effect to the pipeline
  54693. * @param renderEffect the effect to add
  54694. */
  54695. addEffect(renderEffect: PostProcessRenderEffect): void;
  54696. /** @hidden */
  54697. _rebuild(): void;
  54698. /** @hidden */
  54699. _enableEffect(renderEffectName: string, cameras: Camera): void;
  54700. /** @hidden */
  54701. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54702. /** @hidden */
  54703. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54704. /** @hidden */
  54705. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54706. /** @hidden */
  54707. _attachCameras(cameras: Camera, unique: boolean): void;
  54708. /** @hidden */
  54709. _attachCameras(cameras: Camera[], unique: boolean): void;
  54710. /** @hidden */
  54711. _detachCameras(cameras: Camera): void;
  54712. /** @hidden */
  54713. _detachCameras(cameras: Nullable<Camera[]>): void;
  54714. /** @hidden */
  54715. _update(): void;
  54716. /** @hidden */
  54717. _reset(): void;
  54718. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54719. /**
  54720. * Disposes of the pipeline
  54721. */
  54722. dispose(): void;
  54723. }
  54724. }
  54725. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54726. import { Camera } from "babylonjs/Cameras/camera";
  54727. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54728. /**
  54729. * PostProcessRenderPipelineManager class
  54730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54731. */
  54732. export class PostProcessRenderPipelineManager {
  54733. private _renderPipelines;
  54734. /**
  54735. * Initializes a PostProcessRenderPipelineManager
  54736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54737. */
  54738. constructor();
  54739. /**
  54740. * Gets the list of supported render pipelines
  54741. */
  54742. readonly supportedPipelines: PostProcessRenderPipeline[];
  54743. /**
  54744. * Adds a pipeline to the manager
  54745. * @param renderPipeline The pipeline to add
  54746. */
  54747. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54748. /**
  54749. * Attaches a camera to the pipeline
  54750. * @param renderPipelineName The name of the pipeline to attach to
  54751. * @param cameras the camera to attach
  54752. * @param unique if the camera can be attached multiple times to the pipeline
  54753. */
  54754. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54755. /**
  54756. * Detaches a camera from the pipeline
  54757. * @param renderPipelineName The name of the pipeline to detach from
  54758. * @param cameras the camera to detach
  54759. */
  54760. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54761. /**
  54762. * Enables an effect by name on a pipeline
  54763. * @param renderPipelineName the name of the pipeline to enable the effect in
  54764. * @param renderEffectName the name of the effect to enable
  54765. * @param cameras the cameras that the effect should be enabled on
  54766. */
  54767. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54768. /**
  54769. * Disables an effect by name on a pipeline
  54770. * @param renderPipelineName the name of the pipeline to disable the effect in
  54771. * @param renderEffectName the name of the effect to disable
  54772. * @param cameras the cameras that the effect should be disabled on
  54773. */
  54774. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54775. /**
  54776. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54777. */
  54778. update(): void;
  54779. /** @hidden */
  54780. _rebuild(): void;
  54781. /**
  54782. * Disposes of the manager and pipelines
  54783. */
  54784. dispose(): void;
  54785. }
  54786. }
  54787. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54788. import { ISceneComponent } from "babylonjs/sceneComponent";
  54789. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54790. import { Scene } from "babylonjs/scene";
  54791. module "babylonjs/scene" {
  54792. interface Scene {
  54793. /** @hidden (Backing field) */
  54794. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54795. /**
  54796. * Gets the postprocess render pipeline manager
  54797. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54798. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54799. */
  54800. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54801. }
  54802. }
  54803. /**
  54804. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54805. */
  54806. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54807. /**
  54808. * The component name helpfull to identify the component in the list of scene components.
  54809. */
  54810. readonly name: string;
  54811. /**
  54812. * The scene the component belongs to.
  54813. */
  54814. scene: Scene;
  54815. /**
  54816. * Creates a new instance of the component for the given scene
  54817. * @param scene Defines the scene to register the component in
  54818. */
  54819. constructor(scene: Scene);
  54820. /**
  54821. * Registers the component in a given scene
  54822. */
  54823. register(): void;
  54824. /**
  54825. * Rebuilds the elements related to this component in case of
  54826. * context lost for instance.
  54827. */
  54828. rebuild(): void;
  54829. /**
  54830. * Disposes the component and the associated ressources
  54831. */
  54832. dispose(): void;
  54833. private _gatherRenderTargets;
  54834. }
  54835. }
  54836. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54837. import { IAnimatable } from "babylonjs/Misc/tools";
  54838. import { Camera } from "babylonjs/Cameras/camera";
  54839. import { IDisposable } from "babylonjs/scene";
  54840. import { Scene } from "babylonjs/scene";
  54841. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54842. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54843. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54844. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54845. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54846. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54847. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54848. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54849. import { Animation } from "babylonjs/Animations/animation";
  54850. /**
  54851. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54852. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54853. */
  54854. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54855. private _scene;
  54856. private _camerasToBeAttached;
  54857. /**
  54858. * ID of the sharpen post process,
  54859. */
  54860. private readonly SharpenPostProcessId;
  54861. /**
  54862. * @ignore
  54863. * ID of the image processing post process;
  54864. */
  54865. readonly ImageProcessingPostProcessId: string;
  54866. /**
  54867. * @ignore
  54868. * ID of the Fast Approximate Anti-Aliasing post process;
  54869. */
  54870. readonly FxaaPostProcessId: string;
  54871. /**
  54872. * ID of the chromatic aberration post process,
  54873. */
  54874. private readonly ChromaticAberrationPostProcessId;
  54875. /**
  54876. * ID of the grain post process
  54877. */
  54878. private readonly GrainPostProcessId;
  54879. /**
  54880. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54881. */
  54882. sharpen: SharpenPostProcess;
  54883. private _sharpenEffect;
  54884. private bloom;
  54885. /**
  54886. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54887. */
  54888. depthOfField: DepthOfFieldEffect;
  54889. /**
  54890. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54891. */
  54892. fxaa: FxaaPostProcess;
  54893. /**
  54894. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54895. */
  54896. imageProcessing: ImageProcessingPostProcess;
  54897. /**
  54898. * Chromatic aberration post process which will shift rgb colors in the image
  54899. */
  54900. chromaticAberration: ChromaticAberrationPostProcess;
  54901. private _chromaticAberrationEffect;
  54902. /**
  54903. * Grain post process which add noise to the image
  54904. */
  54905. grain: GrainPostProcess;
  54906. private _grainEffect;
  54907. /**
  54908. * Glow post process which adds a glow to emissive areas of the image
  54909. */
  54910. private _glowLayer;
  54911. /**
  54912. * Animations which can be used to tweak settings over a period of time
  54913. */
  54914. animations: Animation[];
  54915. private _imageProcessingConfigurationObserver;
  54916. private _sharpenEnabled;
  54917. private _bloomEnabled;
  54918. private _depthOfFieldEnabled;
  54919. private _depthOfFieldBlurLevel;
  54920. private _fxaaEnabled;
  54921. private _imageProcessingEnabled;
  54922. private _defaultPipelineTextureType;
  54923. private _bloomScale;
  54924. private _chromaticAberrationEnabled;
  54925. private _grainEnabled;
  54926. private _buildAllowed;
  54927. /**
  54928. * Gets active scene
  54929. */
  54930. readonly scene: Scene;
  54931. /**
  54932. * Enable or disable the sharpen process from the pipeline
  54933. */
  54934. sharpenEnabled: boolean;
  54935. private _resizeObserver;
  54936. private _hardwareScaleLevel;
  54937. private _bloomKernel;
  54938. /**
  54939. * Specifies the size of the bloom blur kernel, relative to the final output size
  54940. */
  54941. bloomKernel: number;
  54942. /**
  54943. * Specifies the weight of the bloom in the final rendering
  54944. */
  54945. private _bloomWeight;
  54946. /**
  54947. * Specifies the luma threshold for the area that will be blurred by the bloom
  54948. */
  54949. private _bloomThreshold;
  54950. private _hdr;
  54951. /**
  54952. * The strength of the bloom.
  54953. */
  54954. bloomWeight: number;
  54955. /**
  54956. * The strength of the bloom.
  54957. */
  54958. bloomThreshold: number;
  54959. /**
  54960. * The scale of the bloom, lower value will provide better performance.
  54961. */
  54962. bloomScale: number;
  54963. /**
  54964. * Enable or disable the bloom from the pipeline
  54965. */
  54966. bloomEnabled: boolean;
  54967. private _rebuildBloom;
  54968. /**
  54969. * If the depth of field is enabled.
  54970. */
  54971. depthOfFieldEnabled: boolean;
  54972. /**
  54973. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54974. */
  54975. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54976. /**
  54977. * If the anti aliasing is enabled.
  54978. */
  54979. fxaaEnabled: boolean;
  54980. private _samples;
  54981. /**
  54982. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54983. */
  54984. samples: number;
  54985. /**
  54986. * If image processing is enabled.
  54987. */
  54988. imageProcessingEnabled: boolean;
  54989. /**
  54990. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54991. */
  54992. glowLayerEnabled: boolean;
  54993. /**
  54994. * Enable or disable the chromaticAberration process from the pipeline
  54995. */
  54996. chromaticAberrationEnabled: boolean;
  54997. /**
  54998. * Enable or disable the grain process from the pipeline
  54999. */
  55000. grainEnabled: boolean;
  55001. /**
  55002. * @constructor
  55003. * @param name - The rendering pipeline name (default: "")
  55004. * @param hdr - If high dynamic range textures should be used (default: true)
  55005. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55006. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55007. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55008. */
  55009. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55010. /**
  55011. * Get the class name
  55012. * @returns "DefaultRenderingPipeline"
  55013. */
  55014. getClassName(): string;
  55015. /**
  55016. * Force the compilation of the entire pipeline.
  55017. */
  55018. prepare(): void;
  55019. private _hasCleared;
  55020. private _prevPostProcess;
  55021. private _prevPrevPostProcess;
  55022. private _setAutoClearAndTextureSharing;
  55023. private _depthOfFieldSceneObserver;
  55024. private _buildPipeline;
  55025. private _disposePostProcesses;
  55026. /**
  55027. * Adds a camera to the pipeline
  55028. * @param camera the camera to be added
  55029. */
  55030. addCamera(camera: Camera): void;
  55031. /**
  55032. * Removes a camera from the pipeline
  55033. * @param camera the camera to remove
  55034. */
  55035. removeCamera(camera: Camera): void;
  55036. /**
  55037. * Dispose of the pipeline and stop all post processes
  55038. */
  55039. dispose(): void;
  55040. /**
  55041. * Serialize the rendering pipeline (Used when exporting)
  55042. * @returns the serialized object
  55043. */
  55044. serialize(): any;
  55045. /**
  55046. * Parse the serialized pipeline
  55047. * @param source Source pipeline.
  55048. * @param scene The scene to load the pipeline to.
  55049. * @param rootUrl The URL of the serialized pipeline.
  55050. * @returns An instantiated pipeline from the serialized object.
  55051. */
  55052. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55053. }
  55054. }
  55055. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55056. /** @hidden */
  55057. export var lensHighlightsPixelShader: {
  55058. name: string;
  55059. shader: string;
  55060. };
  55061. }
  55062. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55063. /** @hidden */
  55064. export var depthOfFieldPixelShader: {
  55065. name: string;
  55066. shader: string;
  55067. };
  55068. }
  55069. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55070. import { Camera } from "babylonjs/Cameras/camera";
  55071. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55072. import { Scene } from "babylonjs/scene";
  55073. import "babylonjs/Shaders/chromaticAberration.fragment";
  55074. import "babylonjs/Shaders/lensHighlights.fragment";
  55075. import "babylonjs/Shaders/depthOfField.fragment";
  55076. /**
  55077. * BABYLON.JS Chromatic Aberration GLSL Shader
  55078. * Author: Olivier Guyot
  55079. * Separates very slightly R, G and B colors on the edges of the screen
  55080. * Inspired by Francois Tarlier & Martins Upitis
  55081. */
  55082. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55083. /**
  55084. * @ignore
  55085. * The chromatic aberration PostProcess id in the pipeline
  55086. */
  55087. LensChromaticAberrationEffect: string;
  55088. /**
  55089. * @ignore
  55090. * The highlights enhancing PostProcess id in the pipeline
  55091. */
  55092. HighlightsEnhancingEffect: string;
  55093. /**
  55094. * @ignore
  55095. * The depth-of-field PostProcess id in the pipeline
  55096. */
  55097. LensDepthOfFieldEffect: string;
  55098. private _scene;
  55099. private _depthTexture;
  55100. private _grainTexture;
  55101. private _chromaticAberrationPostProcess;
  55102. private _highlightsPostProcess;
  55103. private _depthOfFieldPostProcess;
  55104. private _edgeBlur;
  55105. private _grainAmount;
  55106. private _chromaticAberration;
  55107. private _distortion;
  55108. private _highlightsGain;
  55109. private _highlightsThreshold;
  55110. private _dofDistance;
  55111. private _dofAperture;
  55112. private _dofDarken;
  55113. private _dofPentagon;
  55114. private _blurNoise;
  55115. /**
  55116. * @constructor
  55117. *
  55118. * Effect parameters are as follow:
  55119. * {
  55120. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55121. * edge_blur: number; // from 0 to x (1 for realism)
  55122. * distortion: number; // from 0 to x (1 for realism)
  55123. * grain_amount: number; // from 0 to 1
  55124. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55125. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55126. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55127. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55128. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55129. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55130. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55131. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55132. * }
  55133. * Note: if an effect parameter is unset, effect is disabled
  55134. *
  55135. * @param name The rendering pipeline name
  55136. * @param parameters - An object containing all parameters (see above)
  55137. * @param scene The scene linked to this pipeline
  55138. * @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)
  55139. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55140. */
  55141. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55142. /**
  55143. * Get the class name
  55144. * @returns "LensRenderingPipeline"
  55145. */
  55146. getClassName(): string;
  55147. /**
  55148. * Gets associated scene
  55149. */
  55150. readonly scene: Scene;
  55151. /**
  55152. * Gets or sets the edge blur
  55153. */
  55154. edgeBlur: number;
  55155. /**
  55156. * Gets or sets the grain amount
  55157. */
  55158. grainAmount: number;
  55159. /**
  55160. * Gets or sets the chromatic aberration amount
  55161. */
  55162. chromaticAberration: number;
  55163. /**
  55164. * Gets or sets the depth of field aperture
  55165. */
  55166. dofAperture: number;
  55167. /**
  55168. * Gets or sets the edge distortion
  55169. */
  55170. edgeDistortion: number;
  55171. /**
  55172. * Gets or sets the depth of field distortion
  55173. */
  55174. dofDistortion: number;
  55175. /**
  55176. * Gets or sets the darken out of focus amount
  55177. */
  55178. darkenOutOfFocus: number;
  55179. /**
  55180. * Gets or sets a boolean indicating if blur noise is enabled
  55181. */
  55182. blurNoise: boolean;
  55183. /**
  55184. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55185. */
  55186. pentagonBokeh: boolean;
  55187. /**
  55188. * Gets or sets the highlight grain amount
  55189. */
  55190. highlightsGain: number;
  55191. /**
  55192. * Gets or sets the highlight threshold
  55193. */
  55194. highlightsThreshold: number;
  55195. /**
  55196. * Sets the amount of blur at the edges
  55197. * @param amount blur amount
  55198. */
  55199. setEdgeBlur(amount: number): void;
  55200. /**
  55201. * Sets edge blur to 0
  55202. */
  55203. disableEdgeBlur(): void;
  55204. /**
  55205. * Sets the amout of grain
  55206. * @param amount Amount of grain
  55207. */
  55208. setGrainAmount(amount: number): void;
  55209. /**
  55210. * Set grain amount to 0
  55211. */
  55212. disableGrain(): void;
  55213. /**
  55214. * Sets the chromatic aberration amount
  55215. * @param amount amount of chromatic aberration
  55216. */
  55217. setChromaticAberration(amount: number): void;
  55218. /**
  55219. * Sets chromatic aberration amount to 0
  55220. */
  55221. disableChromaticAberration(): void;
  55222. /**
  55223. * Sets the EdgeDistortion amount
  55224. * @param amount amount of EdgeDistortion
  55225. */
  55226. setEdgeDistortion(amount: number): void;
  55227. /**
  55228. * Sets edge distortion to 0
  55229. */
  55230. disableEdgeDistortion(): void;
  55231. /**
  55232. * Sets the FocusDistance amount
  55233. * @param amount amount of FocusDistance
  55234. */
  55235. setFocusDistance(amount: number): void;
  55236. /**
  55237. * Disables depth of field
  55238. */
  55239. disableDepthOfField(): void;
  55240. /**
  55241. * Sets the Aperture amount
  55242. * @param amount amount of Aperture
  55243. */
  55244. setAperture(amount: number): void;
  55245. /**
  55246. * Sets the DarkenOutOfFocus amount
  55247. * @param amount amount of DarkenOutOfFocus
  55248. */
  55249. setDarkenOutOfFocus(amount: number): void;
  55250. private _pentagonBokehIsEnabled;
  55251. /**
  55252. * Creates a pentagon bokeh effect
  55253. */
  55254. enablePentagonBokeh(): void;
  55255. /**
  55256. * Disables the pentagon bokeh effect
  55257. */
  55258. disablePentagonBokeh(): void;
  55259. /**
  55260. * Enables noise blur
  55261. */
  55262. enableNoiseBlur(): void;
  55263. /**
  55264. * Disables noise blur
  55265. */
  55266. disableNoiseBlur(): void;
  55267. /**
  55268. * Sets the HighlightsGain amount
  55269. * @param amount amount of HighlightsGain
  55270. */
  55271. setHighlightsGain(amount: number): void;
  55272. /**
  55273. * Sets the HighlightsThreshold amount
  55274. * @param amount amount of HighlightsThreshold
  55275. */
  55276. setHighlightsThreshold(amount: number): void;
  55277. /**
  55278. * Disables highlights
  55279. */
  55280. disableHighlights(): void;
  55281. /**
  55282. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55283. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55284. */
  55285. dispose(disableDepthRender?: boolean): void;
  55286. private _createChromaticAberrationPostProcess;
  55287. private _createHighlightsPostProcess;
  55288. private _createDepthOfFieldPostProcess;
  55289. private _createGrainTexture;
  55290. }
  55291. }
  55292. declare module "babylonjs/Shaders/ssao2.fragment" {
  55293. /** @hidden */
  55294. export var ssao2PixelShader: {
  55295. name: string;
  55296. shader: string;
  55297. };
  55298. }
  55299. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55300. /** @hidden */
  55301. export var ssaoCombinePixelShader: {
  55302. name: string;
  55303. shader: string;
  55304. };
  55305. }
  55306. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55307. import { Camera } from "babylonjs/Cameras/camera";
  55308. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55309. import { Scene } from "babylonjs/scene";
  55310. import "babylonjs/Shaders/ssao2.fragment";
  55311. import "babylonjs/Shaders/ssaoCombine.fragment";
  55312. /**
  55313. * Render pipeline to produce ssao effect
  55314. */
  55315. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55316. /**
  55317. * @ignore
  55318. * The PassPostProcess id in the pipeline that contains the original scene color
  55319. */
  55320. SSAOOriginalSceneColorEffect: string;
  55321. /**
  55322. * @ignore
  55323. * The SSAO PostProcess id in the pipeline
  55324. */
  55325. SSAORenderEffect: string;
  55326. /**
  55327. * @ignore
  55328. * The horizontal blur PostProcess id in the pipeline
  55329. */
  55330. SSAOBlurHRenderEffect: string;
  55331. /**
  55332. * @ignore
  55333. * The vertical blur PostProcess id in the pipeline
  55334. */
  55335. SSAOBlurVRenderEffect: string;
  55336. /**
  55337. * @ignore
  55338. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55339. */
  55340. SSAOCombineRenderEffect: string;
  55341. /**
  55342. * The output strength of the SSAO post-process. Default value is 1.0.
  55343. */
  55344. totalStrength: number;
  55345. /**
  55346. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55347. */
  55348. maxZ: number;
  55349. /**
  55350. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55351. */
  55352. minZAspect: number;
  55353. private _samples;
  55354. /**
  55355. * Number of samples used for the SSAO calculations. Default value is 8
  55356. */
  55357. samples: number;
  55358. private _textureSamples;
  55359. /**
  55360. * Number of samples to use for antialiasing
  55361. */
  55362. textureSamples: number;
  55363. /**
  55364. * Ratio object used for SSAO ratio and blur ratio
  55365. */
  55366. private _ratio;
  55367. /**
  55368. * Dynamically generated sphere sampler.
  55369. */
  55370. private _sampleSphere;
  55371. /**
  55372. * Blur filter offsets
  55373. */
  55374. private _samplerOffsets;
  55375. private _expensiveBlur;
  55376. /**
  55377. * If bilateral blur should be used
  55378. */
  55379. expensiveBlur: boolean;
  55380. /**
  55381. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55382. */
  55383. radius: number;
  55384. /**
  55385. * The base color of the SSAO post-process
  55386. * The final result is "base + ssao" between [0, 1]
  55387. */
  55388. base: number;
  55389. /**
  55390. * Support test.
  55391. */
  55392. static readonly IsSupported: boolean;
  55393. private _scene;
  55394. private _depthTexture;
  55395. private _normalTexture;
  55396. private _randomTexture;
  55397. private _originalColorPostProcess;
  55398. private _ssaoPostProcess;
  55399. private _blurHPostProcess;
  55400. private _blurVPostProcess;
  55401. private _ssaoCombinePostProcess;
  55402. private _firstUpdate;
  55403. /**
  55404. * Gets active scene
  55405. */
  55406. readonly scene: Scene;
  55407. /**
  55408. * @constructor
  55409. * @param name The rendering pipeline name
  55410. * @param scene The scene linked to this pipeline
  55411. * @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 }
  55412. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55413. */
  55414. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55415. /**
  55416. * Get the class name
  55417. * @returns "SSAO2RenderingPipeline"
  55418. */
  55419. getClassName(): string;
  55420. /**
  55421. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55422. */
  55423. dispose(disableGeometryBufferRenderer?: boolean): void;
  55424. private _createBlurPostProcess;
  55425. /** @hidden */
  55426. _rebuild(): void;
  55427. private _bits;
  55428. private _radicalInverse_VdC;
  55429. private _hammersley;
  55430. private _hemisphereSample_uniform;
  55431. private _generateHemisphere;
  55432. private _createSSAOPostProcess;
  55433. private _createSSAOCombinePostProcess;
  55434. private _createRandomTexture;
  55435. /**
  55436. * Serialize the rendering pipeline (Used when exporting)
  55437. * @returns the serialized object
  55438. */
  55439. serialize(): any;
  55440. /**
  55441. * Parse the serialized pipeline
  55442. * @param source Source pipeline.
  55443. * @param scene The scene to load the pipeline to.
  55444. * @param rootUrl The URL of the serialized pipeline.
  55445. * @returns An instantiated pipeline from the serialized object.
  55446. */
  55447. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55448. }
  55449. }
  55450. declare module "babylonjs/Shaders/ssao.fragment" {
  55451. /** @hidden */
  55452. export var ssaoPixelShader: {
  55453. name: string;
  55454. shader: string;
  55455. };
  55456. }
  55457. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55458. import { Camera } from "babylonjs/Cameras/camera";
  55459. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55460. import { Scene } from "babylonjs/scene";
  55461. import "babylonjs/Shaders/ssao.fragment";
  55462. import "babylonjs/Shaders/ssaoCombine.fragment";
  55463. /**
  55464. * Render pipeline to produce ssao effect
  55465. */
  55466. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55467. /**
  55468. * @ignore
  55469. * The PassPostProcess id in the pipeline that contains the original scene color
  55470. */
  55471. SSAOOriginalSceneColorEffect: string;
  55472. /**
  55473. * @ignore
  55474. * The SSAO PostProcess id in the pipeline
  55475. */
  55476. SSAORenderEffect: string;
  55477. /**
  55478. * @ignore
  55479. * The horizontal blur PostProcess id in the pipeline
  55480. */
  55481. SSAOBlurHRenderEffect: string;
  55482. /**
  55483. * @ignore
  55484. * The vertical blur PostProcess id in the pipeline
  55485. */
  55486. SSAOBlurVRenderEffect: string;
  55487. /**
  55488. * @ignore
  55489. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55490. */
  55491. SSAOCombineRenderEffect: string;
  55492. /**
  55493. * The output strength of the SSAO post-process. Default value is 1.0.
  55494. */
  55495. totalStrength: number;
  55496. /**
  55497. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55498. */
  55499. radius: number;
  55500. /**
  55501. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55502. * Must not be equal to fallOff and superior to fallOff.
  55503. * Default value is 0.0075
  55504. */
  55505. area: number;
  55506. /**
  55507. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55508. * Must not be equal to area and inferior to area.
  55509. * Default value is 0.000001
  55510. */
  55511. fallOff: number;
  55512. /**
  55513. * The base color of the SSAO post-process
  55514. * The final result is "base + ssao" between [0, 1]
  55515. */
  55516. base: number;
  55517. private _scene;
  55518. private _depthTexture;
  55519. private _randomTexture;
  55520. private _originalColorPostProcess;
  55521. private _ssaoPostProcess;
  55522. private _blurHPostProcess;
  55523. private _blurVPostProcess;
  55524. private _ssaoCombinePostProcess;
  55525. private _firstUpdate;
  55526. /**
  55527. * Gets active scene
  55528. */
  55529. readonly scene: Scene;
  55530. /**
  55531. * @constructor
  55532. * @param name - The rendering pipeline name
  55533. * @param scene - The scene linked to this pipeline
  55534. * @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 }
  55535. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55536. */
  55537. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55538. /**
  55539. * Get the class name
  55540. * @returns "SSAORenderingPipeline"
  55541. */
  55542. getClassName(): string;
  55543. /**
  55544. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55545. */
  55546. dispose(disableDepthRender?: boolean): void;
  55547. private _createBlurPostProcess;
  55548. /** @hidden */
  55549. _rebuild(): void;
  55550. private _createSSAOPostProcess;
  55551. private _createSSAOCombinePostProcess;
  55552. private _createRandomTexture;
  55553. }
  55554. }
  55555. declare module "babylonjs/Shaders/standard.fragment" {
  55556. /** @hidden */
  55557. export var standardPixelShader: {
  55558. name: string;
  55559. shader: string;
  55560. };
  55561. }
  55562. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55563. import { Nullable } from "babylonjs/types";
  55564. import { IAnimatable } from "babylonjs/Misc/tools";
  55565. import { Camera } from "babylonjs/Cameras/camera";
  55566. import { Texture } from "babylonjs/Materials/Textures/texture";
  55567. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55568. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55569. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55570. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55571. import { IDisposable } from "babylonjs/scene";
  55572. import { SpotLight } from "babylonjs/Lights/spotLight";
  55573. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55574. import { Scene } from "babylonjs/scene";
  55575. import { Animation } from "babylonjs/Animations/animation";
  55576. import "babylonjs/Shaders/standard.fragment";
  55577. /**
  55578. * Standard rendering pipeline
  55579. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55580. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55581. */
  55582. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55583. /**
  55584. * Public members
  55585. */
  55586. /**
  55587. * Post-process which contains the original scene color before the pipeline applies all the effects
  55588. */
  55589. originalPostProcess: Nullable<PostProcess>;
  55590. /**
  55591. * Post-process used to down scale an image x4
  55592. */
  55593. downSampleX4PostProcess: Nullable<PostProcess>;
  55594. /**
  55595. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55596. */
  55597. brightPassPostProcess: Nullable<PostProcess>;
  55598. /**
  55599. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55600. */
  55601. blurHPostProcesses: PostProcess[];
  55602. /**
  55603. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55604. */
  55605. blurVPostProcesses: PostProcess[];
  55606. /**
  55607. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55608. */
  55609. textureAdderPostProcess: Nullable<PostProcess>;
  55610. /**
  55611. * Post-process used to create volumetric lighting effect
  55612. */
  55613. volumetricLightPostProcess: Nullable<PostProcess>;
  55614. /**
  55615. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55616. */
  55617. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55618. /**
  55619. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55620. */
  55621. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55622. /**
  55623. * Post-process used to merge the volumetric light effect and the real scene color
  55624. */
  55625. volumetricLightMergePostProces: Nullable<PostProcess>;
  55626. /**
  55627. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55628. */
  55629. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55630. /**
  55631. * Base post-process used to calculate the average luminance of the final image for HDR
  55632. */
  55633. luminancePostProcess: Nullable<PostProcess>;
  55634. /**
  55635. * Post-processes used to create down sample post-processes in order to get
  55636. * the average luminance of the final image for HDR
  55637. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55638. */
  55639. luminanceDownSamplePostProcesses: PostProcess[];
  55640. /**
  55641. * Post-process used to create a HDR effect (light adaptation)
  55642. */
  55643. hdrPostProcess: Nullable<PostProcess>;
  55644. /**
  55645. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55646. */
  55647. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55648. /**
  55649. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55650. */
  55651. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55652. /**
  55653. * Post-process used to merge the final HDR post-process and the real scene color
  55654. */
  55655. hdrFinalPostProcess: Nullable<PostProcess>;
  55656. /**
  55657. * Post-process used to create a lens flare effect
  55658. */
  55659. lensFlarePostProcess: Nullable<PostProcess>;
  55660. /**
  55661. * Post-process that merges the result of the lens flare post-process and the real scene color
  55662. */
  55663. lensFlareComposePostProcess: Nullable<PostProcess>;
  55664. /**
  55665. * Post-process used to create a motion blur effect
  55666. */
  55667. motionBlurPostProcess: Nullable<PostProcess>;
  55668. /**
  55669. * Post-process used to create a depth of field effect
  55670. */
  55671. depthOfFieldPostProcess: Nullable<PostProcess>;
  55672. /**
  55673. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55674. */
  55675. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55676. /**
  55677. * Represents the brightness threshold in order to configure the illuminated surfaces
  55678. */
  55679. brightThreshold: number;
  55680. /**
  55681. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55682. */
  55683. blurWidth: number;
  55684. /**
  55685. * Sets if the blur for highlighted surfaces must be only horizontal
  55686. */
  55687. horizontalBlur: boolean;
  55688. /**
  55689. * Sets the overall exposure used by the pipeline
  55690. */
  55691. exposure: number;
  55692. /**
  55693. * Texture used typically to simulate "dirty" on camera lens
  55694. */
  55695. lensTexture: Nullable<Texture>;
  55696. /**
  55697. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55698. */
  55699. volumetricLightCoefficient: number;
  55700. /**
  55701. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55702. */
  55703. volumetricLightPower: number;
  55704. /**
  55705. * Used the set the blur intensity to smooth the volumetric lights
  55706. */
  55707. volumetricLightBlurScale: number;
  55708. /**
  55709. * Light (spot or directional) used to generate the volumetric lights rays
  55710. * The source light must have a shadow generate so the pipeline can get its
  55711. * depth map
  55712. */
  55713. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55714. /**
  55715. * For eye adaptation, represents the minimum luminance the eye can see
  55716. */
  55717. hdrMinimumLuminance: number;
  55718. /**
  55719. * For eye adaptation, represents the decrease luminance speed
  55720. */
  55721. hdrDecreaseRate: number;
  55722. /**
  55723. * For eye adaptation, represents the increase luminance speed
  55724. */
  55725. hdrIncreaseRate: number;
  55726. /**
  55727. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55728. */
  55729. lensColorTexture: Nullable<Texture>;
  55730. /**
  55731. * The overall strengh for the lens flare effect
  55732. */
  55733. lensFlareStrength: number;
  55734. /**
  55735. * Dispersion coefficient for lens flare ghosts
  55736. */
  55737. lensFlareGhostDispersal: number;
  55738. /**
  55739. * Main lens flare halo width
  55740. */
  55741. lensFlareHaloWidth: number;
  55742. /**
  55743. * Based on the lens distortion effect, defines how much the lens flare result
  55744. * is distorted
  55745. */
  55746. lensFlareDistortionStrength: number;
  55747. /**
  55748. * Lens star texture must be used to simulate rays on the flares and is available
  55749. * in the documentation
  55750. */
  55751. lensStarTexture: Nullable<Texture>;
  55752. /**
  55753. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55754. * flare effect by taking account of the dirt texture
  55755. */
  55756. lensFlareDirtTexture: Nullable<Texture>;
  55757. /**
  55758. * Represents the focal length for the depth of field effect
  55759. */
  55760. depthOfFieldDistance: number;
  55761. /**
  55762. * Represents the blur intensity for the blurred part of the depth of field effect
  55763. */
  55764. depthOfFieldBlurWidth: number;
  55765. /**
  55766. * For motion blur, defines how much the image is blurred by the movement
  55767. */
  55768. motionStrength: number;
  55769. /**
  55770. * List of animations for the pipeline (IAnimatable implementation)
  55771. */
  55772. animations: Animation[];
  55773. /**
  55774. * Private members
  55775. */
  55776. private _scene;
  55777. private _currentDepthOfFieldSource;
  55778. private _basePostProcess;
  55779. private _hdrCurrentLuminance;
  55780. private _floatTextureType;
  55781. private _ratio;
  55782. private _bloomEnabled;
  55783. private _depthOfFieldEnabled;
  55784. private _vlsEnabled;
  55785. private _lensFlareEnabled;
  55786. private _hdrEnabled;
  55787. private _motionBlurEnabled;
  55788. private _fxaaEnabled;
  55789. private _motionBlurSamples;
  55790. private _volumetricLightStepsCount;
  55791. private _samples;
  55792. /**
  55793. * @ignore
  55794. * Specifies if the bloom pipeline is enabled
  55795. */
  55796. BloomEnabled: boolean;
  55797. /**
  55798. * @ignore
  55799. * Specifies if the depth of field pipeline is enabed
  55800. */
  55801. DepthOfFieldEnabled: boolean;
  55802. /**
  55803. * @ignore
  55804. * Specifies if the lens flare pipeline is enabed
  55805. */
  55806. LensFlareEnabled: boolean;
  55807. /**
  55808. * @ignore
  55809. * Specifies if the HDR pipeline is enabled
  55810. */
  55811. HDREnabled: boolean;
  55812. /**
  55813. * @ignore
  55814. * Specifies if the volumetric lights scattering effect is enabled
  55815. */
  55816. VLSEnabled: boolean;
  55817. /**
  55818. * @ignore
  55819. * Specifies if the motion blur effect is enabled
  55820. */
  55821. MotionBlurEnabled: boolean;
  55822. /**
  55823. * Specifies if anti-aliasing is enabled
  55824. */
  55825. fxaaEnabled: boolean;
  55826. /**
  55827. * Specifies the number of steps used to calculate the volumetric lights
  55828. * Typically in interval [50, 200]
  55829. */
  55830. volumetricLightStepsCount: number;
  55831. /**
  55832. * Specifies the number of samples used for the motion blur effect
  55833. * Typically in interval [16, 64]
  55834. */
  55835. motionBlurSamples: number;
  55836. /**
  55837. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55838. */
  55839. samples: number;
  55840. /**
  55841. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55842. * @constructor
  55843. * @param name The rendering pipeline name
  55844. * @param scene The scene linked to this pipeline
  55845. * @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)
  55846. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55847. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55848. */
  55849. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55850. private _buildPipeline;
  55851. private _createDownSampleX4PostProcess;
  55852. private _createBrightPassPostProcess;
  55853. private _createBlurPostProcesses;
  55854. private _createTextureAdderPostProcess;
  55855. private _createVolumetricLightPostProcess;
  55856. private _createLuminancePostProcesses;
  55857. private _createHdrPostProcess;
  55858. private _createLensFlarePostProcess;
  55859. private _createDepthOfFieldPostProcess;
  55860. private _createMotionBlurPostProcess;
  55861. private _getDepthTexture;
  55862. private _disposePostProcesses;
  55863. /**
  55864. * Dispose of the pipeline and stop all post processes
  55865. */
  55866. dispose(): void;
  55867. /**
  55868. * Serialize the rendering pipeline (Used when exporting)
  55869. * @returns the serialized object
  55870. */
  55871. serialize(): any;
  55872. /**
  55873. * Parse the serialized pipeline
  55874. * @param source Source pipeline.
  55875. * @param scene The scene to load the pipeline to.
  55876. * @param rootUrl The URL of the serialized pipeline.
  55877. * @returns An instantiated pipeline from the serialized object.
  55878. */
  55879. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55880. /**
  55881. * Luminance steps
  55882. */
  55883. static LuminanceSteps: number;
  55884. }
  55885. }
  55886. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55887. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55888. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55889. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55890. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55891. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55892. }
  55893. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55894. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55895. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55896. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55897. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55898. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55899. }
  55900. declare module "babylonjs/Shaders/tonemap.fragment" {
  55901. /** @hidden */
  55902. export var tonemapPixelShader: {
  55903. name: string;
  55904. shader: string;
  55905. };
  55906. }
  55907. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55908. import { Camera } from "babylonjs/Cameras/camera";
  55909. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55910. import "babylonjs/Shaders/tonemap.fragment";
  55911. import { Engine } from "babylonjs/Engines/engine";
  55912. /** Defines operator used for tonemapping */
  55913. export enum TonemappingOperator {
  55914. /** Hable */
  55915. Hable = 0,
  55916. /** Reinhard */
  55917. Reinhard = 1,
  55918. /** HejiDawson */
  55919. HejiDawson = 2,
  55920. /** Photographic */
  55921. Photographic = 3
  55922. }
  55923. /**
  55924. * Defines a post process to apply tone mapping
  55925. */
  55926. export class TonemapPostProcess extends PostProcess {
  55927. private _operator;
  55928. /** Defines the required exposure adjustement */
  55929. exposureAdjustment: number;
  55930. /**
  55931. * Creates a new TonemapPostProcess
  55932. * @param name defines the name of the postprocess
  55933. * @param _operator defines the operator to use
  55934. * @param exposureAdjustment defines the required exposure adjustement
  55935. * @param camera defines the camera to use (can be null)
  55936. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55937. * @param engine defines the hosting engine (can be ignore if camera is set)
  55938. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55939. */
  55940. constructor(name: string, _operator: TonemappingOperator,
  55941. /** Defines the required exposure adjustement */
  55942. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55943. }
  55944. }
  55945. declare module "babylonjs/Shaders/depth.vertex" {
  55946. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55947. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55948. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55949. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55950. /** @hidden */
  55951. export var depthVertexShader: {
  55952. name: string;
  55953. shader: string;
  55954. };
  55955. }
  55956. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55957. /** @hidden */
  55958. export var volumetricLightScatteringPixelShader: {
  55959. name: string;
  55960. shader: string;
  55961. };
  55962. }
  55963. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55964. /** @hidden */
  55965. export var volumetricLightScatteringPassPixelShader: {
  55966. name: string;
  55967. shader: string;
  55968. };
  55969. }
  55970. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55971. import { Vector3 } from "babylonjs/Maths/math";
  55972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55973. import { Mesh } from "babylonjs/Meshes/mesh";
  55974. import { Camera } from "babylonjs/Cameras/camera";
  55975. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55976. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55977. import { Scene } from "babylonjs/scene";
  55978. import "babylonjs/Meshes/Builders/planeBuilder";
  55979. import "babylonjs/Shaders/depth.vertex";
  55980. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55981. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55982. import { Engine } from "babylonjs/Engines/engine";
  55983. /**
  55984. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55985. */
  55986. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55987. private _volumetricLightScatteringPass;
  55988. private _volumetricLightScatteringRTT;
  55989. private _viewPort;
  55990. private _screenCoordinates;
  55991. private _cachedDefines;
  55992. /**
  55993. * If not undefined, the mesh position is computed from the attached node position
  55994. */
  55995. attachedNode: {
  55996. position: Vector3;
  55997. };
  55998. /**
  55999. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56000. */
  56001. customMeshPosition: Vector3;
  56002. /**
  56003. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56004. */
  56005. useCustomMeshPosition: boolean;
  56006. /**
  56007. * If the post-process should inverse the light scattering direction
  56008. */
  56009. invert: boolean;
  56010. /**
  56011. * The internal mesh used by the post-process
  56012. */
  56013. mesh: Mesh;
  56014. /**
  56015. * @hidden
  56016. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56017. */
  56018. useDiffuseColor: boolean;
  56019. /**
  56020. * Array containing the excluded meshes not rendered in the internal pass
  56021. */
  56022. excludedMeshes: AbstractMesh[];
  56023. /**
  56024. * Controls the overall intensity of the post-process
  56025. */
  56026. exposure: number;
  56027. /**
  56028. * Dissipates each sample's contribution in range [0, 1]
  56029. */
  56030. decay: number;
  56031. /**
  56032. * Controls the overall intensity of each sample
  56033. */
  56034. weight: number;
  56035. /**
  56036. * Controls the density of each sample
  56037. */
  56038. density: number;
  56039. /**
  56040. * @constructor
  56041. * @param name The post-process name
  56042. * @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)
  56043. * @param camera The camera that the post-process will be attached to
  56044. * @param mesh The mesh used to create the light scattering
  56045. * @param samples The post-process quality, default 100
  56046. * @param samplingModeThe post-process filtering mode
  56047. * @param engine The babylon engine
  56048. * @param reusable If the post-process is reusable
  56049. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56050. */
  56051. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56052. /**
  56053. * Returns the string "VolumetricLightScatteringPostProcess"
  56054. * @returns "VolumetricLightScatteringPostProcess"
  56055. */
  56056. getClassName(): string;
  56057. private _isReady;
  56058. /**
  56059. * Sets the new light position for light scattering effect
  56060. * @param position The new custom light position
  56061. */
  56062. setCustomMeshPosition(position: Vector3): void;
  56063. /**
  56064. * Returns the light position for light scattering effect
  56065. * @return Vector3 The custom light position
  56066. */
  56067. getCustomMeshPosition(): Vector3;
  56068. /**
  56069. * Disposes the internal assets and detaches the post-process from the camera
  56070. */
  56071. dispose(camera: Camera): void;
  56072. /**
  56073. * Returns the render target texture used by the post-process
  56074. * @return the render target texture used by the post-process
  56075. */
  56076. getPass(): RenderTargetTexture;
  56077. private _meshExcluded;
  56078. private _createPass;
  56079. private _updateMeshScreenCoordinates;
  56080. /**
  56081. * Creates a default mesh for the Volumeric Light Scattering post-process
  56082. * @param name The mesh name
  56083. * @param scene The scene where to create the mesh
  56084. * @return the default mesh
  56085. */
  56086. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56087. }
  56088. }
  56089. declare module "babylonjs/PostProcesses/index" {
  56090. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56091. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56092. export * from "babylonjs/PostProcesses/bloomEffect";
  56093. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56094. export * from "babylonjs/PostProcesses/blurPostProcess";
  56095. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56096. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56097. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56098. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56099. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56100. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56101. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56102. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56103. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56104. export * from "babylonjs/PostProcesses/filterPostProcess";
  56105. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56106. export * from "babylonjs/PostProcesses/grainPostProcess";
  56107. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56108. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56109. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56110. export * from "babylonjs/PostProcesses/passPostProcess";
  56111. export * from "babylonjs/PostProcesses/postProcess";
  56112. export * from "babylonjs/PostProcesses/postProcessManager";
  56113. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56114. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56115. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56116. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56117. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56118. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56119. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56120. }
  56121. declare module "babylonjs/Probes/index" {
  56122. export * from "babylonjs/Probes/reflectionProbe";
  56123. }
  56124. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56125. import { Scene } from "babylonjs/scene";
  56126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56127. import { Color3 } from "babylonjs/Maths/math";
  56128. import { SmartArray } from "babylonjs/Misc/smartArray";
  56129. import { ISceneComponent } from "babylonjs/sceneComponent";
  56130. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56131. import "babylonjs/Meshes/Builders/boxBuilder";
  56132. import "babylonjs/Shaders/color.fragment";
  56133. import "babylonjs/Shaders/color.vertex";
  56134. module "babylonjs/scene" {
  56135. interface Scene {
  56136. /** @hidden (Backing field) */
  56137. _boundingBoxRenderer: BoundingBoxRenderer;
  56138. /** @hidden (Backing field) */
  56139. _forceShowBoundingBoxes: boolean;
  56140. /**
  56141. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56142. */
  56143. forceShowBoundingBoxes: boolean;
  56144. /**
  56145. * Gets the bounding box renderer associated with the scene
  56146. * @returns a BoundingBoxRenderer
  56147. */
  56148. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56149. }
  56150. }
  56151. module "babylonjs/Meshes/abstractMesh" {
  56152. interface AbstractMesh {
  56153. /** @hidden (Backing field) */
  56154. _showBoundingBox: boolean;
  56155. /**
  56156. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56157. */
  56158. showBoundingBox: boolean;
  56159. }
  56160. }
  56161. /**
  56162. * Component responsible of rendering the bounding box of the meshes in a scene.
  56163. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56164. */
  56165. export class BoundingBoxRenderer implements ISceneComponent {
  56166. /**
  56167. * The component name helpfull to identify the component in the list of scene components.
  56168. */
  56169. readonly name: string;
  56170. /**
  56171. * The scene the component belongs to.
  56172. */
  56173. scene: Scene;
  56174. /**
  56175. * Color of the bounding box lines placed in front of an object
  56176. */
  56177. frontColor: Color3;
  56178. /**
  56179. * Color of the bounding box lines placed behind an object
  56180. */
  56181. backColor: Color3;
  56182. /**
  56183. * Defines if the renderer should show the back lines or not
  56184. */
  56185. showBackLines: boolean;
  56186. /**
  56187. * @hidden
  56188. */
  56189. renderList: SmartArray<BoundingBox>;
  56190. private _colorShader;
  56191. private _vertexBuffers;
  56192. private _indexBuffer;
  56193. /**
  56194. * Instantiates a new bounding box renderer in a scene.
  56195. * @param scene the scene the renderer renders in
  56196. */
  56197. constructor(scene: Scene);
  56198. /**
  56199. * Registers the component in a given scene
  56200. */
  56201. register(): void;
  56202. private _evaluateSubMesh;
  56203. private _activeMesh;
  56204. private _prepareRessources;
  56205. private _createIndexBuffer;
  56206. /**
  56207. * Rebuilds the elements related to this component in case of
  56208. * context lost for instance.
  56209. */
  56210. rebuild(): void;
  56211. /**
  56212. * @hidden
  56213. */
  56214. reset(): void;
  56215. /**
  56216. * Render the bounding boxes of a specific rendering group
  56217. * @param renderingGroupId defines the rendering group to render
  56218. */
  56219. render(renderingGroupId: number): void;
  56220. /**
  56221. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56222. * @param mesh Define the mesh to render the occlusion bounding box for
  56223. */
  56224. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56225. /**
  56226. * Dispose and release the resources attached to this renderer.
  56227. */
  56228. dispose(): void;
  56229. }
  56230. }
  56231. declare module "babylonjs/Shaders/depth.fragment" {
  56232. /** @hidden */
  56233. export var depthPixelShader: {
  56234. name: string;
  56235. shader: string;
  56236. };
  56237. }
  56238. declare module "babylonjs/Rendering/depthRenderer" {
  56239. import { Nullable } from "babylonjs/types";
  56240. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56241. import { Scene } from "babylonjs/scene";
  56242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56243. import { Camera } from "babylonjs/Cameras/camera";
  56244. import "babylonjs/Shaders/depth.fragment";
  56245. import "babylonjs/Shaders/depth.vertex";
  56246. /**
  56247. * This represents a depth renderer in Babylon.
  56248. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56249. */
  56250. export class DepthRenderer {
  56251. private _scene;
  56252. private _depthMap;
  56253. private _effect;
  56254. private _cachedDefines;
  56255. private _camera;
  56256. /**
  56257. * Specifiess that the depth renderer will only be used within
  56258. * the camera it is created for.
  56259. * This can help forcing its rendering during the camera processing.
  56260. */
  56261. useOnlyInActiveCamera: boolean;
  56262. /** @hidden */
  56263. static _SceneComponentInitialization: (scene: Scene) => void;
  56264. /**
  56265. * Instantiates a depth renderer
  56266. * @param scene The scene the renderer belongs to
  56267. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56268. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56269. */
  56270. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56271. /**
  56272. * Creates the depth rendering effect and checks if the effect is ready.
  56273. * @param subMesh The submesh to be used to render the depth map of
  56274. * @param useInstances If multiple world instances should be used
  56275. * @returns if the depth renderer is ready to render the depth map
  56276. */
  56277. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56278. /**
  56279. * Gets the texture which the depth map will be written to.
  56280. * @returns The depth map texture
  56281. */
  56282. getDepthMap(): RenderTargetTexture;
  56283. /**
  56284. * Disposes of the depth renderer.
  56285. */
  56286. dispose(): void;
  56287. }
  56288. }
  56289. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56290. import { Nullable } from "babylonjs/types";
  56291. import { Scene } from "babylonjs/scene";
  56292. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56293. import { Camera } from "babylonjs/Cameras/camera";
  56294. import { ISceneComponent } from "babylonjs/sceneComponent";
  56295. module "babylonjs/scene" {
  56296. interface Scene {
  56297. /** @hidden (Backing field) */
  56298. _depthRenderer: {
  56299. [id: string]: DepthRenderer;
  56300. };
  56301. /**
  56302. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56303. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56304. * @returns the created depth renderer
  56305. */
  56306. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56307. /**
  56308. * Disables a depth renderer for a given camera
  56309. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56310. */
  56311. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56312. }
  56313. }
  56314. /**
  56315. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56316. * in several rendering techniques.
  56317. */
  56318. export class DepthRendererSceneComponent implements ISceneComponent {
  56319. /**
  56320. * The component name helpfull to identify the component in the list of scene components.
  56321. */
  56322. readonly name: string;
  56323. /**
  56324. * The scene the component belongs to.
  56325. */
  56326. scene: Scene;
  56327. /**
  56328. * Creates a new instance of the component for the given scene
  56329. * @param scene Defines the scene to register the component in
  56330. */
  56331. constructor(scene: Scene);
  56332. /**
  56333. * Registers the component in a given scene
  56334. */
  56335. register(): void;
  56336. /**
  56337. * Rebuilds the elements related to this component in case of
  56338. * context lost for instance.
  56339. */
  56340. rebuild(): void;
  56341. /**
  56342. * Disposes the component and the associated ressources
  56343. */
  56344. dispose(): void;
  56345. private _gatherRenderTargets;
  56346. private _gatherActiveCameraRenderTargets;
  56347. }
  56348. }
  56349. declare module "babylonjs/Shaders/outline.fragment" {
  56350. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56351. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56352. /** @hidden */
  56353. export var outlinePixelShader: {
  56354. name: string;
  56355. shader: string;
  56356. };
  56357. }
  56358. declare module "babylonjs/Shaders/outline.vertex" {
  56359. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56361. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56362. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56363. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56364. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56365. /** @hidden */
  56366. export var outlineVertexShader: {
  56367. name: string;
  56368. shader: string;
  56369. };
  56370. }
  56371. declare module "babylonjs/Rendering/outlineRenderer" {
  56372. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56373. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56374. import { Scene } from "babylonjs/scene";
  56375. import { ISceneComponent } from "babylonjs/sceneComponent";
  56376. import "babylonjs/Shaders/outline.fragment";
  56377. import "babylonjs/Shaders/outline.vertex";
  56378. module "babylonjs/scene" {
  56379. interface Scene {
  56380. /** @hidden */
  56381. _outlineRenderer: OutlineRenderer;
  56382. /**
  56383. * Gets the outline renderer associated with the scene
  56384. * @returns a OutlineRenderer
  56385. */
  56386. getOutlineRenderer(): OutlineRenderer;
  56387. }
  56388. }
  56389. module "babylonjs/Meshes/abstractMesh" {
  56390. interface AbstractMesh {
  56391. /** @hidden (Backing field) */
  56392. _renderOutline: boolean;
  56393. /**
  56394. * Gets or sets a boolean indicating if the outline must be rendered as well
  56395. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56396. */
  56397. renderOutline: boolean;
  56398. /** @hidden (Backing field) */
  56399. _renderOverlay: boolean;
  56400. /**
  56401. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56402. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56403. */
  56404. renderOverlay: boolean;
  56405. }
  56406. }
  56407. /**
  56408. * This class is responsible to draw bothe outline/overlay of meshes.
  56409. * It should not be used directly but through the available method on mesh.
  56410. */
  56411. export class OutlineRenderer implements ISceneComponent {
  56412. /**
  56413. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56414. */
  56415. private static _StencilReference;
  56416. /**
  56417. * The name of the component. Each component must have a unique name.
  56418. */
  56419. name: string;
  56420. /**
  56421. * The scene the component belongs to.
  56422. */
  56423. scene: Scene;
  56424. /**
  56425. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56426. */
  56427. zOffset: number;
  56428. private _engine;
  56429. private _effect;
  56430. private _cachedDefines;
  56431. private _savedDepthWrite;
  56432. /**
  56433. * Instantiates a new outline renderer. (There could be only one per scene).
  56434. * @param scene Defines the scene it belongs to
  56435. */
  56436. constructor(scene: Scene);
  56437. /**
  56438. * Register the component to one instance of a scene.
  56439. */
  56440. register(): void;
  56441. /**
  56442. * Rebuilds the elements related to this component in case of
  56443. * context lost for instance.
  56444. */
  56445. rebuild(): void;
  56446. /**
  56447. * Disposes the component and the associated ressources.
  56448. */
  56449. dispose(): void;
  56450. /**
  56451. * Renders the outline in the canvas.
  56452. * @param subMesh Defines the sumesh to render
  56453. * @param batch Defines the batch of meshes in case of instances
  56454. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56455. */
  56456. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56457. /**
  56458. * Returns whether or not the outline renderer is ready for a given submesh.
  56459. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56460. * @param subMesh Defines the submesh to check readyness for
  56461. * @param useInstances Defines wheter wee are trying to render instances or not
  56462. * @returns true if ready otherwise false
  56463. */
  56464. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56465. private _beforeRenderingMesh;
  56466. private _afterRenderingMesh;
  56467. }
  56468. }
  56469. declare module "babylonjs/Rendering/index" {
  56470. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56471. export * from "babylonjs/Rendering/depthRenderer";
  56472. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56473. export * from "babylonjs/Rendering/edgesRenderer";
  56474. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56475. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56476. export * from "babylonjs/Rendering/outlineRenderer";
  56477. export * from "babylonjs/Rendering/renderingGroup";
  56478. export * from "babylonjs/Rendering/renderingManager";
  56479. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56480. }
  56481. declare module "babylonjs/Sprites/index" {
  56482. export * from "babylonjs/Sprites/sprite";
  56483. export * from "babylonjs/Sprites/spriteManager";
  56484. export * from "babylonjs/Sprites/spriteSceneComponent";
  56485. }
  56486. declare module "babylonjs/Misc/assetsManager" {
  56487. import { Scene } from "babylonjs/scene";
  56488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56489. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56490. import { Skeleton } from "babylonjs/Bones/skeleton";
  56491. import { Observable } from "babylonjs/Misc/observable";
  56492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56493. import { Texture } from "babylonjs/Materials/Textures/texture";
  56494. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56495. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56496. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56497. /**
  56498. * Defines the list of states available for a task inside a AssetsManager
  56499. */
  56500. export enum AssetTaskState {
  56501. /**
  56502. * Initialization
  56503. */
  56504. INIT = 0,
  56505. /**
  56506. * Running
  56507. */
  56508. RUNNING = 1,
  56509. /**
  56510. * Done
  56511. */
  56512. DONE = 2,
  56513. /**
  56514. * Error
  56515. */
  56516. ERROR = 3
  56517. }
  56518. /**
  56519. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56520. */
  56521. export abstract class AbstractAssetTask {
  56522. /**
  56523. * Task name
  56524. */ name: string;
  56525. /**
  56526. * Callback called when the task is successful
  56527. */
  56528. onSuccess: (task: any) => void;
  56529. /**
  56530. * Callback called when the task is not successful
  56531. */
  56532. onError: (task: any, message?: string, exception?: any) => void;
  56533. /**
  56534. * Creates a new AssetsManager
  56535. * @param name defines the name of the task
  56536. */
  56537. constructor(
  56538. /**
  56539. * Task name
  56540. */ name: string);
  56541. private _isCompleted;
  56542. private _taskState;
  56543. private _errorObject;
  56544. /**
  56545. * Get if the task is completed
  56546. */
  56547. readonly isCompleted: boolean;
  56548. /**
  56549. * Gets the current state of the task
  56550. */
  56551. readonly taskState: AssetTaskState;
  56552. /**
  56553. * Gets the current error object (if task is in error)
  56554. */
  56555. readonly errorObject: {
  56556. message?: string;
  56557. exception?: any;
  56558. };
  56559. /**
  56560. * Internal only
  56561. * @hidden
  56562. */
  56563. _setErrorObject(message?: string, exception?: any): void;
  56564. /**
  56565. * Execute the current task
  56566. * @param scene defines the scene where you want your assets to be loaded
  56567. * @param onSuccess is a callback called when the task is successfully executed
  56568. * @param onError is a callback called if an error occurs
  56569. */
  56570. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56571. /**
  56572. * Execute the current task
  56573. * @param scene defines the scene where you want your assets to be loaded
  56574. * @param onSuccess is a callback called when the task is successfully executed
  56575. * @param onError is a callback called if an error occurs
  56576. */
  56577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56578. /**
  56579. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56580. * This can be used with failed tasks that have the reason for failure fixed.
  56581. */
  56582. reset(): void;
  56583. private onErrorCallback;
  56584. private onDoneCallback;
  56585. }
  56586. /**
  56587. * Define the interface used by progress events raised during assets loading
  56588. */
  56589. export interface IAssetsProgressEvent {
  56590. /**
  56591. * Defines the number of remaining tasks to process
  56592. */
  56593. remainingCount: number;
  56594. /**
  56595. * Defines the total number of tasks
  56596. */
  56597. totalCount: number;
  56598. /**
  56599. * Defines the task that was just processed
  56600. */
  56601. task: AbstractAssetTask;
  56602. }
  56603. /**
  56604. * Class used to share progress information about assets loading
  56605. */
  56606. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56607. /**
  56608. * Defines the number of remaining tasks to process
  56609. */
  56610. remainingCount: number;
  56611. /**
  56612. * Defines the total number of tasks
  56613. */
  56614. totalCount: number;
  56615. /**
  56616. * Defines the task that was just processed
  56617. */
  56618. task: AbstractAssetTask;
  56619. /**
  56620. * Creates a AssetsProgressEvent
  56621. * @param remainingCount defines the number of remaining tasks to process
  56622. * @param totalCount defines the total number of tasks
  56623. * @param task defines the task that was just processed
  56624. */
  56625. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56626. }
  56627. /**
  56628. * Define a task used by AssetsManager to load meshes
  56629. */
  56630. export class MeshAssetTask extends AbstractAssetTask {
  56631. /**
  56632. * Defines the name of the task
  56633. */
  56634. name: string;
  56635. /**
  56636. * Defines the list of mesh's names you want to load
  56637. */
  56638. meshesNames: any;
  56639. /**
  56640. * Defines the root url to use as a base to load your meshes and associated resources
  56641. */
  56642. rootUrl: string;
  56643. /**
  56644. * Defines the filename of the scene to load from
  56645. */
  56646. sceneFilename: string;
  56647. /**
  56648. * Gets the list of loaded meshes
  56649. */
  56650. loadedMeshes: Array<AbstractMesh>;
  56651. /**
  56652. * Gets the list of loaded particle systems
  56653. */
  56654. loadedParticleSystems: Array<IParticleSystem>;
  56655. /**
  56656. * Gets the list of loaded skeletons
  56657. */
  56658. loadedSkeletons: Array<Skeleton>;
  56659. /**
  56660. * Gets the list of loaded animation groups
  56661. */
  56662. loadedAnimationGroups: Array<AnimationGroup>;
  56663. /**
  56664. * Callback called when the task is successful
  56665. */
  56666. onSuccess: (task: MeshAssetTask) => void;
  56667. /**
  56668. * Callback called when the task is successful
  56669. */
  56670. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56671. /**
  56672. * Creates a new MeshAssetTask
  56673. * @param name defines the name of the task
  56674. * @param meshesNames defines the list of mesh's names you want to load
  56675. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56676. * @param sceneFilename defines the filename of the scene to load from
  56677. */
  56678. constructor(
  56679. /**
  56680. * Defines the name of the task
  56681. */
  56682. name: string,
  56683. /**
  56684. * Defines the list of mesh's names you want to load
  56685. */
  56686. meshesNames: any,
  56687. /**
  56688. * Defines the root url to use as a base to load your meshes and associated resources
  56689. */
  56690. rootUrl: string,
  56691. /**
  56692. * Defines the filename of the scene to load from
  56693. */
  56694. sceneFilename: string);
  56695. /**
  56696. * Execute the current task
  56697. * @param scene defines the scene where you want your assets to be loaded
  56698. * @param onSuccess is a callback called when the task is successfully executed
  56699. * @param onError is a callback called if an error occurs
  56700. */
  56701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56702. }
  56703. /**
  56704. * Define a task used by AssetsManager to load text content
  56705. */
  56706. export class TextFileAssetTask extends AbstractAssetTask {
  56707. /**
  56708. * Defines the name of the task
  56709. */
  56710. name: string;
  56711. /**
  56712. * Defines the location of the file to load
  56713. */
  56714. url: string;
  56715. /**
  56716. * Gets the loaded text string
  56717. */
  56718. text: string;
  56719. /**
  56720. * Callback called when the task is successful
  56721. */
  56722. onSuccess: (task: TextFileAssetTask) => void;
  56723. /**
  56724. * Callback called when the task is successful
  56725. */
  56726. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56727. /**
  56728. * Creates a new TextFileAssetTask object
  56729. * @param name defines the name of the task
  56730. * @param url defines the location of the file to load
  56731. */
  56732. constructor(
  56733. /**
  56734. * Defines the name of the task
  56735. */
  56736. name: string,
  56737. /**
  56738. * Defines the location of the file to load
  56739. */
  56740. url: string);
  56741. /**
  56742. * Execute the current task
  56743. * @param scene defines the scene where you want your assets to be loaded
  56744. * @param onSuccess is a callback called when the task is successfully executed
  56745. * @param onError is a callback called if an error occurs
  56746. */
  56747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56748. }
  56749. /**
  56750. * Define a task used by AssetsManager to load binary data
  56751. */
  56752. export class BinaryFileAssetTask extends AbstractAssetTask {
  56753. /**
  56754. * Defines the name of the task
  56755. */
  56756. name: string;
  56757. /**
  56758. * Defines the location of the file to load
  56759. */
  56760. url: string;
  56761. /**
  56762. * Gets the lodaded data (as an array buffer)
  56763. */
  56764. data: ArrayBuffer;
  56765. /**
  56766. * Callback called when the task is successful
  56767. */
  56768. onSuccess: (task: BinaryFileAssetTask) => void;
  56769. /**
  56770. * Callback called when the task is successful
  56771. */
  56772. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56773. /**
  56774. * Creates a new BinaryFileAssetTask object
  56775. * @param name defines the name of the new task
  56776. * @param url defines the location of the file to load
  56777. */
  56778. constructor(
  56779. /**
  56780. * Defines the name of the task
  56781. */
  56782. name: string,
  56783. /**
  56784. * Defines the location of the file to load
  56785. */
  56786. url: string);
  56787. /**
  56788. * Execute the current task
  56789. * @param scene defines the scene where you want your assets to be loaded
  56790. * @param onSuccess is a callback called when the task is successfully executed
  56791. * @param onError is a callback called if an error occurs
  56792. */
  56793. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56794. }
  56795. /**
  56796. * Define a task used by AssetsManager to load images
  56797. */
  56798. export class ImageAssetTask extends AbstractAssetTask {
  56799. /**
  56800. * Defines the name of the task
  56801. */
  56802. name: string;
  56803. /**
  56804. * Defines the location of the image to load
  56805. */
  56806. url: string;
  56807. /**
  56808. * Gets the loaded images
  56809. */
  56810. image: HTMLImageElement;
  56811. /**
  56812. * Callback called when the task is successful
  56813. */
  56814. onSuccess: (task: ImageAssetTask) => void;
  56815. /**
  56816. * Callback called when the task is successful
  56817. */
  56818. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56819. /**
  56820. * Creates a new ImageAssetTask
  56821. * @param name defines the name of the task
  56822. * @param url defines the location of the image to load
  56823. */
  56824. constructor(
  56825. /**
  56826. * Defines the name of the task
  56827. */
  56828. name: string,
  56829. /**
  56830. * Defines the location of the image to load
  56831. */
  56832. url: string);
  56833. /**
  56834. * Execute the current task
  56835. * @param scene defines the scene where you want your assets to be loaded
  56836. * @param onSuccess is a callback called when the task is successfully executed
  56837. * @param onError is a callback called if an error occurs
  56838. */
  56839. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56840. }
  56841. /**
  56842. * Defines the interface used by texture loading tasks
  56843. */
  56844. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56845. /**
  56846. * Gets the loaded texture
  56847. */
  56848. texture: TEX;
  56849. }
  56850. /**
  56851. * Define a task used by AssetsManager to load 2D textures
  56852. */
  56853. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56854. /**
  56855. * Defines the name of the task
  56856. */
  56857. name: string;
  56858. /**
  56859. * Defines the location of the file to load
  56860. */
  56861. url: string;
  56862. /**
  56863. * Defines if mipmap should not be generated (default is false)
  56864. */
  56865. noMipmap?: boolean | undefined;
  56866. /**
  56867. * Defines if texture must be inverted on Y axis (default is false)
  56868. */
  56869. invertY?: boolean | undefined;
  56870. /**
  56871. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56872. */
  56873. samplingMode: number;
  56874. /**
  56875. * Gets the loaded texture
  56876. */
  56877. texture: Texture;
  56878. /**
  56879. * Callback called when the task is successful
  56880. */
  56881. onSuccess: (task: TextureAssetTask) => void;
  56882. /**
  56883. * Callback called when the task is successful
  56884. */
  56885. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56886. /**
  56887. * Creates a new TextureAssetTask object
  56888. * @param name defines the name of the task
  56889. * @param url defines the location of the file to load
  56890. * @param noMipmap defines if mipmap should not be generated (default is false)
  56891. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56892. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56893. */
  56894. constructor(
  56895. /**
  56896. * Defines the name of the task
  56897. */
  56898. name: string,
  56899. /**
  56900. * Defines the location of the file to load
  56901. */
  56902. url: string,
  56903. /**
  56904. * Defines if mipmap should not be generated (default is false)
  56905. */
  56906. noMipmap?: boolean | undefined,
  56907. /**
  56908. * Defines if texture must be inverted on Y axis (default is false)
  56909. */
  56910. invertY?: boolean | undefined,
  56911. /**
  56912. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56913. */
  56914. samplingMode?: number);
  56915. /**
  56916. * Execute the current task
  56917. * @param scene defines the scene where you want your assets to be loaded
  56918. * @param onSuccess is a callback called when the task is successfully executed
  56919. * @param onError is a callback called if an error occurs
  56920. */
  56921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56922. }
  56923. /**
  56924. * Define a task used by AssetsManager to load cube textures
  56925. */
  56926. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56927. /**
  56928. * Defines the name of the task
  56929. */
  56930. name: string;
  56931. /**
  56932. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56933. */
  56934. url: string;
  56935. /**
  56936. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56937. */
  56938. extensions?: string[] | undefined;
  56939. /**
  56940. * Defines if mipmaps should not be generated (default is false)
  56941. */
  56942. noMipmap?: boolean | undefined;
  56943. /**
  56944. * Defines the explicit list of files (undefined by default)
  56945. */
  56946. files?: string[] | undefined;
  56947. /**
  56948. * Gets the loaded texture
  56949. */
  56950. texture: CubeTexture;
  56951. /**
  56952. * Callback called when the task is successful
  56953. */
  56954. onSuccess: (task: CubeTextureAssetTask) => void;
  56955. /**
  56956. * Callback called when the task is successful
  56957. */
  56958. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56959. /**
  56960. * Creates a new CubeTextureAssetTask
  56961. * @param name defines the name of the task
  56962. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56963. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56964. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56965. * @param files defines the explicit list of files (undefined by default)
  56966. */
  56967. constructor(
  56968. /**
  56969. * Defines the name of the task
  56970. */
  56971. name: string,
  56972. /**
  56973. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56974. */
  56975. url: string,
  56976. /**
  56977. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56978. */
  56979. extensions?: string[] | undefined,
  56980. /**
  56981. * Defines if mipmaps should not be generated (default is false)
  56982. */
  56983. noMipmap?: boolean | undefined,
  56984. /**
  56985. * Defines the explicit list of files (undefined by default)
  56986. */
  56987. files?: string[] | undefined);
  56988. /**
  56989. * Execute the current task
  56990. * @param scene defines the scene where you want your assets to be loaded
  56991. * @param onSuccess is a callback called when the task is successfully executed
  56992. * @param onError is a callback called if an error occurs
  56993. */
  56994. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56995. }
  56996. /**
  56997. * Define a task used by AssetsManager to load HDR cube textures
  56998. */
  56999. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57000. /**
  57001. * Defines the name of the task
  57002. */
  57003. name: string;
  57004. /**
  57005. * Defines the location of the file to load
  57006. */
  57007. url: string;
  57008. /**
  57009. * Defines the desired size (the more it increases the longer the generation will be)
  57010. */
  57011. size: number;
  57012. /**
  57013. * Defines if mipmaps should not be generated (default is false)
  57014. */
  57015. noMipmap: boolean;
  57016. /**
  57017. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57018. */
  57019. generateHarmonics: boolean;
  57020. /**
  57021. * 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)
  57022. */
  57023. gammaSpace: boolean;
  57024. /**
  57025. * Internal Use Only
  57026. */
  57027. reserved: boolean;
  57028. /**
  57029. * Gets the loaded texture
  57030. */
  57031. texture: HDRCubeTexture;
  57032. /**
  57033. * Callback called when the task is successful
  57034. */
  57035. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57036. /**
  57037. * Callback called when the task is successful
  57038. */
  57039. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57040. /**
  57041. * Creates a new HDRCubeTextureAssetTask object
  57042. * @param name defines the name of the task
  57043. * @param url defines the location of the file to load
  57044. * @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.
  57045. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57046. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57047. * @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)
  57048. * @param reserved Internal use only
  57049. */
  57050. constructor(
  57051. /**
  57052. * Defines the name of the task
  57053. */
  57054. name: string,
  57055. /**
  57056. * Defines the location of the file to load
  57057. */
  57058. url: string,
  57059. /**
  57060. * Defines the desired size (the more it increases the longer the generation will be)
  57061. */
  57062. size: number,
  57063. /**
  57064. * Defines if mipmaps should not be generated (default is false)
  57065. */
  57066. noMipmap?: boolean,
  57067. /**
  57068. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57069. */
  57070. generateHarmonics?: boolean,
  57071. /**
  57072. * 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)
  57073. */
  57074. gammaSpace?: boolean,
  57075. /**
  57076. * Internal Use Only
  57077. */
  57078. reserved?: boolean);
  57079. /**
  57080. * Execute the current task
  57081. * @param scene defines the scene where you want your assets to be loaded
  57082. * @param onSuccess is a callback called when the task is successfully executed
  57083. * @param onError is a callback called if an error occurs
  57084. */
  57085. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57086. }
  57087. /**
  57088. * This class can be used to easily import assets into a scene
  57089. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57090. */
  57091. export class AssetsManager {
  57092. private _scene;
  57093. private _isLoading;
  57094. protected _tasks: AbstractAssetTask[];
  57095. protected _waitingTasksCount: number;
  57096. protected _totalTasksCount: number;
  57097. /**
  57098. * Callback called when all tasks are processed
  57099. */
  57100. onFinish: (tasks: AbstractAssetTask[]) => void;
  57101. /**
  57102. * Callback called when a task is successful
  57103. */
  57104. onTaskSuccess: (task: AbstractAssetTask) => void;
  57105. /**
  57106. * Callback called when a task had an error
  57107. */
  57108. onTaskError: (task: AbstractAssetTask) => void;
  57109. /**
  57110. * Callback called when a task is done (whatever the result is)
  57111. */
  57112. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57113. /**
  57114. * Observable called when all tasks are processed
  57115. */
  57116. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57117. /**
  57118. * Observable called when a task had an error
  57119. */
  57120. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57121. /**
  57122. * Observable called when all tasks were executed
  57123. */
  57124. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57125. /**
  57126. * Observable called when a task is done (whatever the result is)
  57127. */
  57128. onProgressObservable: Observable<IAssetsProgressEvent>;
  57129. /**
  57130. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57132. */
  57133. useDefaultLoadingScreen: boolean;
  57134. /**
  57135. * Creates a new AssetsManager
  57136. * @param scene defines the scene to work on
  57137. */
  57138. constructor(scene: Scene);
  57139. /**
  57140. * Add a MeshAssetTask to the list of active tasks
  57141. * @param taskName defines the name of the new task
  57142. * @param meshesNames defines the name of meshes to load
  57143. * @param rootUrl defines the root url to use to locate files
  57144. * @param sceneFilename defines the filename of the scene file
  57145. * @returns a new MeshAssetTask object
  57146. */
  57147. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57148. /**
  57149. * Add a TextFileAssetTask to the list of active tasks
  57150. * @param taskName defines the name of the new task
  57151. * @param url defines the url of the file to load
  57152. * @returns a new TextFileAssetTask object
  57153. */
  57154. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57155. /**
  57156. * Add a BinaryFileAssetTask to the list of active tasks
  57157. * @param taskName defines the name of the new task
  57158. * @param url defines the url of the file to load
  57159. * @returns a new BinaryFileAssetTask object
  57160. */
  57161. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57162. /**
  57163. * Add a ImageAssetTask to the list of active tasks
  57164. * @param taskName defines the name of the new task
  57165. * @param url defines the url of the file to load
  57166. * @returns a new ImageAssetTask object
  57167. */
  57168. addImageTask(taskName: string, url: string): ImageAssetTask;
  57169. /**
  57170. * Add a TextureAssetTask to the list of active tasks
  57171. * @param taskName defines the name of the new task
  57172. * @param url defines the url of the file to load
  57173. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57174. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57175. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57176. * @returns a new TextureAssetTask object
  57177. */
  57178. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57179. /**
  57180. * Add a CubeTextureAssetTask to the list of active tasks
  57181. * @param taskName defines the name of the new task
  57182. * @param url defines the url of the file to load
  57183. * @param extensions defines the extension to use to load the cube map (can be null)
  57184. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57185. * @param files defines the list of files to load (can be null)
  57186. * @returns a new CubeTextureAssetTask object
  57187. */
  57188. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57189. /**
  57190. *
  57191. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57192. * @param taskName defines the name of the new task
  57193. * @param url defines the url of the file to load
  57194. * @param size defines the size you want for the cubemap (can be null)
  57195. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57196. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57197. * @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)
  57198. * @param reserved Internal use only
  57199. * @returns a new HDRCubeTextureAssetTask object
  57200. */
  57201. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57202. /**
  57203. * Remove a task from the assets manager.
  57204. * @param task the task to remove
  57205. */
  57206. removeTask(task: AbstractAssetTask): void;
  57207. private _decreaseWaitingTasksCount;
  57208. private _runTask;
  57209. /**
  57210. * Reset the AssetsManager and remove all tasks
  57211. * @return the current instance of the AssetsManager
  57212. */
  57213. reset(): AssetsManager;
  57214. /**
  57215. * Start the loading process
  57216. * @return the current instance of the AssetsManager
  57217. */
  57218. load(): AssetsManager;
  57219. /**
  57220. * Start the loading process as an async operation
  57221. * @return a promise returning the list of failed tasks
  57222. */
  57223. loadAsync(): Promise<void>;
  57224. }
  57225. }
  57226. declare module "babylonjs/Misc/deferred" {
  57227. /**
  57228. * Wrapper class for promise with external resolve and reject.
  57229. */
  57230. export class Deferred<T> {
  57231. /**
  57232. * The promise associated with this deferred object.
  57233. */
  57234. readonly promise: Promise<T>;
  57235. private _resolve;
  57236. private _reject;
  57237. /**
  57238. * The resolve method of the promise associated with this deferred object.
  57239. */
  57240. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57241. /**
  57242. * The reject method of the promise associated with this deferred object.
  57243. */
  57244. readonly reject: (reason?: any) => void;
  57245. /**
  57246. * Constructor for this deferred object.
  57247. */
  57248. constructor();
  57249. }
  57250. }
  57251. declare module "babylonjs/Misc/meshExploder" {
  57252. import { Mesh } from "babylonjs/Meshes/mesh";
  57253. /**
  57254. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57255. */
  57256. export class MeshExploder {
  57257. private _centerMesh;
  57258. private _meshes;
  57259. private _meshesOrigins;
  57260. private _toCenterVectors;
  57261. private _scaledDirection;
  57262. private _newPosition;
  57263. private _centerPosition;
  57264. /**
  57265. * Explodes meshes from a center mesh.
  57266. * @param meshes The meshes to explode.
  57267. * @param centerMesh The mesh to be center of explosion.
  57268. */
  57269. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57270. private _setCenterMesh;
  57271. /**
  57272. * Get class name
  57273. * @returns "MeshExploder"
  57274. */
  57275. getClassName(): string;
  57276. /**
  57277. * "Exploded meshes"
  57278. * @returns Array of meshes with the centerMesh at index 0.
  57279. */
  57280. getMeshes(): Array<Mesh>;
  57281. /**
  57282. * Explodes meshes giving a specific direction
  57283. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57284. */
  57285. explode(direction?: number): void;
  57286. }
  57287. }
  57288. declare module "babylonjs/Misc/filesInput" {
  57289. import { Engine } from "babylonjs/Engines/engine";
  57290. import { Scene } from "babylonjs/scene";
  57291. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57292. /**
  57293. * Class used to help managing file picking and drag'n'drop
  57294. */
  57295. export class FilesInput {
  57296. /**
  57297. * List of files ready to be loaded
  57298. */
  57299. static readonly FilesToLoad: {
  57300. [key: string]: File;
  57301. };
  57302. /**
  57303. * Callback called when a file is processed
  57304. */
  57305. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57306. private _engine;
  57307. private _currentScene;
  57308. private _sceneLoadedCallback;
  57309. private _progressCallback;
  57310. private _additionalRenderLoopLogicCallback;
  57311. private _textureLoadingCallback;
  57312. private _startingProcessingFilesCallback;
  57313. private _onReloadCallback;
  57314. private _errorCallback;
  57315. private _elementToMonitor;
  57316. private _sceneFileToLoad;
  57317. private _filesToLoad;
  57318. /**
  57319. * Creates a new FilesInput
  57320. * @param engine defines the rendering engine
  57321. * @param scene defines the hosting scene
  57322. * @param sceneLoadedCallback callback called when scene is loaded
  57323. * @param progressCallback callback called to track progress
  57324. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57325. * @param textureLoadingCallback callback called when a texture is loading
  57326. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57327. * @param onReloadCallback callback called when a reload is requested
  57328. * @param errorCallback callback call if an error occurs
  57329. */
  57330. 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);
  57331. private _dragEnterHandler;
  57332. private _dragOverHandler;
  57333. private _dropHandler;
  57334. /**
  57335. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57336. * @param elementToMonitor defines the DOM element to track
  57337. */
  57338. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57339. /**
  57340. * Release all associated resources
  57341. */
  57342. dispose(): void;
  57343. private renderFunction;
  57344. private drag;
  57345. private drop;
  57346. private _traverseFolder;
  57347. private _processFiles;
  57348. /**
  57349. * Load files from a drop event
  57350. * @param event defines the drop event to use as source
  57351. */
  57352. loadFiles(event: any): void;
  57353. private _processReload;
  57354. /**
  57355. * Reload the current scene from the loaded files
  57356. */
  57357. reload(): void;
  57358. }
  57359. }
  57360. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57361. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57362. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57363. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57364. }
  57365. declare module "babylonjs/Misc/sceneOptimizer" {
  57366. import { Scene, IDisposable } from "babylonjs/scene";
  57367. import { Observable } from "babylonjs/Misc/observable";
  57368. /**
  57369. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57370. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57371. */
  57372. export class SceneOptimization {
  57373. /**
  57374. * Defines the priority of this optimization (0 by default which means first in the list)
  57375. */
  57376. priority: number;
  57377. /**
  57378. * Gets a string describing the action executed by the current optimization
  57379. * @returns description string
  57380. */
  57381. getDescription(): string;
  57382. /**
  57383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57384. * @param scene defines the current scene where to apply this optimization
  57385. * @param optimizer defines the current optimizer
  57386. * @returns true if everything that can be done was applied
  57387. */
  57388. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57389. /**
  57390. * Creates the SceneOptimization object
  57391. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57392. * @param desc defines the description associated with the optimization
  57393. */
  57394. constructor(
  57395. /**
  57396. * Defines the priority of this optimization (0 by default which means first in the list)
  57397. */
  57398. priority?: number);
  57399. }
  57400. /**
  57401. * Defines an optimization used to reduce the size of render target textures
  57402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57403. */
  57404. export class TextureOptimization extends SceneOptimization {
  57405. /**
  57406. * Defines the priority of this optimization (0 by default which means first in the list)
  57407. */
  57408. priority: number;
  57409. /**
  57410. * 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
  57411. */
  57412. maximumSize: number;
  57413. /**
  57414. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57415. */
  57416. step: number;
  57417. /**
  57418. * Gets a string describing the action executed by the current optimization
  57419. * @returns description string
  57420. */
  57421. getDescription(): string;
  57422. /**
  57423. * Creates the TextureOptimization object
  57424. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57425. * @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
  57426. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57427. */
  57428. constructor(
  57429. /**
  57430. * Defines the priority of this optimization (0 by default which means first in the list)
  57431. */
  57432. priority?: number,
  57433. /**
  57434. * 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
  57435. */
  57436. maximumSize?: number,
  57437. /**
  57438. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57439. */
  57440. step?: number);
  57441. /**
  57442. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57443. * @param scene defines the current scene where to apply this optimization
  57444. * @param optimizer defines the current optimizer
  57445. * @returns true if everything that can be done was applied
  57446. */
  57447. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57448. }
  57449. /**
  57450. * Defines an optimization used to increase or decrease the rendering resolution
  57451. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57452. */
  57453. export class HardwareScalingOptimization extends SceneOptimization {
  57454. /**
  57455. * Defines the priority of this optimization (0 by default which means first in the list)
  57456. */
  57457. priority: number;
  57458. /**
  57459. * Defines the maximum scale to use (2 by default)
  57460. */
  57461. maximumScale: number;
  57462. /**
  57463. * Defines the step to use between two passes (0.5 by default)
  57464. */
  57465. step: number;
  57466. private _currentScale;
  57467. private _directionOffset;
  57468. /**
  57469. * Gets a string describing the action executed by the current optimization
  57470. * @return description string
  57471. */
  57472. getDescription(): string;
  57473. /**
  57474. * Creates the HardwareScalingOptimization object
  57475. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57476. * @param maximumScale defines the maximum scale to use (2 by default)
  57477. * @param step defines the step to use between two passes (0.5 by default)
  57478. */
  57479. constructor(
  57480. /**
  57481. * Defines the priority of this optimization (0 by default which means first in the list)
  57482. */
  57483. priority?: number,
  57484. /**
  57485. * Defines the maximum scale to use (2 by default)
  57486. */
  57487. maximumScale?: number,
  57488. /**
  57489. * Defines the step to use between two passes (0.5 by default)
  57490. */
  57491. step?: number);
  57492. /**
  57493. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57494. * @param scene defines the current scene where to apply this optimization
  57495. * @param optimizer defines the current optimizer
  57496. * @returns true if everything that can be done was applied
  57497. */
  57498. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57499. }
  57500. /**
  57501. * Defines an optimization used to remove shadows
  57502. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57503. */
  57504. export class ShadowsOptimization extends SceneOptimization {
  57505. /**
  57506. * Gets a string describing the action executed by the current optimization
  57507. * @return description string
  57508. */
  57509. getDescription(): string;
  57510. /**
  57511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57512. * @param scene defines the current scene where to apply this optimization
  57513. * @param optimizer defines the current optimizer
  57514. * @returns true if everything that can be done was applied
  57515. */
  57516. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57517. }
  57518. /**
  57519. * Defines an optimization used to turn post-processes off
  57520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57521. */
  57522. export class PostProcessesOptimization extends SceneOptimization {
  57523. /**
  57524. * Gets a string describing the action executed by the current optimization
  57525. * @return description string
  57526. */
  57527. getDescription(): string;
  57528. /**
  57529. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57530. * @param scene defines the current scene where to apply this optimization
  57531. * @param optimizer defines the current optimizer
  57532. * @returns true if everything that can be done was applied
  57533. */
  57534. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57535. }
  57536. /**
  57537. * Defines an optimization used to turn lens flares off
  57538. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57539. */
  57540. export class LensFlaresOptimization extends SceneOptimization {
  57541. /**
  57542. * Gets a string describing the action executed by the current optimization
  57543. * @return description string
  57544. */
  57545. getDescription(): string;
  57546. /**
  57547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57548. * @param scene defines the current scene where to apply this optimization
  57549. * @param optimizer defines the current optimizer
  57550. * @returns true if everything that can be done was applied
  57551. */
  57552. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57553. }
  57554. /**
  57555. * Defines an optimization based on user defined callback.
  57556. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57557. */
  57558. export class CustomOptimization extends SceneOptimization {
  57559. /**
  57560. * Callback called to apply the custom optimization.
  57561. */
  57562. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57563. /**
  57564. * Callback called to get custom description
  57565. */
  57566. onGetDescription: () => string;
  57567. /**
  57568. * Gets a string describing the action executed by the current optimization
  57569. * @returns description string
  57570. */
  57571. getDescription(): string;
  57572. /**
  57573. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57574. * @param scene defines the current scene where to apply this optimization
  57575. * @param optimizer defines the current optimizer
  57576. * @returns true if everything that can be done was applied
  57577. */
  57578. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57579. }
  57580. /**
  57581. * Defines an optimization used to turn particles off
  57582. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57583. */
  57584. export class ParticlesOptimization extends SceneOptimization {
  57585. /**
  57586. * Gets a string describing the action executed by the current optimization
  57587. * @return description string
  57588. */
  57589. getDescription(): string;
  57590. /**
  57591. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57592. * @param scene defines the current scene where to apply this optimization
  57593. * @param optimizer defines the current optimizer
  57594. * @returns true if everything that can be done was applied
  57595. */
  57596. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57597. }
  57598. /**
  57599. * Defines an optimization used to turn render targets off
  57600. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57601. */
  57602. export class RenderTargetsOptimization extends SceneOptimization {
  57603. /**
  57604. * Gets a string describing the action executed by the current optimization
  57605. * @return description string
  57606. */
  57607. getDescription(): string;
  57608. /**
  57609. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57610. * @param scene defines the current scene where to apply this optimization
  57611. * @param optimizer defines the current optimizer
  57612. * @returns true if everything that can be done was applied
  57613. */
  57614. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57615. }
  57616. /**
  57617. * Defines an optimization used to merge meshes with compatible materials
  57618. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57619. */
  57620. export class MergeMeshesOptimization extends SceneOptimization {
  57621. private static _UpdateSelectionTree;
  57622. /**
  57623. * Gets or sets a boolean which defines if optimization octree has to be updated
  57624. */
  57625. /**
  57626. * Gets or sets a boolean which defines if optimization octree has to be updated
  57627. */
  57628. static UpdateSelectionTree: boolean;
  57629. /**
  57630. * Gets a string describing the action executed by the current optimization
  57631. * @return description string
  57632. */
  57633. getDescription(): string;
  57634. private _canBeMerged;
  57635. /**
  57636. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57637. * @param scene defines the current scene where to apply this optimization
  57638. * @param optimizer defines the current optimizer
  57639. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57640. * @returns true if everything that can be done was applied
  57641. */
  57642. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57643. }
  57644. /**
  57645. * Defines a list of options used by SceneOptimizer
  57646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57647. */
  57648. export class SceneOptimizerOptions {
  57649. /**
  57650. * Defines the target frame rate to reach (60 by default)
  57651. */
  57652. targetFrameRate: number;
  57653. /**
  57654. * Defines the interval between two checkes (2000ms by default)
  57655. */
  57656. trackerDuration: number;
  57657. /**
  57658. * Gets the list of optimizations to apply
  57659. */
  57660. optimizations: SceneOptimization[];
  57661. /**
  57662. * Creates a new list of options used by SceneOptimizer
  57663. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57664. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57665. */
  57666. constructor(
  57667. /**
  57668. * Defines the target frame rate to reach (60 by default)
  57669. */
  57670. targetFrameRate?: number,
  57671. /**
  57672. * Defines the interval between two checkes (2000ms by default)
  57673. */
  57674. trackerDuration?: number);
  57675. /**
  57676. * Add a new optimization
  57677. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57678. * @returns the current SceneOptimizerOptions
  57679. */
  57680. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57681. /**
  57682. * Add a new custom optimization
  57683. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57684. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57685. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57686. * @returns the current SceneOptimizerOptions
  57687. */
  57688. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57689. /**
  57690. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57691. * @param targetFrameRate defines the target frame rate (60 by default)
  57692. * @returns a SceneOptimizerOptions object
  57693. */
  57694. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57695. /**
  57696. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57697. * @param targetFrameRate defines the target frame rate (60 by default)
  57698. * @returns a SceneOptimizerOptions object
  57699. */
  57700. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57701. /**
  57702. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57703. * @param targetFrameRate defines the target frame rate (60 by default)
  57704. * @returns a SceneOptimizerOptions object
  57705. */
  57706. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57707. }
  57708. /**
  57709. * Class used to run optimizations in order to reach a target frame rate
  57710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57711. */
  57712. export class SceneOptimizer implements IDisposable {
  57713. private _isRunning;
  57714. private _options;
  57715. private _scene;
  57716. private _currentPriorityLevel;
  57717. private _targetFrameRate;
  57718. private _trackerDuration;
  57719. private _currentFrameRate;
  57720. private _sceneDisposeObserver;
  57721. private _improvementMode;
  57722. /**
  57723. * Defines an observable called when the optimizer reaches the target frame rate
  57724. */
  57725. onSuccessObservable: Observable<SceneOptimizer>;
  57726. /**
  57727. * Defines an observable called when the optimizer enables an optimization
  57728. */
  57729. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57730. /**
  57731. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57732. */
  57733. onFailureObservable: Observable<SceneOptimizer>;
  57734. /**
  57735. * Gets a boolean indicating if the optimizer is in improvement mode
  57736. */
  57737. readonly isInImprovementMode: boolean;
  57738. /**
  57739. * Gets the current priority level (0 at start)
  57740. */
  57741. readonly currentPriorityLevel: number;
  57742. /**
  57743. * Gets the current frame rate checked by the SceneOptimizer
  57744. */
  57745. readonly currentFrameRate: number;
  57746. /**
  57747. * Gets or sets the current target frame rate (60 by default)
  57748. */
  57749. /**
  57750. * Gets or sets the current target frame rate (60 by default)
  57751. */
  57752. targetFrameRate: number;
  57753. /**
  57754. * Gets or sets the current interval between two checks (every 2000ms by default)
  57755. */
  57756. /**
  57757. * Gets or sets the current interval between two checks (every 2000ms by default)
  57758. */
  57759. trackerDuration: number;
  57760. /**
  57761. * Gets the list of active optimizations
  57762. */
  57763. readonly optimizations: SceneOptimization[];
  57764. /**
  57765. * Creates a new SceneOptimizer
  57766. * @param scene defines the scene to work on
  57767. * @param options defines the options to use with the SceneOptimizer
  57768. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57769. * @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)
  57770. */
  57771. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57772. /**
  57773. * Stops the current optimizer
  57774. */
  57775. stop(): void;
  57776. /**
  57777. * Reset the optimizer to initial step (current priority level = 0)
  57778. */
  57779. reset(): void;
  57780. /**
  57781. * Start the optimizer. By default it will try to reach a specific framerate
  57782. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57783. */
  57784. start(): void;
  57785. private _checkCurrentState;
  57786. /**
  57787. * Release all resources
  57788. */
  57789. dispose(): void;
  57790. /**
  57791. * Helper function to create a SceneOptimizer with one single line of code
  57792. * @param scene defines the scene to work on
  57793. * @param options defines the options to use with the SceneOptimizer
  57794. * @param onSuccess defines a callback to call on success
  57795. * @param onFailure defines a callback to call on failure
  57796. * @returns the new SceneOptimizer object
  57797. */
  57798. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57799. }
  57800. }
  57801. declare module "babylonjs/Misc/sceneSerializer" {
  57802. import { Scene } from "babylonjs/scene";
  57803. /**
  57804. * Class used to serialize a scene into a string
  57805. */
  57806. export class SceneSerializer {
  57807. /**
  57808. * Clear cache used by a previous serialization
  57809. */
  57810. static ClearCache(): void;
  57811. /**
  57812. * Serialize a scene into a JSON compatible object
  57813. * @param scene defines the scene to serialize
  57814. * @returns a JSON compatible object
  57815. */
  57816. static Serialize(scene: Scene): any;
  57817. /**
  57818. * Serialize a mesh into a JSON compatible object
  57819. * @param toSerialize defines the mesh to serialize
  57820. * @param withParents defines if parents must be serialized as well
  57821. * @param withChildren defines if children must be serialized as well
  57822. * @returns a JSON compatible object
  57823. */
  57824. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57825. }
  57826. }
  57827. declare module "babylonjs/Misc/videoRecorder" {
  57828. import { Nullable } from "babylonjs/types";
  57829. import { Engine } from "babylonjs/Engines/engine";
  57830. /**
  57831. * This represents the different options avilable for the video capture.
  57832. */
  57833. export interface VideoRecorderOptions {
  57834. /** Defines the mime type of the video */
  57835. mimeType: string;
  57836. /** Defines the video the video should be recorded at */
  57837. fps: number;
  57838. /** Defines the chunk size for the recording data */
  57839. recordChunckSize: number;
  57840. /** The audio tracks to attach to the record */
  57841. audioTracks?: MediaStreamTrack[];
  57842. }
  57843. /**
  57844. * This can helps recording videos from BabylonJS.
  57845. * This is based on the available WebRTC functionalities of the browser.
  57846. *
  57847. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57848. */
  57849. export class VideoRecorder {
  57850. private static readonly _defaultOptions;
  57851. /**
  57852. * Returns wehther or not the VideoRecorder is available in your browser.
  57853. * @param engine Defines the Babylon Engine to check the support for
  57854. * @returns true if supported otherwise false
  57855. */
  57856. static IsSupported(engine: Engine): boolean;
  57857. private readonly _options;
  57858. private _canvas;
  57859. private _mediaRecorder;
  57860. private _recordedChunks;
  57861. private _fileName;
  57862. private _resolve;
  57863. private _reject;
  57864. /**
  57865. * True wether a recording is already in progress.
  57866. */
  57867. readonly isRecording: boolean;
  57868. /**
  57869. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57870. * a video file.
  57871. * @param engine Defines the BabylonJS Engine you wish to record
  57872. * @param options Defines options that can be used to customized the capture
  57873. */
  57874. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57875. /**
  57876. * Stops the current recording before the default capture timeout passed in the startRecording
  57877. * functions.
  57878. */
  57879. stopRecording(): void;
  57880. /**
  57881. * Starts recording the canvas for a max duration specified in parameters.
  57882. * @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.
  57883. * @param maxDuration Defines the maximum recording time in seconds.
  57884. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57885. * @return a promise callback at the end of the recording with the video data in Blob.
  57886. */
  57887. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57888. /**
  57889. * Releases internal resources used during the recording.
  57890. */
  57891. dispose(): void;
  57892. private _handleDataAvailable;
  57893. private _handleError;
  57894. private _handleStop;
  57895. }
  57896. }
  57897. declare module "babylonjs/Misc/workerPool" {
  57898. import { IDisposable } from "babylonjs/scene";
  57899. /**
  57900. * Helper class to push actions to a pool of workers.
  57901. */
  57902. export class WorkerPool implements IDisposable {
  57903. private _workerInfos;
  57904. private _pendingActions;
  57905. /**
  57906. * Constructor
  57907. * @param workers Array of workers to use for actions
  57908. */
  57909. constructor(workers: Array<Worker>);
  57910. /**
  57911. * Terminates all workers and clears any pending actions.
  57912. */
  57913. dispose(): void;
  57914. /**
  57915. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57916. * pended until a worker has completed its action.
  57917. * @param action The action to perform. Call onComplete when the action is complete.
  57918. */
  57919. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57920. private _execute;
  57921. }
  57922. }
  57923. declare module "babylonjs/Misc/screenshotTools" {
  57924. import { Camera } from "babylonjs/Cameras/camera";
  57925. import { Engine } from "babylonjs/Engines/engine";
  57926. /**
  57927. * Class containing a set of static utilities functions for screenshots
  57928. */
  57929. export class ScreenshotTools {
  57930. /**
  57931. * Captures a screenshot of the current rendering
  57932. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57933. * @param engine defines the rendering engine
  57934. * @param camera defines the source camera
  57935. * @param size This parameter can be set to a single number or to an object with the
  57936. * following (optional) properties: precision, width, height. If a single number is passed,
  57937. * it will be used for both width and height. If an object is passed, the screenshot size
  57938. * will be derived from the parameters. The precision property is a multiplier allowing
  57939. * rendering at a higher or lower resolution
  57940. * @param successCallback defines the callback receives a single parameter which contains the
  57941. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57942. * src parameter of an <img> to display it
  57943. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57944. * Check your browser for supported MIME types
  57945. */
  57946. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57947. /**
  57948. * Generates an image screenshot from the specified camera.
  57949. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57950. * @param engine The engine to use for rendering
  57951. * @param camera The camera to use for rendering
  57952. * @param size This parameter can be set to a single number or to an object with the
  57953. * following (optional) properties: precision, width, height. If a single number is passed,
  57954. * it will be used for both width and height. If an object is passed, the screenshot size
  57955. * will be derived from the parameters. The precision property is a multiplier allowing
  57956. * rendering at a higher or lower resolution
  57957. * @param successCallback The callback receives a single parameter which contains the
  57958. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57959. * src parameter of an <img> to display it
  57960. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57961. * Check your browser for supported MIME types
  57962. * @param samples Texture samples (default: 1)
  57963. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57964. * @param fileName A name for for the downloaded file.
  57965. */
  57966. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57967. }
  57968. }
  57969. declare module "babylonjs/Misc/index" {
  57970. export * from "babylonjs/Misc/andOrNotEvaluator";
  57971. export * from "babylonjs/Misc/assetsManager";
  57972. export * from "babylonjs/Misc/dds";
  57973. export * from "babylonjs/Misc/decorators";
  57974. export * from "babylonjs/Misc/deferred";
  57975. export * from "babylonjs/Misc/environmentTextureTools";
  57976. export * from "babylonjs/Misc/meshExploder";
  57977. export * from "babylonjs/Misc/filesInput";
  57978. export * from "babylonjs/Misc/HighDynamicRange/index";
  57979. export * from "babylonjs/Misc/khronosTextureContainer";
  57980. export * from "babylonjs/Misc/observable";
  57981. export * from "babylonjs/Misc/performanceMonitor";
  57982. export * from "babylonjs/Misc/promise";
  57983. export * from "babylonjs/Misc/sceneOptimizer";
  57984. export * from "babylonjs/Misc/sceneSerializer";
  57985. export * from "babylonjs/Misc/smartArray";
  57986. export * from "babylonjs/Misc/stringDictionary";
  57987. export * from "babylonjs/Misc/tags";
  57988. export * from "babylonjs/Misc/textureTools";
  57989. export * from "babylonjs/Misc/tga";
  57990. export * from "babylonjs/Misc/tools";
  57991. export * from "babylonjs/Misc/videoRecorder";
  57992. export * from "babylonjs/Misc/virtualJoystick";
  57993. export * from "babylonjs/Misc/workerPool";
  57994. export * from "babylonjs/Misc/logger";
  57995. export * from "babylonjs/Misc/typeStore";
  57996. export * from "babylonjs/Misc/filesInputStore";
  57997. export * from "babylonjs/Misc/deepCopier";
  57998. export * from "babylonjs/Misc/pivotTools";
  57999. export * from "babylonjs/Misc/precisionDate";
  58000. export * from "babylonjs/Misc/screenshotTools";
  58001. export * from "babylonjs/Misc/typeStore";
  58002. export * from "babylonjs/Misc/webRequest";
  58003. export * from "babylonjs/Misc/iInspectable";
  58004. }
  58005. declare module "babylonjs/index" {
  58006. export * from "babylonjs/abstractScene";
  58007. export * from "babylonjs/Actions/index";
  58008. export * from "babylonjs/Animations/index";
  58009. export * from "babylonjs/assetContainer";
  58010. export * from "babylonjs/Audio/index";
  58011. export * from "babylonjs/Behaviors/index";
  58012. export * from "babylonjs/Bones/index";
  58013. export * from "babylonjs/Cameras/index";
  58014. export * from "babylonjs/Collisions/index";
  58015. export * from "babylonjs/Culling/index";
  58016. export * from "babylonjs/Debug/index";
  58017. export * from "babylonjs/Engines/index";
  58018. export * from "babylonjs/Events/index";
  58019. export * from "babylonjs/Gamepads/index";
  58020. export * from "babylonjs/Gizmos/index";
  58021. export * from "babylonjs/Helpers/index";
  58022. export * from "babylonjs/Instrumentation/index";
  58023. export * from "babylonjs/Layers/index";
  58024. export * from "babylonjs/LensFlares/index";
  58025. export * from "babylonjs/Lights/index";
  58026. export * from "babylonjs/Loading/index";
  58027. export * from "babylonjs/Materials/index";
  58028. export * from "babylonjs/Maths/index";
  58029. export * from "babylonjs/Meshes/index";
  58030. export * from "babylonjs/Morph/index";
  58031. export * from "babylonjs/node";
  58032. export * from "babylonjs/Offline/index";
  58033. export * from "babylonjs/Particles/index";
  58034. export * from "babylonjs/Physics/index";
  58035. export * from "babylonjs/PostProcesses/index";
  58036. export * from "babylonjs/Probes/index";
  58037. export * from "babylonjs/Rendering/index";
  58038. export * from "babylonjs/scene";
  58039. export * from "babylonjs/sceneComponent";
  58040. export * from "babylonjs/Sprites/index";
  58041. export * from "babylonjs/States/index";
  58042. export * from "babylonjs/Misc/index";
  58043. export * from "babylonjs/types";
  58044. }
  58045. declare module "babylonjs/Animations/pathCursor" {
  58046. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58047. /**
  58048. * A cursor which tracks a point on a path
  58049. */
  58050. export class PathCursor {
  58051. private path;
  58052. /**
  58053. * Stores path cursor callbacks for when an onchange event is triggered
  58054. */
  58055. private _onchange;
  58056. /**
  58057. * The value of the path cursor
  58058. */
  58059. value: number;
  58060. /**
  58061. * The animation array of the path cursor
  58062. */
  58063. animations: Animation[];
  58064. /**
  58065. * Initializes the path cursor
  58066. * @param path The path to track
  58067. */
  58068. constructor(path: Path2);
  58069. /**
  58070. * Gets the cursor point on the path
  58071. * @returns A point on the path cursor at the cursor location
  58072. */
  58073. getPoint(): Vector3;
  58074. /**
  58075. * Moves the cursor ahead by the step amount
  58076. * @param step The amount to move the cursor forward
  58077. * @returns This path cursor
  58078. */
  58079. moveAhead(step?: number): PathCursor;
  58080. /**
  58081. * Moves the cursor behind by the step amount
  58082. * @param step The amount to move the cursor back
  58083. * @returns This path cursor
  58084. */
  58085. moveBack(step?: number): PathCursor;
  58086. /**
  58087. * Moves the cursor by the step amount
  58088. * If the step amount is greater than one, an exception is thrown
  58089. * @param step The amount to move the cursor
  58090. * @returns This path cursor
  58091. */
  58092. move(step: number): PathCursor;
  58093. /**
  58094. * Ensures that the value is limited between zero and one
  58095. * @returns This path cursor
  58096. */
  58097. private ensureLimits;
  58098. /**
  58099. * Runs onchange callbacks on change (used by the animation engine)
  58100. * @returns This path cursor
  58101. */
  58102. private raiseOnChange;
  58103. /**
  58104. * Executes a function on change
  58105. * @param f A path cursor onchange callback
  58106. * @returns This path cursor
  58107. */
  58108. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58109. }
  58110. }
  58111. declare module "babylonjs/Legacy/legacy" {
  58112. import * as Babylon from "babylonjs/index";
  58113. export * from "babylonjs/index";
  58114. }
  58115. declare module "babylonjs/Shaders/blur.fragment" {
  58116. /** @hidden */
  58117. export var blurPixelShader: {
  58118. name: string;
  58119. shader: string;
  58120. };
  58121. }
  58122. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  58123. /** @hidden */
  58124. export var vrMultiviewToSingleviewPixelShader: {
  58125. name: string;
  58126. shader: string;
  58127. };
  58128. }
  58129. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58130. /** @hidden */
  58131. export var bones300Declaration: {
  58132. name: string;
  58133. shader: string;
  58134. };
  58135. }
  58136. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58137. /** @hidden */
  58138. export var instances300Declaration: {
  58139. name: string;
  58140. shader: string;
  58141. };
  58142. }
  58143. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58144. /** @hidden */
  58145. export var pointCloudVertexDeclaration: {
  58146. name: string;
  58147. shader: string;
  58148. };
  58149. }
  58150. // Mixins
  58151. interface Window {
  58152. mozIndexedDB: IDBFactory;
  58153. webkitIndexedDB: IDBFactory;
  58154. msIndexedDB: IDBFactory;
  58155. webkitURL: typeof URL;
  58156. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58157. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58158. WebGLRenderingContext: WebGLRenderingContext;
  58159. MSGesture: MSGesture;
  58160. CANNON: any;
  58161. AudioContext: AudioContext;
  58162. webkitAudioContext: AudioContext;
  58163. PointerEvent: any;
  58164. Math: Math;
  58165. Uint8Array: Uint8ArrayConstructor;
  58166. Float32Array: Float32ArrayConstructor;
  58167. mozURL: typeof URL;
  58168. msURL: typeof URL;
  58169. VRFrameData: any; // WebVR, from specs 1.1
  58170. DracoDecoderModule: any;
  58171. setImmediate(handler: (...args: any[]) => void): number;
  58172. }
  58173. interface HTMLCanvasElement {
  58174. requestPointerLock(): void;
  58175. msRequestPointerLock?(): void;
  58176. mozRequestPointerLock?(): void;
  58177. webkitRequestPointerLock?(): void;
  58178. /** Track wether a record is in progress */
  58179. isRecording: boolean;
  58180. /** Capture Stream method defined by some browsers */
  58181. captureStream(fps?: number): MediaStream;
  58182. }
  58183. interface CanvasRenderingContext2D {
  58184. msImageSmoothingEnabled: boolean;
  58185. }
  58186. interface MouseEvent {
  58187. mozMovementX: number;
  58188. mozMovementY: number;
  58189. webkitMovementX: number;
  58190. webkitMovementY: number;
  58191. msMovementX: number;
  58192. msMovementY: number;
  58193. }
  58194. interface Navigator {
  58195. mozGetVRDevices: (any: any) => any;
  58196. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58197. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58198. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58199. webkitGetGamepads(): Gamepad[];
  58200. msGetGamepads(): Gamepad[];
  58201. webkitGamepads(): Gamepad[];
  58202. }
  58203. interface HTMLVideoElement {
  58204. mozSrcObject: any;
  58205. }
  58206. interface Math {
  58207. fround(x: number): number;
  58208. imul(a: number, b: number): number;
  58209. }
  58210. interface WebGLProgram {
  58211. context?: WebGLRenderingContext;
  58212. vertexShader?: WebGLShader;
  58213. fragmentShader?: WebGLShader;
  58214. isParallelCompiled: boolean;
  58215. onCompiled?: () => void;
  58216. }
  58217. interface WebGLRenderingContext {
  58218. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58219. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58220. vertexAttribDivisor(index: number, divisor: number): void;
  58221. createVertexArray(): any;
  58222. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58223. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58224. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58225. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58226. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58227. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58228. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58229. // Queries
  58230. createQuery(): WebGLQuery;
  58231. deleteQuery(query: WebGLQuery): void;
  58232. beginQuery(target: number, query: WebGLQuery): void;
  58233. endQuery(target: number): void;
  58234. getQueryParameter(query: WebGLQuery, pname: number): any;
  58235. getQuery(target: number, pname: number): any;
  58236. MAX_SAMPLES: number;
  58237. RGBA8: number;
  58238. READ_FRAMEBUFFER: number;
  58239. DRAW_FRAMEBUFFER: number;
  58240. UNIFORM_BUFFER: number;
  58241. HALF_FLOAT_OES: number;
  58242. RGBA16F: number;
  58243. RGBA32F: number;
  58244. R32F: number;
  58245. RG32F: number;
  58246. RGB32F: number;
  58247. R16F: number;
  58248. RG16F: number;
  58249. RGB16F: number;
  58250. RED: number;
  58251. RG: number;
  58252. R8: number;
  58253. RG8: number;
  58254. UNSIGNED_INT_24_8: number;
  58255. DEPTH24_STENCIL8: number;
  58256. /* Multiple Render Targets */
  58257. drawBuffers(buffers: number[]): void;
  58258. readBuffer(src: number): void;
  58259. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58260. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58261. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58262. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58263. // Occlusion Query
  58264. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58265. ANY_SAMPLES_PASSED: number;
  58266. QUERY_RESULT_AVAILABLE: number;
  58267. QUERY_RESULT: number;
  58268. }
  58269. interface WebGLBuffer {
  58270. references: number;
  58271. capacity: number;
  58272. is32Bits: boolean;
  58273. }
  58274. interface WebGLProgram {
  58275. transformFeedback?: WebGLTransformFeedback | null;
  58276. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58277. }
  58278. interface EXT_disjoint_timer_query {
  58279. QUERY_COUNTER_BITS_EXT: number;
  58280. TIME_ELAPSED_EXT: number;
  58281. TIMESTAMP_EXT: number;
  58282. GPU_DISJOINT_EXT: number;
  58283. QUERY_RESULT_EXT: number;
  58284. QUERY_RESULT_AVAILABLE_EXT: number;
  58285. queryCounterEXT(query: WebGLQuery, target: number): void;
  58286. createQueryEXT(): WebGLQuery;
  58287. beginQueryEXT(target: number, query: WebGLQuery): void;
  58288. endQueryEXT(target: number): void;
  58289. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58290. deleteQueryEXT(query: WebGLQuery): void;
  58291. }
  58292. interface WebGLUniformLocation {
  58293. _currentState: any;
  58294. }
  58295. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58296. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58297. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58298. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58299. interface WebGLRenderingContext {
  58300. readonly RASTERIZER_DISCARD: number;
  58301. readonly DEPTH_COMPONENT24: number;
  58302. readonly TEXTURE_3D: number;
  58303. readonly TEXTURE_2D_ARRAY: number;
  58304. readonly TEXTURE_COMPARE_FUNC: number;
  58305. readonly TEXTURE_COMPARE_MODE: number;
  58306. readonly COMPARE_REF_TO_TEXTURE: number;
  58307. readonly TEXTURE_WRAP_R: number;
  58308. readonly HALF_FLOAT: number;
  58309. readonly RGB8: number;
  58310. readonly RED_INTEGER: number;
  58311. readonly RG_INTEGER: number;
  58312. readonly RGB_INTEGER: number;
  58313. readonly RGBA_INTEGER: number;
  58314. readonly R8_SNORM: number;
  58315. readonly RG8_SNORM: number;
  58316. readonly RGB8_SNORM: number;
  58317. readonly RGBA8_SNORM: number;
  58318. readonly R8I: number;
  58319. readonly RG8I: number;
  58320. readonly RGB8I: number;
  58321. readonly RGBA8I: number;
  58322. readonly R8UI: number;
  58323. readonly RG8UI: number;
  58324. readonly RGB8UI: number;
  58325. readonly RGBA8UI: number;
  58326. readonly R16I: number;
  58327. readonly RG16I: number;
  58328. readonly RGB16I: number;
  58329. readonly RGBA16I: number;
  58330. readonly R16UI: number;
  58331. readonly RG16UI: number;
  58332. readonly RGB16UI: number;
  58333. readonly RGBA16UI: number;
  58334. readonly R32I: number;
  58335. readonly RG32I: number;
  58336. readonly RGB32I: number;
  58337. readonly RGBA32I: number;
  58338. readonly R32UI: number;
  58339. readonly RG32UI: number;
  58340. readonly RGB32UI: number;
  58341. readonly RGBA32UI: number;
  58342. readonly RGB10_A2UI: number;
  58343. readonly R11F_G11F_B10F: number;
  58344. readonly RGB9_E5: number;
  58345. readonly RGB10_A2: number;
  58346. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58347. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58348. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58349. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58350. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58351. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58352. 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;
  58353. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58354. readonly TRANSFORM_FEEDBACK: number;
  58355. readonly INTERLEAVED_ATTRIBS: number;
  58356. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58357. createTransformFeedback(): WebGLTransformFeedback;
  58358. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58359. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58360. beginTransformFeedback(primitiveMode: number): void;
  58361. endTransformFeedback(): void;
  58362. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58363. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58364. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58365. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58366. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58367. }
  58368. interface ImageBitmap {
  58369. readonly width: number;
  58370. readonly height: number;
  58371. close(): void;
  58372. }
  58373. interface WebGLQuery extends WebGLObject {
  58374. }
  58375. declare var WebGLQuery: {
  58376. prototype: WebGLQuery;
  58377. new(): WebGLQuery;
  58378. };
  58379. interface WebGLSampler extends WebGLObject {
  58380. }
  58381. declare var WebGLSampler: {
  58382. prototype: WebGLSampler;
  58383. new(): WebGLSampler;
  58384. };
  58385. interface WebGLSync extends WebGLObject {
  58386. }
  58387. declare var WebGLSync: {
  58388. prototype: WebGLSync;
  58389. new(): WebGLSync;
  58390. };
  58391. interface WebGLTransformFeedback extends WebGLObject {
  58392. }
  58393. declare var WebGLTransformFeedback: {
  58394. prototype: WebGLTransformFeedback;
  58395. new(): WebGLTransformFeedback;
  58396. };
  58397. interface WebGLVertexArrayObject extends WebGLObject {
  58398. }
  58399. declare var WebGLVertexArrayObject: {
  58400. prototype: WebGLVertexArrayObject;
  58401. new(): WebGLVertexArrayObject;
  58402. };
  58403. // Type definitions for WebVR API
  58404. // Project: https://w3c.github.io/webvr/
  58405. // Definitions by: six a <https://github.com/lostfictions>
  58406. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58407. interface VRDisplay extends EventTarget {
  58408. /**
  58409. * Dictionary of capabilities describing the VRDisplay.
  58410. */
  58411. readonly capabilities: VRDisplayCapabilities;
  58412. /**
  58413. * z-depth defining the far plane of the eye view frustum
  58414. * enables mapping of values in the render target depth
  58415. * attachment to scene coordinates. Initially set to 10000.0.
  58416. */
  58417. depthFar: number;
  58418. /**
  58419. * z-depth defining the near plane of the eye view frustum
  58420. * enables mapping of values in the render target depth
  58421. * attachment to scene coordinates. Initially set to 0.01.
  58422. */
  58423. depthNear: number;
  58424. /**
  58425. * An identifier for this distinct VRDisplay. Used as an
  58426. * association point in the Gamepad API.
  58427. */
  58428. readonly displayId: number;
  58429. /**
  58430. * A display name, a user-readable name identifying it.
  58431. */
  58432. readonly displayName: string;
  58433. readonly isConnected: boolean;
  58434. readonly isPresenting: boolean;
  58435. /**
  58436. * If this VRDisplay supports room-scale experiences, the optional
  58437. * stage attribute contains details on the room-scale parameters.
  58438. */
  58439. readonly stageParameters: VRStageParameters | null;
  58440. /**
  58441. * Passing the value returned by `requestAnimationFrame` to
  58442. * `cancelAnimationFrame` will unregister the callback.
  58443. * @param handle Define the hanle of the request to cancel
  58444. */
  58445. cancelAnimationFrame(handle: number): void;
  58446. /**
  58447. * Stops presenting to the VRDisplay.
  58448. * @returns a promise to know when it stopped
  58449. */
  58450. exitPresent(): Promise<void>;
  58451. /**
  58452. * Return the current VREyeParameters for the given eye.
  58453. * @param whichEye Define the eye we want the parameter for
  58454. * @returns the eye parameters
  58455. */
  58456. getEyeParameters(whichEye: string): VREyeParameters;
  58457. /**
  58458. * Populates the passed VRFrameData with the information required to render
  58459. * the current frame.
  58460. * @param frameData Define the data structure to populate
  58461. * @returns true if ok otherwise false
  58462. */
  58463. getFrameData(frameData: VRFrameData): boolean;
  58464. /**
  58465. * Get the layers currently being presented.
  58466. * @returns the list of VR layers
  58467. */
  58468. getLayers(): VRLayer[];
  58469. /**
  58470. * Return a VRPose containing the future predicted pose of the VRDisplay
  58471. * when the current frame will be presented. The value returned will not
  58472. * change until JavaScript has returned control to the browser.
  58473. *
  58474. * The VRPose will contain the position, orientation, velocity,
  58475. * and acceleration of each of these properties.
  58476. * @returns the pose object
  58477. */
  58478. getPose(): VRPose;
  58479. /**
  58480. * Return the current instantaneous pose of the VRDisplay, with no
  58481. * prediction applied.
  58482. * @returns the current instantaneous pose
  58483. */
  58484. getImmediatePose(): VRPose;
  58485. /**
  58486. * The callback passed to `requestAnimationFrame` will be called
  58487. * any time a new frame should be rendered. When the VRDisplay is
  58488. * presenting the callback will be called at the native refresh
  58489. * rate of the HMD. When not presenting this function acts
  58490. * identically to how window.requestAnimationFrame acts. Content should
  58491. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58492. * asynchronously from other displays and at differing refresh rates.
  58493. * @param callback Define the eaction to run next frame
  58494. * @returns the request handle it
  58495. */
  58496. requestAnimationFrame(callback: FrameRequestCallback): number;
  58497. /**
  58498. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58499. * Repeat calls while already presenting will update the VRLayers being displayed.
  58500. * @param layers Define the list of layer to present
  58501. * @returns a promise to know when the request has been fulfilled
  58502. */
  58503. requestPresent(layers: VRLayer[]): Promise<void>;
  58504. /**
  58505. * Reset the pose for this display, treating its current position and
  58506. * orientation as the "origin/zero" values. VRPose.position,
  58507. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58508. * updated when calling resetPose(). This should be called in only
  58509. * sitting-space experiences.
  58510. */
  58511. resetPose(): void;
  58512. /**
  58513. * The VRLayer provided to the VRDisplay will be captured and presented
  58514. * in the HMD. Calling this function has the same effect on the source
  58515. * canvas as any other operation that uses its source image, and canvases
  58516. * created without preserveDrawingBuffer set to true will be cleared.
  58517. * @param pose Define the pose to submit
  58518. */
  58519. submitFrame(pose?: VRPose): void;
  58520. }
  58521. declare var VRDisplay: {
  58522. prototype: VRDisplay;
  58523. new(): VRDisplay;
  58524. };
  58525. interface VRLayer {
  58526. leftBounds?: number[] | Float32Array | null;
  58527. rightBounds?: number[] | Float32Array | null;
  58528. source?: HTMLCanvasElement | null;
  58529. }
  58530. interface VRDisplayCapabilities {
  58531. readonly canPresent: boolean;
  58532. readonly hasExternalDisplay: boolean;
  58533. readonly hasOrientation: boolean;
  58534. readonly hasPosition: boolean;
  58535. readonly maxLayers: number;
  58536. }
  58537. interface VREyeParameters {
  58538. /** @deprecated */
  58539. readonly fieldOfView: VRFieldOfView;
  58540. readonly offset: Float32Array;
  58541. readonly renderHeight: number;
  58542. readonly renderWidth: number;
  58543. }
  58544. interface VRFieldOfView {
  58545. readonly downDegrees: number;
  58546. readonly leftDegrees: number;
  58547. readonly rightDegrees: number;
  58548. readonly upDegrees: number;
  58549. }
  58550. interface VRFrameData {
  58551. readonly leftProjectionMatrix: Float32Array;
  58552. readonly leftViewMatrix: Float32Array;
  58553. readonly pose: VRPose;
  58554. readonly rightProjectionMatrix: Float32Array;
  58555. readonly rightViewMatrix: Float32Array;
  58556. readonly timestamp: number;
  58557. }
  58558. interface VRPose {
  58559. readonly angularAcceleration: Float32Array | null;
  58560. readonly angularVelocity: Float32Array | null;
  58561. readonly linearAcceleration: Float32Array | null;
  58562. readonly linearVelocity: Float32Array | null;
  58563. readonly orientation: Float32Array | null;
  58564. readonly position: Float32Array | null;
  58565. readonly timestamp: number;
  58566. }
  58567. interface VRStageParameters {
  58568. sittingToStandingTransform?: Float32Array;
  58569. sizeX?: number;
  58570. sizeY?: number;
  58571. }
  58572. interface Navigator {
  58573. getVRDisplays(): Promise<VRDisplay[]>;
  58574. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58575. }
  58576. interface Window {
  58577. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58578. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58579. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58580. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58581. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58582. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58583. }
  58584. interface Gamepad {
  58585. readonly displayId: number;
  58586. }
  58587. interface XRDevice {
  58588. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58589. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58590. }
  58591. interface XRSession {
  58592. getInputSources(): Array<any>;
  58593. baseLayer: XRWebGLLayer;
  58594. requestFrameOfReference(type: string): Promise<void>;
  58595. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58596. end(): Promise<void>;
  58597. requestAnimationFrame: Function;
  58598. addEventListener: Function;
  58599. }
  58600. interface XRSessionCreationOptions {
  58601. outputContext?: WebGLRenderingContext | null;
  58602. immersive?: boolean;
  58603. environmentIntegration?: boolean;
  58604. }
  58605. interface XRLayer {
  58606. getViewport: Function;
  58607. framebufferWidth: number;
  58608. framebufferHeight: number;
  58609. }
  58610. interface XRView {
  58611. projectionMatrix: Float32Array;
  58612. }
  58613. interface XRFrame {
  58614. getDevicePose: Function;
  58615. getInputPose: Function;
  58616. views: Array<XRView>;
  58617. baseLayer: XRLayer;
  58618. }
  58619. interface XRFrameOfReference {
  58620. }
  58621. interface XRWebGLLayer extends XRLayer {
  58622. framebuffer: WebGLFramebuffer;
  58623. }
  58624. declare var XRWebGLLayer: {
  58625. prototype: XRWebGLLayer;
  58626. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58627. };
  58628. declare module "babylonjs" {
  58629. export * from "babylonjs/Legacy/legacy";
  58630. }
  58631. declare module BABYLON {
  58632. /** Alias type for value that can be null */
  58633. export type Nullable<T> = T | null;
  58634. /**
  58635. * Alias type for number that are floats
  58636. * @ignorenaming
  58637. */
  58638. export type float = number;
  58639. /**
  58640. * Alias type for number that are doubles.
  58641. * @ignorenaming
  58642. */
  58643. export type double = number;
  58644. /**
  58645. * Alias type for number that are integer
  58646. * @ignorenaming
  58647. */
  58648. export type int = number;
  58649. /** Alias type for number array or Float32Array */
  58650. export type FloatArray = number[] | Float32Array;
  58651. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  58652. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  58653. /**
  58654. * Alias for types that can be used by a Buffer or VertexBuffer.
  58655. */
  58656. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  58657. /**
  58658. * Alias type for primitive types
  58659. * @ignorenaming
  58660. */
  58661. type Primitive = undefined | null | boolean | string | number | Function;
  58662. /**
  58663. * Type modifier to make all the properties of an object Readonly
  58664. */
  58665. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  58666. /**
  58667. * Type modifier to make all the properties of an object Readonly recursively
  58668. */
  58669. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  58670. /** @hidden */
  58671. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  58672. }
  58673. /** @hidden */
  58674. /** @hidden */
  58675. type DeepImmutableObject<T> = {
  58676. readonly [K in keyof T]: DeepImmutable<T[K]>;
  58677. };
  58678. }
  58679. declare module BABYLON {
  58680. /**
  58681. * Class containing a set of static utilities functions for arrays.
  58682. */
  58683. export class ArrayTools {
  58684. /**
  58685. * Returns an array of the given size filled with element built from the given constructor and the paramters
  58686. * @param size the number of element to construct and put in the array
  58687. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58688. * @returns a new array filled with new objects
  58689. */
  58690. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  58691. }
  58692. }
  58693. declare module BABYLON {
  58694. /**
  58695. * Scalar computation library
  58696. */
  58697. export class Scalar {
  58698. /**
  58699. * Two pi constants convenient for computation.
  58700. */
  58701. static TwoPi: number;
  58702. /**
  58703. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58704. * @param a number
  58705. * @param b number
  58706. * @param epsilon (default = 1.401298E-45)
  58707. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58708. */
  58709. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  58710. /**
  58711. * Returns a string : the upper case translation of the number i to hexadecimal.
  58712. * @param i number
  58713. * @returns the upper case translation of the number i to hexadecimal.
  58714. */
  58715. static ToHex(i: number): string;
  58716. /**
  58717. * Returns -1 if value is negative and +1 is value is positive.
  58718. * @param value the value
  58719. * @returns the value itself if it's equal to zero.
  58720. */
  58721. static Sign(value: number): number;
  58722. /**
  58723. * Returns the value itself if it's between min and max.
  58724. * Returns min if the value is lower than min.
  58725. * Returns max if the value is greater than max.
  58726. * @param value the value to clmap
  58727. * @param min the min value to clamp to (default: 0)
  58728. * @param max the max value to clamp to (default: 1)
  58729. * @returns the clamped value
  58730. */
  58731. static Clamp(value: number, min?: number, max?: number): number;
  58732. /**
  58733. * the log2 of value.
  58734. * @param value the value to compute log2 of
  58735. * @returns the log2 of value.
  58736. */
  58737. static Log2(value: number): number;
  58738. /**
  58739. * Loops the value, so that it is never larger than length and never smaller than 0.
  58740. *
  58741. * This is similar to the modulo operator but it works with floating point numbers.
  58742. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58743. * With t = 5 and length = 2.5, the result would be 0.0.
  58744. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58745. * @param value the value
  58746. * @param length the length
  58747. * @returns the looped value
  58748. */
  58749. static Repeat(value: number, length: number): number;
  58750. /**
  58751. * Normalize the value between 0.0 and 1.0 using min and max values
  58752. * @param value value to normalize
  58753. * @param min max to normalize between
  58754. * @param max min to normalize between
  58755. * @returns the normalized value
  58756. */
  58757. static Normalize(value: number, min: number, max: number): number;
  58758. /**
  58759. * Denormalize the value from 0.0 and 1.0 using min and max values
  58760. * @param normalized value to denormalize
  58761. * @param min max to denormalize between
  58762. * @param max min to denormalize between
  58763. * @returns the denormalized value
  58764. */
  58765. static Denormalize(normalized: number, min: number, max: number): number;
  58766. /**
  58767. * Calculates the shortest difference between two given angles given in degrees.
  58768. * @param current current angle in degrees
  58769. * @param target target angle in degrees
  58770. * @returns the delta
  58771. */
  58772. static DeltaAngle(current: number, target: number): number;
  58773. /**
  58774. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58775. * @param tx value
  58776. * @param length length
  58777. * @returns The returned value will move back and forth between 0 and length
  58778. */
  58779. static PingPong(tx: number, length: number): number;
  58780. /**
  58781. * Interpolates between min and max with smoothing at the limits.
  58782. *
  58783. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58784. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58785. * @param from from
  58786. * @param to to
  58787. * @param tx value
  58788. * @returns the smooth stepped value
  58789. */
  58790. static SmoothStep(from: number, to: number, tx: number): number;
  58791. /**
  58792. * Moves a value current towards target.
  58793. *
  58794. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58795. * Negative values of maxDelta pushes the value away from target.
  58796. * @param current current value
  58797. * @param target target value
  58798. * @param maxDelta max distance to move
  58799. * @returns resulting value
  58800. */
  58801. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58802. /**
  58803. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58804. *
  58805. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58806. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58807. * @param current current value
  58808. * @param target target value
  58809. * @param maxDelta max distance to move
  58810. * @returns resulting angle
  58811. */
  58812. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58813. /**
  58814. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58815. * @param start start value
  58816. * @param end target value
  58817. * @param amount amount to lerp between
  58818. * @returns the lerped value
  58819. */
  58820. static Lerp(start: number, end: number, amount: number): number;
  58821. /**
  58822. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58823. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58824. * @param start start value
  58825. * @param end target value
  58826. * @param amount amount to lerp between
  58827. * @returns the lerped value
  58828. */
  58829. static LerpAngle(start: number, end: number, amount: number): number;
  58830. /**
  58831. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58832. * @param a start value
  58833. * @param b target value
  58834. * @param value value between a and b
  58835. * @returns the inverseLerp value
  58836. */
  58837. static InverseLerp(a: number, b: number, value: number): number;
  58838. /**
  58839. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58840. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58841. * @param value1 spline value
  58842. * @param tangent1 spline value
  58843. * @param value2 spline value
  58844. * @param tangent2 spline value
  58845. * @param amount input value
  58846. * @returns hermite result
  58847. */
  58848. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58849. /**
  58850. * Returns a random float number between and min and max values
  58851. * @param min min value of random
  58852. * @param max max value of random
  58853. * @returns random value
  58854. */
  58855. static RandomRange(min: number, max: number): number;
  58856. /**
  58857. * This function returns percentage of a number in a given range.
  58858. *
  58859. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58860. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58861. * @param number to convert to percentage
  58862. * @param min min range
  58863. * @param max max range
  58864. * @returns the percentage
  58865. */
  58866. static RangeToPercent(number: number, min: number, max: number): number;
  58867. /**
  58868. * This function returns number that corresponds to the percentage in a given range.
  58869. *
  58870. * PercentToRange(0.34,0,100) will return 34.
  58871. * @param percent to convert to number
  58872. * @param min min range
  58873. * @param max max range
  58874. * @returns the number
  58875. */
  58876. static PercentToRange(percent: number, min: number, max: number): number;
  58877. /**
  58878. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58879. * @param angle The angle to normalize in radian.
  58880. * @return The converted angle.
  58881. */
  58882. static NormalizeRadians(angle: number): number;
  58883. }
  58884. }
  58885. declare module BABYLON {
  58886. /**
  58887. * Constant used to convert a value to gamma space
  58888. * @ignorenaming
  58889. */
  58890. export const ToGammaSpace: number;
  58891. /**
  58892. * Constant used to convert a value to linear space
  58893. * @ignorenaming
  58894. */
  58895. export const ToLinearSpace = 2.2;
  58896. /**
  58897. * Constant used to define the minimal number value in Babylon.js
  58898. * @ignorenaming
  58899. */
  58900. export const Epsilon = 0.001;
  58901. /**
  58902. * Class used to hold a RBG color
  58903. */
  58904. export class Color3 {
  58905. /**
  58906. * Defines the red component (between 0 and 1, default is 0)
  58907. */
  58908. r: number;
  58909. /**
  58910. * Defines the green component (between 0 and 1, default is 0)
  58911. */
  58912. g: number;
  58913. /**
  58914. * Defines the blue component (between 0 and 1, default is 0)
  58915. */
  58916. b: number;
  58917. /**
  58918. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58919. * @param r defines the red component (between 0 and 1, default is 0)
  58920. * @param g defines the green component (between 0 and 1, default is 0)
  58921. * @param b defines the blue component (between 0 and 1, default is 0)
  58922. */
  58923. constructor(
  58924. /**
  58925. * Defines the red component (between 0 and 1, default is 0)
  58926. */
  58927. r?: number,
  58928. /**
  58929. * Defines the green component (between 0 and 1, default is 0)
  58930. */
  58931. g?: number,
  58932. /**
  58933. * Defines the blue component (between 0 and 1, default is 0)
  58934. */
  58935. b?: number);
  58936. /**
  58937. * Creates a string with the Color3 current values
  58938. * @returns the string representation of the Color3 object
  58939. */
  58940. toString(): string;
  58941. /**
  58942. * Returns the string "Color3"
  58943. * @returns "Color3"
  58944. */
  58945. getClassName(): string;
  58946. /**
  58947. * Compute the Color3 hash code
  58948. * @returns an unique number that can be used to hash Color3 objects
  58949. */
  58950. getHashCode(): number;
  58951. /**
  58952. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58953. * @param array defines the array where to store the r,g,b components
  58954. * @param index defines an optional index in the target array to define where to start storing values
  58955. * @returns the current Color3 object
  58956. */
  58957. toArray(array: FloatArray, index?: number): Color3;
  58958. /**
  58959. * Returns a new Color4 object from the current Color3 and the given alpha
  58960. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58961. * @returns a new Color4 object
  58962. */
  58963. toColor4(alpha?: number): Color4;
  58964. /**
  58965. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58966. * @returns the new array
  58967. */
  58968. asArray(): number[];
  58969. /**
  58970. * Returns the luminance value
  58971. * @returns a float value
  58972. */
  58973. toLuminance(): number;
  58974. /**
  58975. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58976. * @param otherColor defines the second operand
  58977. * @returns the new Color3 object
  58978. */
  58979. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58980. /**
  58981. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58982. * @param otherColor defines the second operand
  58983. * @param result defines the Color3 object where to store the result
  58984. * @returns the current Color3
  58985. */
  58986. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58987. /**
  58988. * Determines equality between Color3 objects
  58989. * @param otherColor defines the second operand
  58990. * @returns true if the rgb values are equal to the given ones
  58991. */
  58992. equals(otherColor: DeepImmutable<Color3>): boolean;
  58993. /**
  58994. * Determines equality between the current Color3 object and a set of r,b,g values
  58995. * @param r defines the red component to check
  58996. * @param g defines the green component to check
  58997. * @param b defines the blue component to check
  58998. * @returns true if the rgb values are equal to the given ones
  58999. */
  59000. equalsFloats(r: number, g: number, b: number): boolean;
  59001. /**
  59002. * Multiplies in place each rgb value by scale
  59003. * @param scale defines the scaling factor
  59004. * @returns the updated Color3
  59005. */
  59006. scale(scale: number): Color3;
  59007. /**
  59008. * Multiplies the rgb values by scale and stores the result into "result"
  59009. * @param scale defines the scaling factor
  59010. * @param result defines the Color3 object where to store the result
  59011. * @returns the unmodified current Color3
  59012. */
  59013. scaleToRef(scale: number, result: Color3): Color3;
  59014. /**
  59015. * Scale the current Color3 values by a factor and add the result to a given Color3
  59016. * @param scale defines the scale factor
  59017. * @param result defines color to store the result into
  59018. * @returns the unmodified current Color3
  59019. */
  59020. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59021. /**
  59022. * Clamps the rgb values by the min and max values and stores the result into "result"
  59023. * @param min defines minimum clamping value (default is 0)
  59024. * @param max defines maximum clamping value (default is 1)
  59025. * @param result defines color to store the result into
  59026. * @returns the original Color3
  59027. */
  59028. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59029. /**
  59030. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59031. * @param otherColor defines the second operand
  59032. * @returns the new Color3
  59033. */
  59034. add(otherColor: DeepImmutable<Color3>): Color3;
  59035. /**
  59036. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59037. * @param otherColor defines the second operand
  59038. * @param result defines Color3 object to store the result into
  59039. * @returns the unmodified current Color3
  59040. */
  59041. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59042. /**
  59043. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59044. * @param otherColor defines the second operand
  59045. * @returns the new Color3
  59046. */
  59047. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59048. /**
  59049. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59050. * @param otherColor defines the second operand
  59051. * @param result defines Color3 object to store the result into
  59052. * @returns the unmodified current Color3
  59053. */
  59054. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59055. /**
  59056. * Copy the current object
  59057. * @returns a new Color3 copied the current one
  59058. */
  59059. clone(): Color3;
  59060. /**
  59061. * Copies the rgb values from the source in the current Color3
  59062. * @param source defines the source Color3 object
  59063. * @returns the updated Color3 object
  59064. */
  59065. copyFrom(source: DeepImmutable<Color3>): Color3;
  59066. /**
  59067. * Updates the Color3 rgb values from the given floats
  59068. * @param r defines the red component to read from
  59069. * @param g defines the green component to read from
  59070. * @param b defines the blue component to read from
  59071. * @returns the current Color3 object
  59072. */
  59073. copyFromFloats(r: number, g: number, b: number): Color3;
  59074. /**
  59075. * Updates the Color3 rgb values from the given floats
  59076. * @param r defines the red component to read from
  59077. * @param g defines the green component to read from
  59078. * @param b defines the blue component to read from
  59079. * @returns the current Color3 object
  59080. */
  59081. set(r: number, g: number, b: number): Color3;
  59082. /**
  59083. * Compute the Color3 hexadecimal code as a string
  59084. * @returns a string containing the hexadecimal representation of the Color3 object
  59085. */
  59086. toHexString(): string;
  59087. /**
  59088. * Computes a new Color3 converted from the current one to linear space
  59089. * @returns a new Color3 object
  59090. */
  59091. toLinearSpace(): Color3;
  59092. /**
  59093. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59094. * @param convertedColor defines the Color3 object where to store the linear space version
  59095. * @returns the unmodified Color3
  59096. */
  59097. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59098. /**
  59099. * Computes a new Color3 converted from the current one to gamma space
  59100. * @returns a new Color3 object
  59101. */
  59102. toGammaSpace(): Color3;
  59103. /**
  59104. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59105. * @param convertedColor defines the Color3 object where to store the gamma space version
  59106. * @returns the unmodified Color3
  59107. */
  59108. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59109. private static _BlackReadOnly;
  59110. /**
  59111. * Creates a new Color3 from the string containing valid hexadecimal values
  59112. * @param hex defines a string containing valid hexadecimal values
  59113. * @returns a new Color3 object
  59114. */
  59115. static FromHexString(hex: string): Color3;
  59116. /**
  59117. * Creates a new Vector3 from the starting index of the given array
  59118. * @param array defines the source array
  59119. * @param offset defines an offset in the source array
  59120. * @returns a new Color3 object
  59121. */
  59122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59123. /**
  59124. * Creates a new Color3 from integer values (< 256)
  59125. * @param r defines the red component to read from (value between 0 and 255)
  59126. * @param g defines the green component to read from (value between 0 and 255)
  59127. * @param b defines the blue component to read from (value between 0 and 255)
  59128. * @returns a new Color3 object
  59129. */
  59130. static FromInts(r: number, g: number, b: number): Color3;
  59131. /**
  59132. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59133. * @param start defines the start Color3 value
  59134. * @param end defines the end Color3 value
  59135. * @param amount defines the gradient value between start and end
  59136. * @returns a new Color3 object
  59137. */
  59138. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59139. /**
  59140. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59141. * @param left defines the start value
  59142. * @param right defines the end value
  59143. * @param amount defines the gradient factor
  59144. * @param result defines the Color3 object where to store the result
  59145. */
  59146. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59147. /**
  59148. * Returns a Color3 value containing a red color
  59149. * @returns a new Color3 object
  59150. */
  59151. static Red(): Color3;
  59152. /**
  59153. * Returns a Color3 value containing a green color
  59154. * @returns a new Color3 object
  59155. */
  59156. static Green(): Color3;
  59157. /**
  59158. * Returns a Color3 value containing a blue color
  59159. * @returns a new Color3 object
  59160. */
  59161. static Blue(): Color3;
  59162. /**
  59163. * Returns a Color3 value containing a black color
  59164. * @returns a new Color3 object
  59165. */
  59166. static Black(): Color3;
  59167. /**
  59168. * Gets a Color3 value containing a black color that must not be updated
  59169. */
  59170. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59171. /**
  59172. * Returns a Color3 value containing a white color
  59173. * @returns a new Color3 object
  59174. */
  59175. static White(): Color3;
  59176. /**
  59177. * Returns a Color3 value containing a purple color
  59178. * @returns a new Color3 object
  59179. */
  59180. static Purple(): Color3;
  59181. /**
  59182. * Returns a Color3 value containing a magenta color
  59183. * @returns a new Color3 object
  59184. */
  59185. static Magenta(): Color3;
  59186. /**
  59187. * Returns a Color3 value containing a yellow color
  59188. * @returns a new Color3 object
  59189. */
  59190. static Yellow(): Color3;
  59191. /**
  59192. * Returns a Color3 value containing a gray color
  59193. * @returns a new Color3 object
  59194. */
  59195. static Gray(): Color3;
  59196. /**
  59197. * Returns a Color3 value containing a teal color
  59198. * @returns a new Color3 object
  59199. */
  59200. static Teal(): Color3;
  59201. /**
  59202. * Returns a Color3 value containing a random color
  59203. * @returns a new Color3 object
  59204. */
  59205. static Random(): Color3;
  59206. }
  59207. /**
  59208. * Class used to hold a RBGA color
  59209. */
  59210. export class Color4 {
  59211. /**
  59212. * Defines the red component (between 0 and 1, default is 0)
  59213. */
  59214. r: number;
  59215. /**
  59216. * Defines the green component (between 0 and 1, default is 0)
  59217. */
  59218. g: number;
  59219. /**
  59220. * Defines the blue component (between 0 and 1, default is 0)
  59221. */
  59222. b: number;
  59223. /**
  59224. * Defines the alpha component (between 0 and 1, default is 1)
  59225. */
  59226. a: number;
  59227. /**
  59228. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59229. * @param r defines the red component (between 0 and 1, default is 0)
  59230. * @param g defines the green component (between 0 and 1, default is 0)
  59231. * @param b defines the blue component (between 0 and 1, default is 0)
  59232. * @param a defines the alpha component (between 0 and 1, default is 1)
  59233. */
  59234. constructor(
  59235. /**
  59236. * Defines the red component (between 0 and 1, default is 0)
  59237. */
  59238. r?: number,
  59239. /**
  59240. * Defines the green component (between 0 and 1, default is 0)
  59241. */
  59242. g?: number,
  59243. /**
  59244. * Defines the blue component (between 0 and 1, default is 0)
  59245. */
  59246. b?: number,
  59247. /**
  59248. * Defines the alpha component (between 0 and 1, default is 1)
  59249. */
  59250. a?: number);
  59251. /**
  59252. * Adds in place the given Color4 values to the current Color4 object
  59253. * @param right defines the second operand
  59254. * @returns the current updated Color4 object
  59255. */
  59256. addInPlace(right: DeepImmutable<Color4>): Color4;
  59257. /**
  59258. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59259. * @returns the new array
  59260. */
  59261. asArray(): number[];
  59262. /**
  59263. * Stores from the starting index in the given array the Color4 successive values
  59264. * @param array defines the array where to store the r,g,b components
  59265. * @param index defines an optional index in the target array to define where to start storing values
  59266. * @returns the current Color4 object
  59267. */
  59268. toArray(array: number[], index?: number): Color4;
  59269. /**
  59270. * Determines equality between Color4 objects
  59271. * @param otherColor defines the second operand
  59272. * @returns true if the rgba values are equal to the given ones
  59273. */
  59274. equals(otherColor: DeepImmutable<Color4>): boolean;
  59275. /**
  59276. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59277. * @param right defines the second operand
  59278. * @returns a new Color4 object
  59279. */
  59280. add(right: DeepImmutable<Color4>): Color4;
  59281. /**
  59282. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59283. * @param right defines the second operand
  59284. * @returns a new Color4 object
  59285. */
  59286. subtract(right: DeepImmutable<Color4>): Color4;
  59287. /**
  59288. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59289. * @param right defines the second operand
  59290. * @param result defines the Color4 object where to store the result
  59291. * @returns the current Color4 object
  59292. */
  59293. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59294. /**
  59295. * Creates a new Color4 with the current Color4 values multiplied by scale
  59296. * @param scale defines the scaling factor to apply
  59297. * @returns a new Color4 object
  59298. */
  59299. scale(scale: number): Color4;
  59300. /**
  59301. * Multiplies the current Color4 values by scale and stores the result in "result"
  59302. * @param scale defines the scaling factor to apply
  59303. * @param result defines the Color4 object where to store the result
  59304. * @returns the current unmodified Color4
  59305. */
  59306. scaleToRef(scale: number, result: Color4): Color4;
  59307. /**
  59308. * Scale the current Color4 values by a factor and add the result to a given Color4
  59309. * @param scale defines the scale factor
  59310. * @param result defines the Color4 object where to store the result
  59311. * @returns the unmodified current Color4
  59312. */
  59313. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59314. /**
  59315. * Clamps the rgb values by the min and max values and stores the result into "result"
  59316. * @param min defines minimum clamping value (default is 0)
  59317. * @param max defines maximum clamping value (default is 1)
  59318. * @param result defines color to store the result into.
  59319. * @returns the cuurent Color4
  59320. */
  59321. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59322. /**
  59323. * Multipy an Color4 value by another and return a new Color4 object
  59324. * @param color defines the Color4 value to multiply by
  59325. * @returns a new Color4 object
  59326. */
  59327. multiply(color: Color4): Color4;
  59328. /**
  59329. * Multipy a Color4 value by another and push the result in a reference value
  59330. * @param color defines the Color4 value to multiply by
  59331. * @param result defines the Color4 to fill the result in
  59332. * @returns the result Color4
  59333. */
  59334. multiplyToRef(color: Color4, result: Color4): Color4;
  59335. /**
  59336. * Creates a string with the Color4 current values
  59337. * @returns the string representation of the Color4 object
  59338. */
  59339. toString(): string;
  59340. /**
  59341. * Returns the string "Color4"
  59342. * @returns "Color4"
  59343. */
  59344. getClassName(): string;
  59345. /**
  59346. * Compute the Color4 hash code
  59347. * @returns an unique number that can be used to hash Color4 objects
  59348. */
  59349. getHashCode(): number;
  59350. /**
  59351. * Creates a new Color4 copied from the current one
  59352. * @returns a new Color4 object
  59353. */
  59354. clone(): Color4;
  59355. /**
  59356. * Copies the given Color4 values into the current one
  59357. * @param source defines the source Color4 object
  59358. * @returns the current updated Color4 object
  59359. */
  59360. copyFrom(source: Color4): Color4;
  59361. /**
  59362. * Copies the given float values into the current one
  59363. * @param r defines the red component to read from
  59364. * @param g defines the green component to read from
  59365. * @param b defines the blue component to read from
  59366. * @param a defines the alpha component to read from
  59367. * @returns the current updated Color4 object
  59368. */
  59369. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59370. /**
  59371. * Copies the given float values into the current one
  59372. * @param r defines the red component to read from
  59373. * @param g defines the green component to read from
  59374. * @param b defines the blue component to read from
  59375. * @param a defines the alpha component to read from
  59376. * @returns the current updated Color4 object
  59377. */
  59378. set(r: number, g: number, b: number, a: number): Color4;
  59379. /**
  59380. * Compute the Color4 hexadecimal code as a string
  59381. * @returns a string containing the hexadecimal representation of the Color4 object
  59382. */
  59383. toHexString(): string;
  59384. /**
  59385. * Computes a new Color4 converted from the current one to linear space
  59386. * @returns a new Color4 object
  59387. */
  59388. toLinearSpace(): Color4;
  59389. /**
  59390. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59391. * @param convertedColor defines the Color4 object where to store the linear space version
  59392. * @returns the unmodified Color4
  59393. */
  59394. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59395. /**
  59396. * Computes a new Color4 converted from the current one to gamma space
  59397. * @returns a new Color4 object
  59398. */
  59399. toGammaSpace(): Color4;
  59400. /**
  59401. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59402. * @param convertedColor defines the Color4 object where to store the gamma space version
  59403. * @returns the unmodified Color4
  59404. */
  59405. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59406. /**
  59407. * Creates a new Color4 from the string containing valid hexadecimal values
  59408. * @param hex defines a string containing valid hexadecimal values
  59409. * @returns a new Color4 object
  59410. */
  59411. static FromHexString(hex: string): Color4;
  59412. /**
  59413. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59414. * @param left defines the start value
  59415. * @param right defines the end value
  59416. * @param amount defines the gradient factor
  59417. * @returns a new Color4 object
  59418. */
  59419. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59420. /**
  59421. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59422. * @param left defines the start value
  59423. * @param right defines the end value
  59424. * @param amount defines the gradient factor
  59425. * @param result defines the Color4 object where to store data
  59426. */
  59427. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59428. /**
  59429. * Creates a new Color4 from a Color3 and an alpha value
  59430. * @param color3 defines the source Color3 to read from
  59431. * @param alpha defines the alpha component (1.0 by default)
  59432. * @returns a new Color4 object
  59433. */
  59434. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59435. /**
  59436. * Creates a new Color4 from the starting index element of the given array
  59437. * @param array defines the source array to read from
  59438. * @param offset defines the offset in the source array
  59439. * @returns a new Color4 object
  59440. */
  59441. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59442. /**
  59443. * Creates a new Color3 from integer values (< 256)
  59444. * @param r defines the red component to read from (value between 0 and 255)
  59445. * @param g defines the green component to read from (value between 0 and 255)
  59446. * @param b defines the blue component to read from (value between 0 and 255)
  59447. * @param a defines the alpha component to read from (value between 0 and 255)
  59448. * @returns a new Color3 object
  59449. */
  59450. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59451. /**
  59452. * Check the content of a given array and convert it to an array containing RGBA data
  59453. * If the original array was already containing count * 4 values then it is returned directly
  59454. * @param colors defines the array to check
  59455. * @param count defines the number of RGBA data to expect
  59456. * @returns an array containing count * 4 values (RGBA)
  59457. */
  59458. static CheckColors4(colors: number[], count: number): number[];
  59459. }
  59460. /**
  59461. * Class representing a vector containing 2 coordinates
  59462. */
  59463. export class Vector2 {
  59464. /** defines the first coordinate */
  59465. x: number;
  59466. /** defines the second coordinate */
  59467. y: number;
  59468. /**
  59469. * Creates a new Vector2 from the given x and y coordinates
  59470. * @param x defines the first coordinate
  59471. * @param y defines the second coordinate
  59472. */
  59473. constructor(
  59474. /** defines the first coordinate */
  59475. x?: number,
  59476. /** defines the second coordinate */
  59477. y?: number);
  59478. /**
  59479. * Gets a string with the Vector2 coordinates
  59480. * @returns a string with the Vector2 coordinates
  59481. */
  59482. toString(): string;
  59483. /**
  59484. * Gets class name
  59485. * @returns the string "Vector2"
  59486. */
  59487. getClassName(): string;
  59488. /**
  59489. * Gets current vector hash code
  59490. * @returns the Vector2 hash code as a number
  59491. */
  59492. getHashCode(): number;
  59493. /**
  59494. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59495. * @param array defines the source array
  59496. * @param index defines the offset in source array
  59497. * @returns the current Vector2
  59498. */
  59499. toArray(array: FloatArray, index?: number): Vector2;
  59500. /**
  59501. * Copy the current vector to an array
  59502. * @returns a new array with 2 elements: the Vector2 coordinates.
  59503. */
  59504. asArray(): number[];
  59505. /**
  59506. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59507. * @param source defines the source Vector2
  59508. * @returns the current updated Vector2
  59509. */
  59510. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59511. /**
  59512. * Sets the Vector2 coordinates with the given floats
  59513. * @param x defines the first coordinate
  59514. * @param y defines the second coordinate
  59515. * @returns the current updated Vector2
  59516. */
  59517. copyFromFloats(x: number, y: number): Vector2;
  59518. /**
  59519. * Sets the Vector2 coordinates with the given floats
  59520. * @param x defines the first coordinate
  59521. * @param y defines the second coordinate
  59522. * @returns the current updated Vector2
  59523. */
  59524. set(x: number, y: number): Vector2;
  59525. /**
  59526. * Add another vector with the current one
  59527. * @param otherVector defines the other vector
  59528. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59529. */
  59530. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59531. /**
  59532. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59533. * @param otherVector defines the other vector
  59534. * @param result defines the target vector
  59535. * @returns the unmodified current Vector2
  59536. */
  59537. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59538. /**
  59539. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59540. * @param otherVector defines the other vector
  59541. * @returns the current updated Vector2
  59542. */
  59543. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59544. /**
  59545. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  59546. * @param otherVector defines the other vector
  59547. * @returns a new Vector2
  59548. */
  59549. addVector3(otherVector: Vector3): Vector2;
  59550. /**
  59551. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  59552. * @param otherVector defines the other vector
  59553. * @returns a new Vector2
  59554. */
  59555. subtract(otherVector: Vector2): Vector2;
  59556. /**
  59557. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  59558. * @param otherVector defines the other vector
  59559. * @param result defines the target vector
  59560. * @returns the unmodified current Vector2
  59561. */
  59562. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59563. /**
  59564. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  59565. * @param otherVector defines the other vector
  59566. * @returns the current updated Vector2
  59567. */
  59568. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59569. /**
  59570. * Multiplies in place the current Vector2 coordinates by the given ones
  59571. * @param otherVector defines the other vector
  59572. * @returns the current updated Vector2
  59573. */
  59574. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59575. /**
  59576. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  59577. * @param otherVector defines the other vector
  59578. * @returns a new Vector2
  59579. */
  59580. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  59581. /**
  59582. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  59583. * @param otherVector defines the other vector
  59584. * @param result defines the target vector
  59585. * @returns the unmodified current Vector2
  59586. */
  59587. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59588. /**
  59589. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  59590. * @param x defines the first coordinate
  59591. * @param y defines the second coordinate
  59592. * @returns a new Vector2
  59593. */
  59594. multiplyByFloats(x: number, y: number): Vector2;
  59595. /**
  59596. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  59597. * @param otherVector defines the other vector
  59598. * @returns a new Vector2
  59599. */
  59600. divide(otherVector: Vector2): Vector2;
  59601. /**
  59602. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  59603. * @param otherVector defines the other vector
  59604. * @param result defines the target vector
  59605. * @returns the unmodified current Vector2
  59606. */
  59607. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59608. /**
  59609. * Divides the current Vector2 coordinates by the given ones
  59610. * @param otherVector defines the other vector
  59611. * @returns the current updated Vector2
  59612. */
  59613. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59614. /**
  59615. * Gets a new Vector2 with current Vector2 negated coordinates
  59616. * @returns a new Vector2
  59617. */
  59618. negate(): Vector2;
  59619. /**
  59620. * Multiply the Vector2 coordinates by scale
  59621. * @param scale defines the scaling factor
  59622. * @returns the current updated Vector2
  59623. */
  59624. scaleInPlace(scale: number): Vector2;
  59625. /**
  59626. * Returns a new Vector2 scaled by "scale" from the current Vector2
  59627. * @param scale defines the scaling factor
  59628. * @returns a new Vector2
  59629. */
  59630. scale(scale: number): Vector2;
  59631. /**
  59632. * Scale the current Vector2 values by a factor to a given Vector2
  59633. * @param scale defines the scale factor
  59634. * @param result defines the Vector2 object where to store the result
  59635. * @returns the unmodified current Vector2
  59636. */
  59637. scaleToRef(scale: number, result: Vector2): Vector2;
  59638. /**
  59639. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  59640. * @param scale defines the scale factor
  59641. * @param result defines the Vector2 object where to store the result
  59642. * @returns the unmodified current Vector2
  59643. */
  59644. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  59645. /**
  59646. * Gets a boolean if two vectors are equals
  59647. * @param otherVector defines the other vector
  59648. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  59649. */
  59650. equals(otherVector: DeepImmutable<Vector2>): boolean;
  59651. /**
  59652. * Gets a boolean if two vectors are equals (using an epsilon value)
  59653. * @param otherVector defines the other vector
  59654. * @param epsilon defines the minimal distance to consider equality
  59655. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  59656. */
  59657. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  59658. /**
  59659. * Gets a new Vector2 from current Vector2 floored values
  59660. * @returns a new Vector2
  59661. */
  59662. floor(): Vector2;
  59663. /**
  59664. * Gets a new Vector2 from current Vector2 floored values
  59665. * @returns a new Vector2
  59666. */
  59667. fract(): Vector2;
  59668. /**
  59669. * Gets the length of the vector
  59670. * @returns the vector length (float)
  59671. */
  59672. length(): number;
  59673. /**
  59674. * Gets the vector squared length
  59675. * @returns the vector squared length (float)
  59676. */
  59677. lengthSquared(): number;
  59678. /**
  59679. * Normalize the vector
  59680. * @returns the current updated Vector2
  59681. */
  59682. normalize(): Vector2;
  59683. /**
  59684. * Gets a new Vector2 copied from the Vector2
  59685. * @returns a new Vector2
  59686. */
  59687. clone(): Vector2;
  59688. /**
  59689. * Gets a new Vector2(0, 0)
  59690. * @returns a new Vector2
  59691. */
  59692. static Zero(): Vector2;
  59693. /**
  59694. * Gets a new Vector2(1, 1)
  59695. * @returns a new Vector2
  59696. */
  59697. static One(): Vector2;
  59698. /**
  59699. * Gets a new Vector2 set from the given index element of the given array
  59700. * @param array defines the data source
  59701. * @param offset defines the offset in the data source
  59702. * @returns a new Vector2
  59703. */
  59704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  59705. /**
  59706. * Sets "result" from the given index element of the given array
  59707. * @param array defines the data source
  59708. * @param offset defines the offset in the data source
  59709. * @param result defines the target vector
  59710. */
  59711. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  59712. /**
  59713. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  59714. * @param value1 defines 1st point of control
  59715. * @param value2 defines 2nd point of control
  59716. * @param value3 defines 3rd point of control
  59717. * @param value4 defines 4th point of control
  59718. * @param amount defines the interpolation factor
  59719. * @returns a new Vector2
  59720. */
  59721. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  59722. /**
  59723. * 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".
  59724. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  59725. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  59726. * @param value defines the value to clamp
  59727. * @param min defines the lower limit
  59728. * @param max defines the upper limit
  59729. * @returns a new Vector2
  59730. */
  59731. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59732. /**
  59733. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59734. * @param value1 defines the 1st control point
  59735. * @param tangent1 defines the outgoing tangent
  59736. * @param value2 defines the 2nd control point
  59737. * @param tangent2 defines the incoming tangent
  59738. * @param amount defines the interpolation factor
  59739. * @returns a new Vector2
  59740. */
  59741. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59742. /**
  59743. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59744. * @param start defines the start vector
  59745. * @param end defines the end vector
  59746. * @param amount defines the interpolation factor
  59747. * @returns a new Vector2
  59748. */
  59749. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59750. /**
  59751. * Gets the dot product of the vector "left" and the vector "right"
  59752. * @param left defines first vector
  59753. * @param right defines second vector
  59754. * @returns the dot product (float)
  59755. */
  59756. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59757. /**
  59758. * Returns a new Vector2 equal to the normalized given vector
  59759. * @param vector defines the vector to normalize
  59760. * @returns a new Vector2
  59761. */
  59762. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59763. /**
  59764. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59765. * @param left defines 1st vector
  59766. * @param right defines 2nd vector
  59767. * @returns a new Vector2
  59768. */
  59769. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59770. /**
  59771. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59772. * @param left defines 1st vector
  59773. * @param right defines 2nd vector
  59774. * @returns a new Vector2
  59775. */
  59776. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59777. /**
  59778. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59779. * @param vector defines the vector to transform
  59780. * @param transformation defines the matrix to apply
  59781. * @returns a new Vector2
  59782. */
  59783. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59784. /**
  59785. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59786. * @param vector defines the vector to transform
  59787. * @param transformation defines the matrix to apply
  59788. * @param result defines the target vector
  59789. */
  59790. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59791. /**
  59792. * Determines if a given vector is included in a triangle
  59793. * @param p defines the vector to test
  59794. * @param p0 defines 1st triangle point
  59795. * @param p1 defines 2nd triangle point
  59796. * @param p2 defines 3rd triangle point
  59797. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59798. */
  59799. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59800. /**
  59801. * Gets the distance between the vectors "value1" and "value2"
  59802. * @param value1 defines first vector
  59803. * @param value2 defines second vector
  59804. * @returns the distance between vectors
  59805. */
  59806. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59807. /**
  59808. * Returns the squared distance between the vectors "value1" and "value2"
  59809. * @param value1 defines first vector
  59810. * @param value2 defines second vector
  59811. * @returns the squared distance between vectors
  59812. */
  59813. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59814. /**
  59815. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59816. * @param value1 defines first vector
  59817. * @param value2 defines second vector
  59818. * @returns a new Vector2
  59819. */
  59820. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59821. /**
  59822. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59823. * @param p defines the middle point
  59824. * @param segA defines one point of the segment
  59825. * @param segB defines the other point of the segment
  59826. * @returns the shortest distance
  59827. */
  59828. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59829. }
  59830. /**
  59831. * Classed used to store (x,y,z) vector representation
  59832. * A Vector3 is the main object used in 3D geometry
  59833. * It can represent etiher the coordinates of a point the space, either a direction
  59834. * Reminder: js uses a left handed forward facing system
  59835. */
  59836. export class Vector3 {
  59837. /**
  59838. * Defines the first coordinates (on X axis)
  59839. */
  59840. x: number;
  59841. /**
  59842. * Defines the second coordinates (on Y axis)
  59843. */
  59844. y: number;
  59845. /**
  59846. * Defines the third coordinates (on Z axis)
  59847. */
  59848. z: number;
  59849. private static _UpReadOnly;
  59850. /**
  59851. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59852. * @param x defines the first coordinates (on X axis)
  59853. * @param y defines the second coordinates (on Y axis)
  59854. * @param z defines the third coordinates (on Z axis)
  59855. */
  59856. constructor(
  59857. /**
  59858. * Defines the first coordinates (on X axis)
  59859. */
  59860. x?: number,
  59861. /**
  59862. * Defines the second coordinates (on Y axis)
  59863. */
  59864. y?: number,
  59865. /**
  59866. * Defines the third coordinates (on Z axis)
  59867. */
  59868. z?: number);
  59869. /**
  59870. * Creates a string representation of the Vector3
  59871. * @returns a string with the Vector3 coordinates.
  59872. */
  59873. toString(): string;
  59874. /**
  59875. * Gets the class name
  59876. * @returns the string "Vector3"
  59877. */
  59878. getClassName(): string;
  59879. /**
  59880. * Creates the Vector3 hash code
  59881. * @returns a number which tends to be unique between Vector3 instances
  59882. */
  59883. getHashCode(): number;
  59884. /**
  59885. * Creates an array containing three elements : the coordinates of the Vector3
  59886. * @returns a new array of numbers
  59887. */
  59888. asArray(): number[];
  59889. /**
  59890. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59891. * @param array defines the destination array
  59892. * @param index defines the offset in the destination array
  59893. * @returns the current Vector3
  59894. */
  59895. toArray(array: FloatArray, index?: number): Vector3;
  59896. /**
  59897. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59898. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59899. */
  59900. toQuaternion(): Quaternion;
  59901. /**
  59902. * Adds the given vector to the current Vector3
  59903. * @param otherVector defines the second operand
  59904. * @returns the current updated Vector3
  59905. */
  59906. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59907. /**
  59908. * Adds the given coordinates to the current Vector3
  59909. * @param x defines the x coordinate of the operand
  59910. * @param y defines the y coordinate of the operand
  59911. * @param z defines the z coordinate of the operand
  59912. * @returns the current updated Vector3
  59913. */
  59914. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59915. /**
  59916. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59917. * @param otherVector defines the second operand
  59918. * @returns the resulting Vector3
  59919. */
  59920. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59921. /**
  59922. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59923. * @param otherVector defines the second operand
  59924. * @param result defines the Vector3 object where to store the result
  59925. * @returns the current Vector3
  59926. */
  59927. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59928. /**
  59929. * Subtract the given vector from the current Vector3
  59930. * @param otherVector defines the second operand
  59931. * @returns the current updated Vector3
  59932. */
  59933. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59934. /**
  59935. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59936. * @param otherVector defines the second operand
  59937. * @returns the resulting Vector3
  59938. */
  59939. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59940. /**
  59941. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59942. * @param otherVector defines the second operand
  59943. * @param result defines the Vector3 object where to store the result
  59944. * @returns the current Vector3
  59945. */
  59946. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59947. /**
  59948. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59949. * @param x defines the x coordinate of the operand
  59950. * @param y defines the y coordinate of the operand
  59951. * @param z defines the z coordinate of the operand
  59952. * @returns the resulting Vector3
  59953. */
  59954. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59955. /**
  59956. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59957. * @param x defines the x coordinate of the operand
  59958. * @param y defines the y coordinate of the operand
  59959. * @param z defines the z coordinate of the operand
  59960. * @param result defines the Vector3 object where to store the result
  59961. * @returns the current Vector3
  59962. */
  59963. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59964. /**
  59965. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59966. * @returns a new Vector3
  59967. */
  59968. negate(): Vector3;
  59969. /**
  59970. * Multiplies the Vector3 coordinates by the float "scale"
  59971. * @param scale defines the multiplier factor
  59972. * @returns the current updated Vector3
  59973. */
  59974. scaleInPlace(scale: number): Vector3;
  59975. /**
  59976. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59977. * @param scale defines the multiplier factor
  59978. * @returns a new Vector3
  59979. */
  59980. scale(scale: number): Vector3;
  59981. /**
  59982. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59983. * @param scale defines the multiplier factor
  59984. * @param result defines the Vector3 object where to store the result
  59985. * @returns the current Vector3
  59986. */
  59987. scaleToRef(scale: number, result: Vector3): Vector3;
  59988. /**
  59989. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59990. * @param scale defines the scale factor
  59991. * @param result defines the Vector3 object where to store the result
  59992. * @returns the unmodified current Vector3
  59993. */
  59994. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59995. /**
  59996. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59997. * @param otherVector defines the second operand
  59998. * @returns true if both vectors are equals
  59999. */
  60000. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60001. /**
  60002. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60003. * @param otherVector defines the second operand
  60004. * @param epsilon defines the minimal distance to define values as equals
  60005. * @returns true if both vectors are distant less than epsilon
  60006. */
  60007. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60008. /**
  60009. * Returns true if the current Vector3 coordinates equals the given floats
  60010. * @param x defines the x coordinate of the operand
  60011. * @param y defines the y coordinate of the operand
  60012. * @param z defines the z coordinate of the operand
  60013. * @returns true if both vectors are equals
  60014. */
  60015. equalsToFloats(x: number, y: number, z: number): boolean;
  60016. /**
  60017. * Multiplies the current Vector3 coordinates by the given ones
  60018. * @param otherVector defines the second operand
  60019. * @returns the current updated Vector3
  60020. */
  60021. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60022. /**
  60023. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60024. * @param otherVector defines the second operand
  60025. * @returns the new Vector3
  60026. */
  60027. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60028. /**
  60029. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60030. * @param otherVector defines the second operand
  60031. * @param result defines the Vector3 object where to store the result
  60032. * @returns the current Vector3
  60033. */
  60034. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60035. /**
  60036. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60037. * @param x defines the x coordinate of the operand
  60038. * @param y defines the y coordinate of the operand
  60039. * @param z defines the z coordinate of the operand
  60040. * @returns the new Vector3
  60041. */
  60042. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60043. /**
  60044. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60045. * @param otherVector defines the second operand
  60046. * @returns the new Vector3
  60047. */
  60048. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60049. /**
  60050. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60051. * @param otherVector defines the second operand
  60052. * @param result defines the Vector3 object where to store the result
  60053. * @returns the current Vector3
  60054. */
  60055. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60056. /**
  60057. * Divides the current Vector3 coordinates by the given ones.
  60058. * @param otherVector defines the second operand
  60059. * @returns the current updated Vector3
  60060. */
  60061. divideInPlace(otherVector: Vector3): Vector3;
  60062. /**
  60063. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60064. * @param other defines the second operand
  60065. * @returns the current updated Vector3
  60066. */
  60067. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60068. /**
  60069. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60070. * @param other defines the second operand
  60071. * @returns the current updated Vector3
  60072. */
  60073. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60074. /**
  60075. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60076. * @param x defines the x coordinate of the operand
  60077. * @param y defines the y coordinate of the operand
  60078. * @param z defines the z coordinate of the operand
  60079. * @returns the current updated Vector3
  60080. */
  60081. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60082. /**
  60083. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60084. * @param x defines the x coordinate of the operand
  60085. * @param y defines the y coordinate of the operand
  60086. * @param z defines the z coordinate of the operand
  60087. * @returns the current updated Vector3
  60088. */
  60089. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60090. /**
  60091. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60092. * Check if is non uniform within a certain amount of decimal places to account for this
  60093. * @param epsilon the amount the values can differ
  60094. * @returns if the the vector is non uniform to a certain number of decimal places
  60095. */
  60096. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60097. /**
  60098. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60099. */
  60100. readonly isNonUniform: boolean;
  60101. /**
  60102. * Gets a new Vector3 from current Vector3 floored values
  60103. * @returns a new Vector3
  60104. */
  60105. floor(): Vector3;
  60106. /**
  60107. * Gets a new Vector3 from current Vector3 floored values
  60108. * @returns a new Vector3
  60109. */
  60110. fract(): Vector3;
  60111. /**
  60112. * Gets the length of the Vector3
  60113. * @returns the length of the Vecto3
  60114. */
  60115. length(): number;
  60116. /**
  60117. * Gets the squared length of the Vector3
  60118. * @returns squared length of the Vector3
  60119. */
  60120. lengthSquared(): number;
  60121. /**
  60122. * Normalize the current Vector3.
  60123. * Please note that this is an in place operation.
  60124. * @returns the current updated Vector3
  60125. */
  60126. normalize(): Vector3;
  60127. /**
  60128. * Reorders the x y z properties of the vector in place
  60129. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60130. * @returns the current updated vector
  60131. */
  60132. reorderInPlace(order: string): this;
  60133. /**
  60134. * Rotates the vector around 0,0,0 by a quaternion
  60135. * @param quaternion the rotation quaternion
  60136. * @param result vector to store the result
  60137. * @returns the resulting vector
  60138. */
  60139. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60140. /**
  60141. * Rotates a vector around a given point
  60142. * @param quaternion the rotation quaternion
  60143. * @param point the point to rotate around
  60144. * @param result vector to store the result
  60145. * @returns the resulting vector
  60146. */
  60147. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60148. /**
  60149. * Normalize the current Vector3 with the given input length.
  60150. * Please note that this is an in place operation.
  60151. * @param len the length of the vector
  60152. * @returns the current updated Vector3
  60153. */
  60154. normalizeFromLength(len: number): Vector3;
  60155. /**
  60156. * Normalize the current Vector3 to a new vector
  60157. * @returns the new Vector3
  60158. */
  60159. normalizeToNew(): Vector3;
  60160. /**
  60161. * Normalize the current Vector3 to the reference
  60162. * @param reference define the Vector3 to update
  60163. * @returns the updated Vector3
  60164. */
  60165. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60166. /**
  60167. * Creates a new Vector3 copied from the current Vector3
  60168. * @returns the new Vector3
  60169. */
  60170. clone(): Vector3;
  60171. /**
  60172. * Copies the given vector coordinates to the current Vector3 ones
  60173. * @param source defines the source Vector3
  60174. * @returns the current updated Vector3
  60175. */
  60176. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60177. /**
  60178. * Copies the given floats to the current Vector3 coordinates
  60179. * @param x defines the x coordinate of the operand
  60180. * @param y defines the y coordinate of the operand
  60181. * @param z defines the z coordinate of the operand
  60182. * @returns the current updated Vector3
  60183. */
  60184. copyFromFloats(x: number, y: number, z: number): Vector3;
  60185. /**
  60186. * Copies the given floats to the current Vector3 coordinates
  60187. * @param x defines the x coordinate of the operand
  60188. * @param y defines the y coordinate of the operand
  60189. * @param z defines the z coordinate of the operand
  60190. * @returns the current updated Vector3
  60191. */
  60192. set(x: number, y: number, z: number): Vector3;
  60193. /**
  60194. * Copies the given float to the current Vector3 coordinates
  60195. * @param v defines the x, y and z coordinates of the operand
  60196. * @returns the current updated Vector3
  60197. */
  60198. setAll(v: number): Vector3;
  60199. /**
  60200. * Get the clip factor between two vectors
  60201. * @param vector0 defines the first operand
  60202. * @param vector1 defines the second operand
  60203. * @param axis defines the axis to use
  60204. * @param size defines the size along the axis
  60205. * @returns the clip factor
  60206. */
  60207. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60208. /**
  60209. * Get angle between two vectors
  60210. * @param vector0 angle between vector0 and vector1
  60211. * @param vector1 angle between vector0 and vector1
  60212. * @param normal direction of the normal
  60213. * @return the angle between vector0 and vector1
  60214. */
  60215. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60216. /**
  60217. * Returns a new Vector3 set from the index "offset" of the given array
  60218. * @param array defines the source array
  60219. * @param offset defines the offset in the source array
  60220. * @returns the new Vector3
  60221. */
  60222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60223. /**
  60224. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60225. * This function is deprecated. Use FromArray instead
  60226. * @param array defines the source array
  60227. * @param offset defines the offset in the source array
  60228. * @returns the new Vector3
  60229. */
  60230. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60231. /**
  60232. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60233. * @param array defines the source array
  60234. * @param offset defines the offset in the source array
  60235. * @param result defines the Vector3 where to store the result
  60236. */
  60237. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60238. /**
  60239. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60240. * This function is deprecated. Use FromArrayToRef instead.
  60241. * @param array defines the source array
  60242. * @param offset defines the offset in the source array
  60243. * @param result defines the Vector3 where to store the result
  60244. */
  60245. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60246. /**
  60247. * Sets the given vector "result" with the given floats.
  60248. * @param x defines the x coordinate of the source
  60249. * @param y defines the y coordinate of the source
  60250. * @param z defines the z coordinate of the source
  60251. * @param result defines the Vector3 where to store the result
  60252. */
  60253. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60254. /**
  60255. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60256. * @returns a new empty Vector3
  60257. */
  60258. static Zero(): Vector3;
  60259. /**
  60260. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60261. * @returns a new unit Vector3
  60262. */
  60263. static One(): Vector3;
  60264. /**
  60265. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60266. * @returns a new up Vector3
  60267. */
  60268. static Up(): Vector3;
  60269. /**
  60270. * Gets a up Vector3 that must not be updated
  60271. */
  60272. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60273. /**
  60274. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60275. * @returns a new down Vector3
  60276. */
  60277. static Down(): Vector3;
  60278. /**
  60279. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60280. * @returns a new forward Vector3
  60281. */
  60282. static Forward(): Vector3;
  60283. /**
  60284. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60285. * @returns a new forward Vector3
  60286. */
  60287. static Backward(): Vector3;
  60288. /**
  60289. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60290. * @returns a new right Vector3
  60291. */
  60292. static Right(): Vector3;
  60293. /**
  60294. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60295. * @returns a new left Vector3
  60296. */
  60297. static Left(): Vector3;
  60298. /**
  60299. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60300. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60301. * @param vector defines the Vector3 to transform
  60302. * @param transformation defines the transformation matrix
  60303. * @returns the transformed Vector3
  60304. */
  60305. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60306. /**
  60307. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60308. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60309. * @param vector defines the Vector3 to transform
  60310. * @param transformation defines the transformation matrix
  60311. * @param result defines the Vector3 where to store the result
  60312. */
  60313. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60314. /**
  60315. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60316. * This method computes tranformed coordinates only, not transformed direction vectors
  60317. * @param x define the x coordinate of the source vector
  60318. * @param y define the y coordinate of the source vector
  60319. * @param z define the z coordinate of the source vector
  60320. * @param transformation defines the transformation matrix
  60321. * @param result defines the Vector3 where to store the result
  60322. */
  60323. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60324. /**
  60325. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60326. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60327. * @param vector defines the Vector3 to transform
  60328. * @param transformation defines the transformation matrix
  60329. * @returns the new Vector3
  60330. */
  60331. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60332. /**
  60333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60334. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60335. * @param vector defines the Vector3 to transform
  60336. * @param transformation defines the transformation matrix
  60337. * @param result defines the Vector3 where to store the result
  60338. */
  60339. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60340. /**
  60341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60342. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60343. * @param x define the x coordinate of the source vector
  60344. * @param y define the y coordinate of the source vector
  60345. * @param z define the z coordinate of the source vector
  60346. * @param transformation defines the transformation matrix
  60347. * @param result defines the Vector3 where to store the result
  60348. */
  60349. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60350. /**
  60351. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60352. * @param value1 defines the first control point
  60353. * @param value2 defines the second control point
  60354. * @param value3 defines the third control point
  60355. * @param value4 defines the fourth control point
  60356. * @param amount defines the amount on the spline to use
  60357. * @returns the new Vector3
  60358. */
  60359. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60360. /**
  60361. * 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"
  60362. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60363. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60364. * @param value defines the current value
  60365. * @param min defines the lower range value
  60366. * @param max defines the upper range value
  60367. * @returns the new Vector3
  60368. */
  60369. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60370. /**
  60371. * 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"
  60372. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60373. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60374. * @param value defines the current value
  60375. * @param min defines the lower range value
  60376. * @param max defines the upper range value
  60377. * @param result defines the Vector3 where to store the result
  60378. */
  60379. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60380. /**
  60381. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60382. * @param value1 defines the first control point
  60383. * @param tangent1 defines the first tangent vector
  60384. * @param value2 defines the second control point
  60385. * @param tangent2 defines the second tangent vector
  60386. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60387. * @returns the new Vector3
  60388. */
  60389. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60390. /**
  60391. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60392. * @param start defines the start value
  60393. * @param end defines the end value
  60394. * @param amount max defines amount between both (between 0 and 1)
  60395. * @returns the new Vector3
  60396. */
  60397. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60398. /**
  60399. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60400. * @param start defines the start value
  60401. * @param end defines the end value
  60402. * @param amount max defines amount between both (between 0 and 1)
  60403. * @param result defines the Vector3 where to store the result
  60404. */
  60405. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60406. /**
  60407. * Returns the dot product (float) between the vectors "left" and "right"
  60408. * @param left defines the left operand
  60409. * @param right defines the right operand
  60410. * @returns the dot product
  60411. */
  60412. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60413. /**
  60414. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60415. * The cross product is then orthogonal to both "left" and "right"
  60416. * @param left defines the left operand
  60417. * @param right defines the right operand
  60418. * @returns the cross product
  60419. */
  60420. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60421. /**
  60422. * Sets the given vector "result" with the cross product of "left" and "right"
  60423. * The cross product is then orthogonal to both "left" and "right"
  60424. * @param left defines the left operand
  60425. * @param right defines the right operand
  60426. * @param result defines the Vector3 where to store the result
  60427. */
  60428. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60429. /**
  60430. * Returns a new Vector3 as the normalization of the given vector
  60431. * @param vector defines the Vector3 to normalize
  60432. * @returns the new Vector3
  60433. */
  60434. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60435. /**
  60436. * Sets the given vector "result" with the normalization of the given first vector
  60437. * @param vector defines the Vector3 to normalize
  60438. * @param result defines the Vector3 where to store the result
  60439. */
  60440. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60441. /**
  60442. * Project a Vector3 onto screen space
  60443. * @param vector defines the Vector3 to project
  60444. * @param world defines the world matrix to use
  60445. * @param transform defines the transform (view x projection) matrix to use
  60446. * @param viewport defines the screen viewport to use
  60447. * @returns the new Vector3
  60448. */
  60449. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60450. /** @hidden */
  60451. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60452. /**
  60453. * Unproject from screen space to object space
  60454. * @param source defines the screen space Vector3 to use
  60455. * @param viewportWidth defines the current width of the viewport
  60456. * @param viewportHeight defines the current height of the viewport
  60457. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60458. * @param transform defines the transform (view x projection) matrix to use
  60459. * @returns the new Vector3
  60460. */
  60461. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60462. /**
  60463. * Unproject from screen space to object space
  60464. * @param source defines the screen space Vector3 to use
  60465. * @param viewportWidth defines the current width of the viewport
  60466. * @param viewportHeight defines the current height of the viewport
  60467. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60468. * @param view defines the view matrix to use
  60469. * @param projection defines the projection matrix to use
  60470. * @returns the new Vector3
  60471. */
  60472. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60473. /**
  60474. * Unproject from screen space to object space
  60475. * @param source defines the screen space Vector3 to use
  60476. * @param viewportWidth defines the current width of the viewport
  60477. * @param viewportHeight defines the current height of the viewport
  60478. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60479. * @param view defines the view matrix to use
  60480. * @param projection defines the projection matrix to use
  60481. * @param result defines the Vector3 where to store the result
  60482. */
  60483. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60484. /**
  60485. * Unproject from screen space to object space
  60486. * @param sourceX defines the screen space x coordinate to use
  60487. * @param sourceY defines the screen space y coordinate to use
  60488. * @param sourceZ defines the screen space z coordinate to use
  60489. * @param viewportWidth defines the current width of the viewport
  60490. * @param viewportHeight defines the current height of the viewport
  60491. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60492. * @param view defines the view matrix to use
  60493. * @param projection defines the projection matrix to use
  60494. * @param result defines the Vector3 where to store the result
  60495. */
  60496. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60497. /**
  60498. * Gets the minimal coordinate values between two Vector3
  60499. * @param left defines the first operand
  60500. * @param right defines the second operand
  60501. * @returns the new Vector3
  60502. */
  60503. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60504. /**
  60505. * Gets the maximal coordinate values between two Vector3
  60506. * @param left defines the first operand
  60507. * @param right defines the second operand
  60508. * @returns the new Vector3
  60509. */
  60510. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60511. /**
  60512. * Returns the distance between the vectors "value1" and "value2"
  60513. * @param value1 defines the first operand
  60514. * @param value2 defines the second operand
  60515. * @returns the distance
  60516. */
  60517. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60518. /**
  60519. * Returns the squared distance between the vectors "value1" and "value2"
  60520. * @param value1 defines the first operand
  60521. * @param value2 defines the second operand
  60522. * @returns the squared distance
  60523. */
  60524. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60525. /**
  60526. * Returns a new Vector3 located at the center between "value1" and "value2"
  60527. * @param value1 defines the first operand
  60528. * @param value2 defines the second operand
  60529. * @returns the new Vector3
  60530. */
  60531. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60532. /**
  60533. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60534. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60535. * to something in order to rotate it from its local system to the given target system
  60536. * Note: axis1, axis2 and axis3 are normalized during this operation
  60537. * @param axis1 defines the first axis
  60538. * @param axis2 defines the second axis
  60539. * @param axis3 defines the third axis
  60540. * @returns a new Vector3
  60541. */
  60542. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  60543. /**
  60544. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  60545. * @param axis1 defines the first axis
  60546. * @param axis2 defines the second axis
  60547. * @param axis3 defines the third axis
  60548. * @param ref defines the Vector3 where to store the result
  60549. */
  60550. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  60551. }
  60552. /**
  60553. * Vector4 class created for EulerAngle class conversion to Quaternion
  60554. */
  60555. export class Vector4 {
  60556. /** x value of the vector */
  60557. x: number;
  60558. /** y value of the vector */
  60559. y: number;
  60560. /** z value of the vector */
  60561. z: number;
  60562. /** w value of the vector */
  60563. w: number;
  60564. /**
  60565. * Creates a Vector4 object from the given floats.
  60566. * @param x x value of the vector
  60567. * @param y y value of the vector
  60568. * @param z z value of the vector
  60569. * @param w w value of the vector
  60570. */
  60571. constructor(
  60572. /** x value of the vector */
  60573. x: number,
  60574. /** y value of the vector */
  60575. y: number,
  60576. /** z value of the vector */
  60577. z: number,
  60578. /** w value of the vector */
  60579. w: number);
  60580. /**
  60581. * Returns the string with the Vector4 coordinates.
  60582. * @returns a string containing all the vector values
  60583. */
  60584. toString(): string;
  60585. /**
  60586. * Returns the string "Vector4".
  60587. * @returns "Vector4"
  60588. */
  60589. getClassName(): string;
  60590. /**
  60591. * Returns the Vector4 hash code.
  60592. * @returns a unique hash code
  60593. */
  60594. getHashCode(): number;
  60595. /**
  60596. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  60597. * @returns the resulting array
  60598. */
  60599. asArray(): number[];
  60600. /**
  60601. * Populates the given array from the given index with the Vector4 coordinates.
  60602. * @param array array to populate
  60603. * @param index index of the array to start at (default: 0)
  60604. * @returns the Vector4.
  60605. */
  60606. toArray(array: FloatArray, index?: number): Vector4;
  60607. /**
  60608. * Adds the given vector to the current Vector4.
  60609. * @param otherVector the vector to add
  60610. * @returns the updated Vector4.
  60611. */
  60612. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60613. /**
  60614. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  60615. * @param otherVector the vector to add
  60616. * @returns the resulting vector
  60617. */
  60618. add(otherVector: DeepImmutable<Vector4>): Vector4;
  60619. /**
  60620. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  60621. * @param otherVector the vector to add
  60622. * @param result the vector to store the result
  60623. * @returns the current Vector4.
  60624. */
  60625. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60626. /**
  60627. * Subtract in place the given vector from the current Vector4.
  60628. * @param otherVector the vector to subtract
  60629. * @returns the updated Vector4.
  60630. */
  60631. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60632. /**
  60633. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  60634. * @param otherVector the vector to add
  60635. * @returns the new vector with the result
  60636. */
  60637. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  60638. /**
  60639. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  60640. * @param otherVector the vector to subtract
  60641. * @param result the vector to store the result
  60642. * @returns the current Vector4.
  60643. */
  60644. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60645. /**
  60646. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60647. */
  60648. /**
  60649. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60650. * @param x value to subtract
  60651. * @param y value to subtract
  60652. * @param z value to subtract
  60653. * @param w value to subtract
  60654. * @returns new vector containing the result
  60655. */
  60656. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60657. /**
  60658. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60659. * @param x value to subtract
  60660. * @param y value to subtract
  60661. * @param z value to subtract
  60662. * @param w value to subtract
  60663. * @param result the vector to store the result in
  60664. * @returns the current Vector4.
  60665. */
  60666. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  60667. /**
  60668. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  60669. * @returns a new vector with the negated values
  60670. */
  60671. negate(): Vector4;
  60672. /**
  60673. * Multiplies the current Vector4 coordinates by scale (float).
  60674. * @param scale the number to scale with
  60675. * @returns the updated Vector4.
  60676. */
  60677. scaleInPlace(scale: number): Vector4;
  60678. /**
  60679. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  60680. * @param scale the number to scale with
  60681. * @returns a new vector with the result
  60682. */
  60683. scale(scale: number): Vector4;
  60684. /**
  60685. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  60686. * @param scale the number to scale with
  60687. * @param result a vector to store the result in
  60688. * @returns the current Vector4.
  60689. */
  60690. scaleToRef(scale: number, result: Vector4): Vector4;
  60691. /**
  60692. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  60693. * @param scale defines the scale factor
  60694. * @param result defines the Vector4 object where to store the result
  60695. * @returns the unmodified current Vector4
  60696. */
  60697. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  60698. /**
  60699. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  60700. * @param otherVector the vector to compare against
  60701. * @returns true if they are equal
  60702. */
  60703. equals(otherVector: DeepImmutable<Vector4>): boolean;
  60704. /**
  60705. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  60706. * @param otherVector vector to compare against
  60707. * @param epsilon (Default: very small number)
  60708. * @returns true if they are equal
  60709. */
  60710. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  60711. /**
  60712. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  60713. * @param x x value to compare against
  60714. * @param y y value to compare against
  60715. * @param z z value to compare against
  60716. * @param w w value to compare against
  60717. * @returns true if equal
  60718. */
  60719. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  60720. /**
  60721. * Multiplies in place the current Vector4 by the given one.
  60722. * @param otherVector vector to multiple with
  60723. * @returns the updated Vector4.
  60724. */
  60725. multiplyInPlace(otherVector: Vector4): Vector4;
  60726. /**
  60727. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  60728. * @param otherVector vector to multiple with
  60729. * @returns resulting new vector
  60730. */
  60731. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60732. /**
  60733. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60734. * @param otherVector vector to multiple with
  60735. * @param result vector to store the result
  60736. * @returns the current Vector4.
  60737. */
  60738. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60739. /**
  60740. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60741. * @param x x value multiply with
  60742. * @param y y value multiply with
  60743. * @param z z value multiply with
  60744. * @param w w value multiply with
  60745. * @returns resulting new vector
  60746. */
  60747. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60748. /**
  60749. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60750. * @param otherVector vector to devide with
  60751. * @returns resulting new vector
  60752. */
  60753. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60754. /**
  60755. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60756. * @param otherVector vector to devide with
  60757. * @param result vector to store the result
  60758. * @returns the current Vector4.
  60759. */
  60760. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60761. /**
  60762. * Divides the current Vector3 coordinates by the given ones.
  60763. * @param otherVector vector to devide with
  60764. * @returns the updated Vector3.
  60765. */
  60766. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60767. /**
  60768. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60769. * @param other defines the second operand
  60770. * @returns the current updated Vector4
  60771. */
  60772. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60773. /**
  60774. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60775. * @param other defines the second operand
  60776. * @returns the current updated Vector4
  60777. */
  60778. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60779. /**
  60780. * Gets a new Vector4 from current Vector4 floored values
  60781. * @returns a new Vector4
  60782. */
  60783. floor(): Vector4;
  60784. /**
  60785. * Gets a new Vector4 from current Vector3 floored values
  60786. * @returns a new Vector4
  60787. */
  60788. fract(): Vector4;
  60789. /**
  60790. * Returns the Vector4 length (float).
  60791. * @returns the length
  60792. */
  60793. length(): number;
  60794. /**
  60795. * Returns the Vector4 squared length (float).
  60796. * @returns the length squared
  60797. */
  60798. lengthSquared(): number;
  60799. /**
  60800. * Normalizes in place the Vector4.
  60801. * @returns the updated Vector4.
  60802. */
  60803. normalize(): Vector4;
  60804. /**
  60805. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60806. * @returns this converted to a new vector3
  60807. */
  60808. toVector3(): Vector3;
  60809. /**
  60810. * Returns a new Vector4 copied from the current one.
  60811. * @returns the new cloned vector
  60812. */
  60813. clone(): Vector4;
  60814. /**
  60815. * Updates the current Vector4 with the given one coordinates.
  60816. * @param source the source vector to copy from
  60817. * @returns the updated Vector4.
  60818. */
  60819. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60820. /**
  60821. * Updates the current Vector4 coordinates with the given floats.
  60822. * @param x float to copy from
  60823. * @param y float to copy from
  60824. * @param z float to copy from
  60825. * @param w float to copy from
  60826. * @returns the updated Vector4.
  60827. */
  60828. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60829. /**
  60830. * Updates the current Vector4 coordinates with the given floats.
  60831. * @param x float to set from
  60832. * @param y float to set from
  60833. * @param z float to set from
  60834. * @param w float to set from
  60835. * @returns the updated Vector4.
  60836. */
  60837. set(x: number, y: number, z: number, w: number): Vector4;
  60838. /**
  60839. * Copies the given float to the current Vector3 coordinates
  60840. * @param v defines the x, y, z and w coordinates of the operand
  60841. * @returns the current updated Vector3
  60842. */
  60843. setAll(v: number): Vector4;
  60844. /**
  60845. * Returns a new Vector4 set from the starting index of the given array.
  60846. * @param array the array to pull values from
  60847. * @param offset the offset into the array to start at
  60848. * @returns the new vector
  60849. */
  60850. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60851. /**
  60852. * Updates the given vector "result" from the starting index of the given array.
  60853. * @param array the array to pull values from
  60854. * @param offset the offset into the array to start at
  60855. * @param result the vector to store the result in
  60856. */
  60857. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60858. /**
  60859. * Updates the given vector "result" from the starting index of the given Float32Array.
  60860. * @param array the array to pull values from
  60861. * @param offset the offset into the array to start at
  60862. * @param result the vector to store the result in
  60863. */
  60864. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60865. /**
  60866. * Updates the given vector "result" coordinates from the given floats.
  60867. * @param x float to set from
  60868. * @param y float to set from
  60869. * @param z float to set from
  60870. * @param w float to set from
  60871. * @param result the vector to the floats in
  60872. */
  60873. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60874. /**
  60875. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60876. * @returns the new vector
  60877. */
  60878. static Zero(): Vector4;
  60879. /**
  60880. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60881. * @returns the new vector
  60882. */
  60883. static One(): Vector4;
  60884. /**
  60885. * Returns a new normalized Vector4 from the given one.
  60886. * @param vector the vector to normalize
  60887. * @returns the vector
  60888. */
  60889. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60890. /**
  60891. * Updates the given vector "result" from the normalization of the given one.
  60892. * @param vector the vector to normalize
  60893. * @param result the vector to store the result in
  60894. */
  60895. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60896. /**
  60897. * Returns a vector with the minimum values from the left and right vectors
  60898. * @param left left vector to minimize
  60899. * @param right right vector to minimize
  60900. * @returns a new vector with the minimum of the left and right vector values
  60901. */
  60902. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60903. /**
  60904. * Returns a vector with the maximum values from the left and right vectors
  60905. * @param left left vector to maximize
  60906. * @param right right vector to maximize
  60907. * @returns a new vector with the maximum of the left and right vector values
  60908. */
  60909. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60910. /**
  60911. * Returns the distance (float) between the vectors "value1" and "value2".
  60912. * @param value1 value to calulate the distance between
  60913. * @param value2 value to calulate the distance between
  60914. * @return the distance between the two vectors
  60915. */
  60916. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60917. /**
  60918. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60919. * @param value1 value to calulate the distance between
  60920. * @param value2 value to calulate the distance between
  60921. * @return the distance between the two vectors squared
  60922. */
  60923. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60924. /**
  60925. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60926. * @param value1 value to calulate the center between
  60927. * @param value2 value to calulate the center between
  60928. * @return the center between the two vectors
  60929. */
  60930. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60931. /**
  60932. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60933. * This methods computes transformed normalized direction vectors only.
  60934. * @param vector the vector to transform
  60935. * @param transformation the transformation matrix to apply
  60936. * @returns the new vector
  60937. */
  60938. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60939. /**
  60940. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60941. * This methods computes transformed normalized direction vectors only.
  60942. * @param vector the vector to transform
  60943. * @param transformation the transformation matrix to apply
  60944. * @param result the vector to store the result in
  60945. */
  60946. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60947. /**
  60948. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60949. * This methods computes transformed normalized direction vectors only.
  60950. * @param x value to transform
  60951. * @param y value to transform
  60952. * @param z value to transform
  60953. * @param w value to transform
  60954. * @param transformation the transformation matrix to apply
  60955. * @param result the vector to store the results in
  60956. */
  60957. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60958. /**
  60959. * Creates a new Vector4 from a Vector3
  60960. * @param source defines the source data
  60961. * @param w defines the 4th component (default is 0)
  60962. * @returns a new Vector4
  60963. */
  60964. static FromVector3(source: Vector3, w?: number): Vector4;
  60965. }
  60966. /**
  60967. * Interface for the size containing width and height
  60968. */
  60969. export interface ISize {
  60970. /**
  60971. * Width
  60972. */
  60973. width: number;
  60974. /**
  60975. * Heighht
  60976. */
  60977. height: number;
  60978. }
  60979. /**
  60980. * Size containing widht and height
  60981. */
  60982. export class Size implements ISize {
  60983. /**
  60984. * Width
  60985. */
  60986. width: number;
  60987. /**
  60988. * Height
  60989. */
  60990. height: number;
  60991. /**
  60992. * Creates a Size object from the given width and height (floats).
  60993. * @param width width of the new size
  60994. * @param height height of the new size
  60995. */
  60996. constructor(width: number, height: number);
  60997. /**
  60998. * Returns a string with the Size width and height
  60999. * @returns a string with the Size width and height
  61000. */
  61001. toString(): string;
  61002. /**
  61003. * "Size"
  61004. * @returns the string "Size"
  61005. */
  61006. getClassName(): string;
  61007. /**
  61008. * Returns the Size hash code.
  61009. * @returns a hash code for a unique width and height
  61010. */
  61011. getHashCode(): number;
  61012. /**
  61013. * Updates the current size from the given one.
  61014. * @param src the given size
  61015. */
  61016. copyFrom(src: Size): void;
  61017. /**
  61018. * Updates in place the current Size from the given floats.
  61019. * @param width width of the new size
  61020. * @param height height of the new size
  61021. * @returns the updated Size.
  61022. */
  61023. copyFromFloats(width: number, height: number): Size;
  61024. /**
  61025. * Updates in place the current Size from the given floats.
  61026. * @param width width to set
  61027. * @param height height to set
  61028. * @returns the updated Size.
  61029. */
  61030. set(width: number, height: number): Size;
  61031. /**
  61032. * Multiplies the width and height by numbers
  61033. * @param w factor to multiple the width by
  61034. * @param h factor to multiple the height by
  61035. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61036. */
  61037. multiplyByFloats(w: number, h: number): Size;
  61038. /**
  61039. * Clones the size
  61040. * @returns a new Size copied from the given one.
  61041. */
  61042. clone(): Size;
  61043. /**
  61044. * True if the current Size and the given one width and height are strictly equal.
  61045. * @param other the other size to compare against
  61046. * @returns True if the current Size and the given one width and height are strictly equal.
  61047. */
  61048. equals(other: Size): boolean;
  61049. /**
  61050. * The surface of the Size : width * height (float).
  61051. */
  61052. readonly surface: number;
  61053. /**
  61054. * Create a new size of zero
  61055. * @returns a new Size set to (0.0, 0.0)
  61056. */
  61057. static Zero(): Size;
  61058. /**
  61059. * Sums the width and height of two sizes
  61060. * @param otherSize size to add to this size
  61061. * @returns a new Size set as the addition result of the current Size and the given one.
  61062. */
  61063. add(otherSize: Size): Size;
  61064. /**
  61065. * Subtracts the width and height of two
  61066. * @param otherSize size to subtract to this size
  61067. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61068. */
  61069. subtract(otherSize: Size): Size;
  61070. /**
  61071. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61072. * @param start starting size to lerp between
  61073. * @param end end size to lerp between
  61074. * @param amount amount to lerp between the start and end values
  61075. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61076. */
  61077. static Lerp(start: Size, end: Size, amount: number): Size;
  61078. }
  61079. /**
  61080. * Class used to store quaternion data
  61081. * @see https://en.wikipedia.org/wiki/Quaternion
  61082. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61083. */
  61084. export class Quaternion {
  61085. /** defines the first component (0 by default) */
  61086. x: number;
  61087. /** defines the second component (0 by default) */
  61088. y: number;
  61089. /** defines the third component (0 by default) */
  61090. z: number;
  61091. /** defines the fourth component (1.0 by default) */
  61092. w: number;
  61093. /**
  61094. * Creates a new Quaternion from the given floats
  61095. * @param x defines the first component (0 by default)
  61096. * @param y defines the second component (0 by default)
  61097. * @param z defines the third component (0 by default)
  61098. * @param w defines the fourth component (1.0 by default)
  61099. */
  61100. constructor(
  61101. /** defines the first component (0 by default) */
  61102. x?: number,
  61103. /** defines the second component (0 by default) */
  61104. y?: number,
  61105. /** defines the third component (0 by default) */
  61106. z?: number,
  61107. /** defines the fourth component (1.0 by default) */
  61108. w?: number);
  61109. /**
  61110. * Gets a string representation for the current quaternion
  61111. * @returns a string with the Quaternion coordinates
  61112. */
  61113. toString(): string;
  61114. /**
  61115. * Gets the class name of the quaternion
  61116. * @returns the string "Quaternion"
  61117. */
  61118. getClassName(): string;
  61119. /**
  61120. * Gets a hash code for this quaternion
  61121. * @returns the quaternion hash code
  61122. */
  61123. getHashCode(): number;
  61124. /**
  61125. * Copy the quaternion to an array
  61126. * @returns a new array populated with 4 elements from the quaternion coordinates
  61127. */
  61128. asArray(): number[];
  61129. /**
  61130. * Check if two quaternions are equals
  61131. * @param otherQuaternion defines the second operand
  61132. * @return true if the current quaternion and the given one coordinates are strictly equals
  61133. */
  61134. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61135. /**
  61136. * Clone the current quaternion
  61137. * @returns a new quaternion copied from the current one
  61138. */
  61139. clone(): Quaternion;
  61140. /**
  61141. * Copy a quaternion to the current one
  61142. * @param other defines the other quaternion
  61143. * @returns the updated current quaternion
  61144. */
  61145. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61146. /**
  61147. * Updates the current quaternion with the given float coordinates
  61148. * @param x defines the x coordinate
  61149. * @param y defines the y coordinate
  61150. * @param z defines the z coordinate
  61151. * @param w defines the w coordinate
  61152. * @returns the updated current quaternion
  61153. */
  61154. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61155. /**
  61156. * Updates the current quaternion from the given float coordinates
  61157. * @param x defines the x coordinate
  61158. * @param y defines the y coordinate
  61159. * @param z defines the z coordinate
  61160. * @param w defines the w coordinate
  61161. * @returns the updated current quaternion
  61162. */
  61163. set(x: number, y: number, z: number, w: number): Quaternion;
  61164. /**
  61165. * Adds two quaternions
  61166. * @param other defines the second operand
  61167. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61168. */
  61169. add(other: DeepImmutable<Quaternion>): Quaternion;
  61170. /**
  61171. * Add a quaternion to the current one
  61172. * @param other defines the quaternion to add
  61173. * @returns the current quaternion
  61174. */
  61175. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61176. /**
  61177. * Subtract two quaternions
  61178. * @param other defines the second operand
  61179. * @returns a new quaternion as the subtraction result of the given one from the current one
  61180. */
  61181. subtract(other: Quaternion): Quaternion;
  61182. /**
  61183. * Multiplies the current quaternion by a scale factor
  61184. * @param value defines the scale factor
  61185. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61186. */
  61187. scale(value: number): Quaternion;
  61188. /**
  61189. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61190. * @param scale defines the scale factor
  61191. * @param result defines the Quaternion object where to store the result
  61192. * @returns the unmodified current quaternion
  61193. */
  61194. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61195. /**
  61196. * Multiplies in place the current quaternion by a scale factor
  61197. * @param value defines the scale factor
  61198. * @returns the current modified quaternion
  61199. */
  61200. scaleInPlace(value: number): Quaternion;
  61201. /**
  61202. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61203. * @param scale defines the scale factor
  61204. * @param result defines the Quaternion object where to store the result
  61205. * @returns the unmodified current quaternion
  61206. */
  61207. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61208. /**
  61209. * Multiplies two quaternions
  61210. * @param q1 defines the second operand
  61211. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61212. */
  61213. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61214. /**
  61215. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61216. * @param q1 defines the second operand
  61217. * @param result defines the target quaternion
  61218. * @returns the current quaternion
  61219. */
  61220. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61221. /**
  61222. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61223. * @param q1 defines the second operand
  61224. * @returns the currentupdated quaternion
  61225. */
  61226. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61227. /**
  61228. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61229. * @param ref defines the target quaternion
  61230. * @returns the current quaternion
  61231. */
  61232. conjugateToRef(ref: Quaternion): Quaternion;
  61233. /**
  61234. * Conjugates in place (1-q) the current quaternion
  61235. * @returns the current updated quaternion
  61236. */
  61237. conjugateInPlace(): Quaternion;
  61238. /**
  61239. * Conjugates in place (1-q) the current quaternion
  61240. * @returns a new quaternion
  61241. */
  61242. conjugate(): Quaternion;
  61243. /**
  61244. * Gets length of current quaternion
  61245. * @returns the quaternion length (float)
  61246. */
  61247. length(): number;
  61248. /**
  61249. * Normalize in place the current quaternion
  61250. * @returns the current updated quaternion
  61251. */
  61252. normalize(): Quaternion;
  61253. /**
  61254. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61255. * @param order is a reserved parameter and is ignore for now
  61256. * @returns a new Vector3 containing the Euler angles
  61257. */
  61258. toEulerAngles(order?: string): Vector3;
  61259. /**
  61260. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61261. * @param result defines the vector which will be filled with the Euler angles
  61262. * @param order is a reserved parameter and is ignore for now
  61263. * @returns the current unchanged quaternion
  61264. */
  61265. toEulerAnglesToRef(result: Vector3): Quaternion;
  61266. /**
  61267. * Updates the given rotation matrix with the current quaternion values
  61268. * @param result defines the target matrix
  61269. * @returns the current unchanged quaternion
  61270. */
  61271. toRotationMatrix(result: Matrix): Quaternion;
  61272. /**
  61273. * Updates the current quaternion from the given rotation matrix values
  61274. * @param matrix defines the source matrix
  61275. * @returns the current updated quaternion
  61276. */
  61277. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61278. /**
  61279. * Creates a new quaternion from a rotation matrix
  61280. * @param matrix defines the source matrix
  61281. * @returns a new quaternion created from the given rotation matrix values
  61282. */
  61283. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61284. /**
  61285. * Updates the given quaternion with the given rotation matrix values
  61286. * @param matrix defines the source matrix
  61287. * @param result defines the target quaternion
  61288. */
  61289. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61290. /**
  61291. * Returns the dot product (float) between the quaternions "left" and "right"
  61292. * @param left defines the left operand
  61293. * @param right defines the right operand
  61294. * @returns the dot product
  61295. */
  61296. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61297. /**
  61298. * Checks if the two quaternions are close to each other
  61299. * @param quat0 defines the first quaternion to check
  61300. * @param quat1 defines the second quaternion to check
  61301. * @returns true if the two quaternions are close to each other
  61302. */
  61303. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61304. /**
  61305. * Creates an empty quaternion
  61306. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61307. */
  61308. static Zero(): Quaternion;
  61309. /**
  61310. * Inverse a given quaternion
  61311. * @param q defines the source quaternion
  61312. * @returns a new quaternion as the inverted current quaternion
  61313. */
  61314. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61315. /**
  61316. * Inverse a given quaternion
  61317. * @param q defines the source quaternion
  61318. * @param result the quaternion the result will be stored in
  61319. * @returns the result quaternion
  61320. */
  61321. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61322. /**
  61323. * Creates an identity quaternion
  61324. * @returns the identity quaternion
  61325. */
  61326. static Identity(): Quaternion;
  61327. /**
  61328. * Gets a boolean indicating if the given quaternion is identity
  61329. * @param quaternion defines the quaternion to check
  61330. * @returns true if the quaternion is identity
  61331. */
  61332. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61333. /**
  61334. * Creates a quaternion from a rotation around an axis
  61335. * @param axis defines the axis to use
  61336. * @param angle defines the angle to use
  61337. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61338. */
  61339. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61340. /**
  61341. * Creates a rotation around an axis and stores it into the given quaternion
  61342. * @param axis defines the axis to use
  61343. * @param angle defines the angle to use
  61344. * @param result defines the target quaternion
  61345. * @returns the target quaternion
  61346. */
  61347. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61348. /**
  61349. * Creates a new quaternion from data stored into an array
  61350. * @param array defines the data source
  61351. * @param offset defines the offset in the source array where the data starts
  61352. * @returns a new quaternion
  61353. */
  61354. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61355. /**
  61356. * Create a quaternion from Euler rotation angles
  61357. * @param x Pitch
  61358. * @param y Yaw
  61359. * @param z Roll
  61360. * @returns the new Quaternion
  61361. */
  61362. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61363. /**
  61364. * Updates a quaternion from Euler rotation angles
  61365. * @param x Pitch
  61366. * @param y Yaw
  61367. * @param z Roll
  61368. * @param result the quaternion to store the result
  61369. * @returns the updated quaternion
  61370. */
  61371. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61372. /**
  61373. * Create a quaternion from Euler rotation vector
  61374. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61375. * @returns the new Quaternion
  61376. */
  61377. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61378. /**
  61379. * Updates a quaternion from Euler rotation vector
  61380. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61381. * @param result the quaternion to store the result
  61382. * @returns the updated quaternion
  61383. */
  61384. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61385. /**
  61386. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61387. * @param yaw defines the rotation around Y axis
  61388. * @param pitch defines the rotation around X axis
  61389. * @param roll defines the rotation around Z axis
  61390. * @returns the new quaternion
  61391. */
  61392. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61393. /**
  61394. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61395. * @param yaw defines the rotation around Y axis
  61396. * @param pitch defines the rotation around X axis
  61397. * @param roll defines the rotation around Z axis
  61398. * @param result defines the target quaternion
  61399. */
  61400. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61401. /**
  61402. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61403. * @param alpha defines the rotation around first axis
  61404. * @param beta defines the rotation around second axis
  61405. * @param gamma defines the rotation around third axis
  61406. * @returns the new quaternion
  61407. */
  61408. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61409. /**
  61410. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61411. * @param alpha defines the rotation around first axis
  61412. * @param beta defines the rotation around second axis
  61413. * @param gamma defines the rotation around third axis
  61414. * @param result defines the target quaternion
  61415. */
  61416. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61417. /**
  61418. * 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)
  61419. * @param axis1 defines the first axis
  61420. * @param axis2 defines the second axis
  61421. * @param axis3 defines the third axis
  61422. * @returns the new quaternion
  61423. */
  61424. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61425. /**
  61426. * 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
  61427. * @param axis1 defines the first axis
  61428. * @param axis2 defines the second axis
  61429. * @param axis3 defines the third axis
  61430. * @param ref defines the target quaternion
  61431. */
  61432. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61433. /**
  61434. * Interpolates between two quaternions
  61435. * @param left defines first quaternion
  61436. * @param right defines second quaternion
  61437. * @param amount defines the gradient to use
  61438. * @returns the new interpolated quaternion
  61439. */
  61440. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61441. /**
  61442. * Interpolates between two quaternions and stores it into a target quaternion
  61443. * @param left defines first quaternion
  61444. * @param right defines second quaternion
  61445. * @param amount defines the gradient to use
  61446. * @param result defines the target quaternion
  61447. */
  61448. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61449. /**
  61450. * Interpolate between two quaternions using Hermite interpolation
  61451. * @param value1 defines first quaternion
  61452. * @param tangent1 defines the incoming tangent
  61453. * @param value2 defines second quaternion
  61454. * @param tangent2 defines the outgoing tangent
  61455. * @param amount defines the target quaternion
  61456. * @returns the new interpolated quaternion
  61457. */
  61458. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61459. }
  61460. /**
  61461. * Class used to store matrix data (4x4)
  61462. */
  61463. export class Matrix {
  61464. private static _updateFlagSeed;
  61465. private static _identityReadOnly;
  61466. private _isIdentity;
  61467. private _isIdentityDirty;
  61468. private _isIdentity3x2;
  61469. private _isIdentity3x2Dirty;
  61470. /**
  61471. * Gets the update flag of the matrix which is an unique number for the matrix.
  61472. * It will be incremented every time the matrix data change.
  61473. * You can use it to speed the comparison between two versions of the same matrix.
  61474. */
  61475. updateFlag: number;
  61476. private readonly _m;
  61477. /**
  61478. * Gets the internal data of the matrix
  61479. */
  61480. readonly m: DeepImmutable<Float32Array>;
  61481. /** @hidden */
  61482. _markAsUpdated(): void;
  61483. /** @hidden */
  61484. private _updateIdentityStatus;
  61485. /**
  61486. * Creates an empty matrix (filled with zeros)
  61487. */
  61488. constructor();
  61489. /**
  61490. * Check if the current matrix is identity
  61491. * @returns true is the matrix is the identity matrix
  61492. */
  61493. isIdentity(): boolean;
  61494. /**
  61495. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61496. * @returns true is the matrix is the identity matrix
  61497. */
  61498. isIdentityAs3x2(): boolean;
  61499. /**
  61500. * Gets the determinant of the matrix
  61501. * @returns the matrix determinant
  61502. */
  61503. determinant(): number;
  61504. /**
  61505. * Returns the matrix as a Float32Array
  61506. * @returns the matrix underlying array
  61507. */
  61508. toArray(): DeepImmutable<Float32Array>;
  61509. /**
  61510. * Returns the matrix as a Float32Array
  61511. * @returns the matrix underlying array.
  61512. */
  61513. asArray(): DeepImmutable<Float32Array>;
  61514. /**
  61515. * Inverts the current matrix in place
  61516. * @returns the current inverted matrix
  61517. */
  61518. invert(): Matrix;
  61519. /**
  61520. * Sets all the matrix elements to zero
  61521. * @returns the current matrix
  61522. */
  61523. reset(): Matrix;
  61524. /**
  61525. * Adds the current matrix with a second one
  61526. * @param other defines the matrix to add
  61527. * @returns a new matrix as the addition of the current matrix and the given one
  61528. */
  61529. add(other: DeepImmutable<Matrix>): Matrix;
  61530. /**
  61531. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61532. * @param other defines the matrix to add
  61533. * @param result defines the target matrix
  61534. * @returns the current matrix
  61535. */
  61536. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61537. /**
  61538. * Adds in place the given matrix to the current matrix
  61539. * @param other defines the second operand
  61540. * @returns the current updated matrix
  61541. */
  61542. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  61543. /**
  61544. * Sets the given matrix to the current inverted Matrix
  61545. * @param other defines the target matrix
  61546. * @returns the unmodified current matrix
  61547. */
  61548. invertToRef(other: Matrix): Matrix;
  61549. /**
  61550. * add a value at the specified position in the current Matrix
  61551. * @param index the index of the value within the matrix. between 0 and 15.
  61552. * @param value the value to be added
  61553. * @returns the current updated matrix
  61554. */
  61555. addAtIndex(index: number, value: number): Matrix;
  61556. /**
  61557. * mutiply the specified position in the current Matrix by a value
  61558. * @param index the index of the value within the matrix. between 0 and 15.
  61559. * @param value the value to be added
  61560. * @returns the current updated matrix
  61561. */
  61562. multiplyAtIndex(index: number, value: number): Matrix;
  61563. /**
  61564. * Inserts the translation vector (using 3 floats) in the current matrix
  61565. * @param x defines the 1st component of the translation
  61566. * @param y defines the 2nd component of the translation
  61567. * @param z defines the 3rd component of the translation
  61568. * @returns the current updated matrix
  61569. */
  61570. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  61571. /**
  61572. * Inserts the translation vector in the current matrix
  61573. * @param vector3 defines the translation to insert
  61574. * @returns the current updated matrix
  61575. */
  61576. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  61577. /**
  61578. * Gets the translation value of the current matrix
  61579. * @returns a new Vector3 as the extracted translation from the matrix
  61580. */
  61581. getTranslation(): Vector3;
  61582. /**
  61583. * Fill a Vector3 with the extracted translation from the matrix
  61584. * @param result defines the Vector3 where to store the translation
  61585. * @returns the current matrix
  61586. */
  61587. getTranslationToRef(result: Vector3): Matrix;
  61588. /**
  61589. * Remove rotation and scaling part from the matrix
  61590. * @returns the updated matrix
  61591. */
  61592. removeRotationAndScaling(): Matrix;
  61593. /**
  61594. * Multiply two matrices
  61595. * @param other defines the second operand
  61596. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  61597. */
  61598. multiply(other: DeepImmutable<Matrix>): Matrix;
  61599. /**
  61600. * Copy the current matrix from the given one
  61601. * @param other defines the source matrix
  61602. * @returns the current updated matrix
  61603. */
  61604. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  61605. /**
  61606. * Populates the given array from the starting index with the current matrix values
  61607. * @param array defines the target array
  61608. * @param offset defines the offset in the target array where to start storing values
  61609. * @returns the current matrix
  61610. */
  61611. copyToArray(array: Float32Array, offset?: number): Matrix;
  61612. /**
  61613. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  61614. * @param other defines the second operand
  61615. * @param result defines the matrix where to store the multiplication
  61616. * @returns the current matrix
  61617. */
  61618. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61619. /**
  61620. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  61621. * @param other defines the second operand
  61622. * @param result defines the array where to store the multiplication
  61623. * @param offset defines the offset in the target array where to start storing values
  61624. * @returns the current matrix
  61625. */
  61626. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  61627. /**
  61628. * Check equality between this matrix and a second one
  61629. * @param value defines the second matrix to compare
  61630. * @returns true is the current matrix and the given one values are strictly equal
  61631. */
  61632. equals(value: DeepImmutable<Matrix>): boolean;
  61633. /**
  61634. * Clone the current matrix
  61635. * @returns a new matrix from the current matrix
  61636. */
  61637. clone(): Matrix;
  61638. /**
  61639. * Returns the name of the current matrix class
  61640. * @returns the string "Matrix"
  61641. */
  61642. getClassName(): string;
  61643. /**
  61644. * Gets the hash code of the current matrix
  61645. * @returns the hash code
  61646. */
  61647. getHashCode(): number;
  61648. /**
  61649. * Decomposes the current Matrix into a translation, rotation and scaling components
  61650. * @param scale defines the scale vector3 given as a reference to update
  61651. * @param rotation defines the rotation quaternion given as a reference to update
  61652. * @param translation defines the translation vector3 given as a reference to update
  61653. * @returns true if operation was successful
  61654. */
  61655. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  61656. /**
  61657. * Gets specific row of the matrix
  61658. * @param index defines the number of the row to get
  61659. * @returns the index-th row of the current matrix as a new Vector4
  61660. */
  61661. getRow(index: number): Nullable<Vector4>;
  61662. /**
  61663. * Sets the index-th row of the current matrix to the vector4 values
  61664. * @param index defines the number of the row to set
  61665. * @param row defines the target vector4
  61666. * @returns the updated current matrix
  61667. */
  61668. setRow(index: number, row: Vector4): Matrix;
  61669. /**
  61670. * Compute the transpose of the matrix
  61671. * @returns the new transposed matrix
  61672. */
  61673. transpose(): Matrix;
  61674. /**
  61675. * Compute the transpose of the matrix and store it in a given matrix
  61676. * @param result defines the target matrix
  61677. * @returns the current matrix
  61678. */
  61679. transposeToRef(result: Matrix): Matrix;
  61680. /**
  61681. * Sets the index-th row of the current matrix with the given 4 x float values
  61682. * @param index defines the row index
  61683. * @param x defines the x component to set
  61684. * @param y defines the y component to set
  61685. * @param z defines the z component to set
  61686. * @param w defines the w component to set
  61687. * @returns the updated current matrix
  61688. */
  61689. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  61690. /**
  61691. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  61692. * @param scale defines the scale factor
  61693. * @returns a new matrix
  61694. */
  61695. scale(scale: number): Matrix;
  61696. /**
  61697. * Scale the current matrix values by a factor to a given result matrix
  61698. * @param scale defines the scale factor
  61699. * @param result defines the matrix to store the result
  61700. * @returns the current matrix
  61701. */
  61702. scaleToRef(scale: number, result: Matrix): Matrix;
  61703. /**
  61704. * Scale the current matrix values by a factor and add the result to a given matrix
  61705. * @param scale defines the scale factor
  61706. * @param result defines the Matrix to store the result
  61707. * @returns the current matrix
  61708. */
  61709. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  61710. /**
  61711. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  61712. * @param ref matrix to store the result
  61713. */
  61714. toNormalMatrix(ref: Matrix): void;
  61715. /**
  61716. * Gets only rotation part of the current matrix
  61717. * @returns a new matrix sets to the extracted rotation matrix from the current one
  61718. */
  61719. getRotationMatrix(): Matrix;
  61720. /**
  61721. * Extracts the rotation matrix from the current one and sets it as the given "result"
  61722. * @param result defines the target matrix to store data to
  61723. * @returns the current matrix
  61724. */
  61725. getRotationMatrixToRef(result: Matrix): Matrix;
  61726. /**
  61727. * Toggles model matrix from being right handed to left handed in place and vice versa
  61728. */
  61729. toggleModelMatrixHandInPlace(): void;
  61730. /**
  61731. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61732. */
  61733. toggleProjectionMatrixHandInPlace(): void;
  61734. /**
  61735. * Creates a matrix from an array
  61736. * @param array defines the source array
  61737. * @param offset defines an offset in the source array
  61738. * @returns a new Matrix set from the starting index of the given array
  61739. */
  61740. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61741. /**
  61742. * Copy the content of an array into a given matrix
  61743. * @param array defines the source array
  61744. * @param offset defines an offset in the source array
  61745. * @param result defines the target matrix
  61746. */
  61747. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61748. /**
  61749. * Stores an array into a matrix after having multiplied each component by a given factor
  61750. * @param array defines the source array
  61751. * @param offset defines the offset in the source array
  61752. * @param scale defines the scaling factor
  61753. * @param result defines the target matrix
  61754. */
  61755. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61756. /**
  61757. * Gets an identity matrix that must not be updated
  61758. */
  61759. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61760. /**
  61761. * Stores a list of values (16) inside a given matrix
  61762. * @param initialM11 defines 1st value of 1st row
  61763. * @param initialM12 defines 2nd value of 1st row
  61764. * @param initialM13 defines 3rd value of 1st row
  61765. * @param initialM14 defines 4th value of 1st row
  61766. * @param initialM21 defines 1st value of 2nd row
  61767. * @param initialM22 defines 2nd value of 2nd row
  61768. * @param initialM23 defines 3rd value of 2nd row
  61769. * @param initialM24 defines 4th value of 2nd row
  61770. * @param initialM31 defines 1st value of 3rd row
  61771. * @param initialM32 defines 2nd value of 3rd row
  61772. * @param initialM33 defines 3rd value of 3rd row
  61773. * @param initialM34 defines 4th value of 3rd row
  61774. * @param initialM41 defines 1st value of 4th row
  61775. * @param initialM42 defines 2nd value of 4th row
  61776. * @param initialM43 defines 3rd value of 4th row
  61777. * @param initialM44 defines 4th value of 4th row
  61778. * @param result defines the target matrix
  61779. */
  61780. 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;
  61781. /**
  61782. * Creates new matrix from a list of values (16)
  61783. * @param initialM11 defines 1st value of 1st row
  61784. * @param initialM12 defines 2nd value of 1st row
  61785. * @param initialM13 defines 3rd value of 1st row
  61786. * @param initialM14 defines 4th value of 1st row
  61787. * @param initialM21 defines 1st value of 2nd row
  61788. * @param initialM22 defines 2nd value of 2nd row
  61789. * @param initialM23 defines 3rd value of 2nd row
  61790. * @param initialM24 defines 4th value of 2nd row
  61791. * @param initialM31 defines 1st value of 3rd row
  61792. * @param initialM32 defines 2nd value of 3rd row
  61793. * @param initialM33 defines 3rd value of 3rd row
  61794. * @param initialM34 defines 4th value of 3rd row
  61795. * @param initialM41 defines 1st value of 4th row
  61796. * @param initialM42 defines 2nd value of 4th row
  61797. * @param initialM43 defines 3rd value of 4th row
  61798. * @param initialM44 defines 4th value of 4th row
  61799. * @returns the new matrix
  61800. */
  61801. 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;
  61802. /**
  61803. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61804. * @param scale defines the scale vector3
  61805. * @param rotation defines the rotation quaternion
  61806. * @param translation defines the translation vector3
  61807. * @returns a new matrix
  61808. */
  61809. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61810. /**
  61811. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61812. * @param scale defines the scale vector3
  61813. * @param rotation defines the rotation quaternion
  61814. * @param translation defines the translation vector3
  61815. * @param result defines the target matrix
  61816. */
  61817. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61818. /**
  61819. * Creates a new identity matrix
  61820. * @returns a new identity matrix
  61821. */
  61822. static Identity(): Matrix;
  61823. /**
  61824. * Creates a new identity matrix and stores the result in a given matrix
  61825. * @param result defines the target matrix
  61826. */
  61827. static IdentityToRef(result: Matrix): void;
  61828. /**
  61829. * Creates a new zero matrix
  61830. * @returns a new zero matrix
  61831. */
  61832. static Zero(): Matrix;
  61833. /**
  61834. * Creates a new rotation matrix for "angle" radians around the X axis
  61835. * @param angle defines the angle (in radians) to use
  61836. * @return the new matrix
  61837. */
  61838. static RotationX(angle: number): Matrix;
  61839. /**
  61840. * Creates a new matrix as the invert of a given matrix
  61841. * @param source defines the source matrix
  61842. * @returns the new matrix
  61843. */
  61844. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61845. /**
  61846. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61847. * @param angle defines the angle (in radians) to use
  61848. * @param result defines the target matrix
  61849. */
  61850. static RotationXToRef(angle: number, result: Matrix): void;
  61851. /**
  61852. * Creates a new rotation matrix for "angle" radians around the Y axis
  61853. * @param angle defines the angle (in radians) to use
  61854. * @return the new matrix
  61855. */
  61856. static RotationY(angle: number): Matrix;
  61857. /**
  61858. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61859. * @param angle defines the angle (in radians) to use
  61860. * @param result defines the target matrix
  61861. */
  61862. static RotationYToRef(angle: number, result: Matrix): void;
  61863. /**
  61864. * Creates a new rotation matrix for "angle" radians around the Z axis
  61865. * @param angle defines the angle (in radians) to use
  61866. * @return the new matrix
  61867. */
  61868. static RotationZ(angle: number): Matrix;
  61869. /**
  61870. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61871. * @param angle defines the angle (in radians) to use
  61872. * @param result defines the target matrix
  61873. */
  61874. static RotationZToRef(angle: number, result: Matrix): void;
  61875. /**
  61876. * Creates a new rotation matrix for "angle" radians around the given axis
  61877. * @param axis defines the axis to use
  61878. * @param angle defines the angle (in radians) to use
  61879. * @return the new matrix
  61880. */
  61881. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61882. /**
  61883. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61884. * @param axis defines the axis to use
  61885. * @param angle defines the angle (in radians) to use
  61886. * @param result defines the target matrix
  61887. */
  61888. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61889. /**
  61890. * Creates a rotation matrix
  61891. * @param yaw defines the yaw angle in radians (Y axis)
  61892. * @param pitch defines the pitch angle in radians (X axis)
  61893. * @param roll defines the roll angle in radians (X axis)
  61894. * @returns the new rotation matrix
  61895. */
  61896. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61897. /**
  61898. * Creates a rotation matrix and stores it in a given matrix
  61899. * @param yaw defines the yaw angle in radians (Y axis)
  61900. * @param pitch defines the pitch angle in radians (X axis)
  61901. * @param roll defines the roll angle in radians (X axis)
  61902. * @param result defines the target matrix
  61903. */
  61904. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61905. /**
  61906. * Creates a scaling matrix
  61907. * @param x defines the scale factor on X axis
  61908. * @param y defines the scale factor on Y axis
  61909. * @param z defines the scale factor on Z axis
  61910. * @returns the new matrix
  61911. */
  61912. static Scaling(x: number, y: number, z: number): Matrix;
  61913. /**
  61914. * Creates a scaling matrix and stores it in a given matrix
  61915. * @param x defines the scale factor on X axis
  61916. * @param y defines the scale factor on Y axis
  61917. * @param z defines the scale factor on Z axis
  61918. * @param result defines the target matrix
  61919. */
  61920. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61921. /**
  61922. * Creates a translation matrix
  61923. * @param x defines the translation on X axis
  61924. * @param y defines the translation on Y axis
  61925. * @param z defines the translationon Z axis
  61926. * @returns the new matrix
  61927. */
  61928. static Translation(x: number, y: number, z: number): Matrix;
  61929. /**
  61930. * Creates a translation matrix and stores it in a given matrix
  61931. * @param x defines the translation on X axis
  61932. * @param y defines the translation on Y axis
  61933. * @param z defines the translationon Z axis
  61934. * @param result defines the target matrix
  61935. */
  61936. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61937. /**
  61938. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61939. * @param startValue defines the start value
  61940. * @param endValue defines the end value
  61941. * @param gradient defines the gradient factor
  61942. * @returns the new matrix
  61943. */
  61944. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61945. /**
  61946. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61947. * @param startValue defines the start value
  61948. * @param endValue defines the end value
  61949. * @param gradient defines the gradient factor
  61950. * @param result defines the Matrix object where to store data
  61951. */
  61952. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61953. /**
  61954. * Builds a new matrix whose values are computed by:
  61955. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61956. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61957. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61958. * @param startValue defines the first matrix
  61959. * @param endValue defines the second matrix
  61960. * @param gradient defines the gradient between the two matrices
  61961. * @returns the new matrix
  61962. */
  61963. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61964. /**
  61965. * Update a matrix to values which are computed by:
  61966. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61967. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61968. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61969. * @param startValue defines the first matrix
  61970. * @param endValue defines the second matrix
  61971. * @param gradient defines the gradient between the two matrices
  61972. * @param result defines the target matrix
  61973. */
  61974. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61975. /**
  61976. * 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"
  61977. * This function works in left handed mode
  61978. * @param eye defines the final position of the entity
  61979. * @param target defines where the entity should look at
  61980. * @param up defines the up vector for the entity
  61981. * @returns the new matrix
  61982. */
  61983. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61984. /**
  61985. * 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".
  61986. * This function works in left handed mode
  61987. * @param eye defines the final position of the entity
  61988. * @param target defines where the entity should look at
  61989. * @param up defines the up vector for the entity
  61990. * @param result defines the target matrix
  61991. */
  61992. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61993. /**
  61994. * 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"
  61995. * This function works in right handed mode
  61996. * @param eye defines the final position of the entity
  61997. * @param target defines where the entity should look at
  61998. * @param up defines the up vector for the entity
  61999. * @returns the new matrix
  62000. */
  62001. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62002. /**
  62003. * 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".
  62004. * This function works in right handed mode
  62005. * @param eye defines the final position of the entity
  62006. * @param target defines where the entity should look at
  62007. * @param up defines the up vector for the entity
  62008. * @param result defines the target matrix
  62009. */
  62010. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62011. /**
  62012. * Create a left-handed orthographic projection matrix
  62013. * @param width defines the viewport width
  62014. * @param height defines the viewport height
  62015. * @param znear defines the near clip plane
  62016. * @param zfar defines the far clip plane
  62017. * @returns a new matrix as a left-handed orthographic projection matrix
  62018. */
  62019. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62020. /**
  62021. * Store a left-handed orthographic projection to a given matrix
  62022. * @param width defines the viewport width
  62023. * @param height defines the viewport height
  62024. * @param znear defines the near clip plane
  62025. * @param zfar defines the far clip plane
  62026. * @param result defines the target matrix
  62027. */
  62028. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62029. /**
  62030. * Create a left-handed orthographic projection matrix
  62031. * @param left defines the viewport left coordinate
  62032. * @param right defines the viewport right coordinate
  62033. * @param bottom defines the viewport bottom coordinate
  62034. * @param top defines the viewport top coordinate
  62035. * @param znear defines the near clip plane
  62036. * @param zfar defines the far clip plane
  62037. * @returns a new matrix as a left-handed orthographic projection matrix
  62038. */
  62039. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62040. /**
  62041. * Stores a left-handed orthographic projection into a given matrix
  62042. * @param left defines the viewport left coordinate
  62043. * @param right defines the viewport right coordinate
  62044. * @param bottom defines the viewport bottom coordinate
  62045. * @param top defines the viewport top coordinate
  62046. * @param znear defines the near clip plane
  62047. * @param zfar defines the far clip plane
  62048. * @param result defines the target matrix
  62049. */
  62050. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62051. /**
  62052. * Creates a right-handed orthographic projection matrix
  62053. * @param left defines the viewport left coordinate
  62054. * @param right defines the viewport right coordinate
  62055. * @param bottom defines the viewport bottom coordinate
  62056. * @param top defines the viewport top coordinate
  62057. * @param znear defines the near clip plane
  62058. * @param zfar defines the far clip plane
  62059. * @returns a new matrix as a right-handed orthographic projection matrix
  62060. */
  62061. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62062. /**
  62063. * Stores a right-handed orthographic projection into a given matrix
  62064. * @param left defines the viewport left coordinate
  62065. * @param right defines the viewport right coordinate
  62066. * @param bottom defines the viewport bottom coordinate
  62067. * @param top defines the viewport top coordinate
  62068. * @param znear defines the near clip plane
  62069. * @param zfar defines the far clip plane
  62070. * @param result defines the target matrix
  62071. */
  62072. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62073. /**
  62074. * Creates a left-handed perspective projection matrix
  62075. * @param width defines the viewport width
  62076. * @param height defines the viewport height
  62077. * @param znear defines the near clip plane
  62078. * @param zfar defines the far clip plane
  62079. * @returns a new matrix as a left-handed perspective projection matrix
  62080. */
  62081. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62082. /**
  62083. * Creates a left-handed perspective projection matrix
  62084. * @param fov defines the horizontal field of view
  62085. * @param aspect defines the aspect ratio
  62086. * @param znear defines the near clip plane
  62087. * @param zfar defines the far clip plane
  62088. * @returns a new matrix as a left-handed perspective projection matrix
  62089. */
  62090. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62091. /**
  62092. * Stores a left-handed perspective projection into a given matrix
  62093. * @param fov defines the horizontal field of view
  62094. * @param aspect defines the aspect ratio
  62095. * @param znear defines the near clip plane
  62096. * @param zfar defines the far clip plane
  62097. * @param result defines the target matrix
  62098. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62099. */
  62100. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62101. /**
  62102. * Creates a right-handed perspective projection matrix
  62103. * @param fov defines the horizontal field of view
  62104. * @param aspect defines the aspect ratio
  62105. * @param znear defines the near clip plane
  62106. * @param zfar defines the far clip plane
  62107. * @returns a new matrix as a right-handed perspective projection matrix
  62108. */
  62109. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62110. /**
  62111. * Stores a right-handed perspective projection into a given matrix
  62112. * @param fov defines the horizontal field of view
  62113. * @param aspect defines the aspect ratio
  62114. * @param znear defines the near clip plane
  62115. * @param zfar defines the far clip plane
  62116. * @param result defines the target matrix
  62117. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62118. */
  62119. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62120. /**
  62121. * Stores a perspective projection for WebVR info a given matrix
  62122. * @param fov defines the field of view
  62123. * @param znear defines the near clip plane
  62124. * @param zfar defines the far clip plane
  62125. * @param result defines the target matrix
  62126. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62127. */
  62128. static PerspectiveFovWebVRToRef(fov: {
  62129. upDegrees: number;
  62130. downDegrees: number;
  62131. leftDegrees: number;
  62132. rightDegrees: number;
  62133. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62134. /**
  62135. * Computes a complete transformation matrix
  62136. * @param viewport defines the viewport to use
  62137. * @param world defines the world matrix
  62138. * @param view defines the view matrix
  62139. * @param projection defines the projection matrix
  62140. * @param zmin defines the near clip plane
  62141. * @param zmax defines the far clip plane
  62142. * @returns the transformation matrix
  62143. */
  62144. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62145. /**
  62146. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62147. * @param matrix defines the matrix to use
  62148. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62149. */
  62150. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62151. /**
  62152. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62153. * @param matrix defines the matrix to use
  62154. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62155. */
  62156. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62157. /**
  62158. * Compute the transpose of a given matrix
  62159. * @param matrix defines the matrix to transpose
  62160. * @returns the new matrix
  62161. */
  62162. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62163. /**
  62164. * Compute the transpose of a matrix and store it in a target matrix
  62165. * @param matrix defines the matrix to transpose
  62166. * @param result defines the target matrix
  62167. */
  62168. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62169. /**
  62170. * Computes a reflection matrix from a plane
  62171. * @param plane defines the reflection plane
  62172. * @returns a new matrix
  62173. */
  62174. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62175. /**
  62176. * Computes a reflection matrix from a plane
  62177. * @param plane defines the reflection plane
  62178. * @param result defines the target matrix
  62179. */
  62180. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62181. /**
  62182. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62183. * @param xaxis defines the value of the 1st axis
  62184. * @param yaxis defines the value of the 2nd axis
  62185. * @param zaxis defines the value of the 3rd axis
  62186. * @param result defines the target matrix
  62187. */
  62188. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62189. /**
  62190. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62191. * @param quat defines the quaternion to use
  62192. * @param result defines the target matrix
  62193. */
  62194. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62195. }
  62196. /**
  62197. * Represens a plane by the equation ax + by + cz + d = 0
  62198. */
  62199. export class Plane {
  62200. /**
  62201. * Normal of the plane (a,b,c)
  62202. */
  62203. normal: Vector3;
  62204. /**
  62205. * d component of the plane
  62206. */
  62207. d: number;
  62208. /**
  62209. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62210. * @param a a component of the plane
  62211. * @param b b component of the plane
  62212. * @param c c component of the plane
  62213. * @param d d component of the plane
  62214. */
  62215. constructor(a: number, b: number, c: number, d: number);
  62216. /**
  62217. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62218. */
  62219. asArray(): number[];
  62220. /**
  62221. * @returns a new plane copied from the current Plane.
  62222. */
  62223. clone(): Plane;
  62224. /**
  62225. * @returns the string "Plane".
  62226. */
  62227. getClassName(): string;
  62228. /**
  62229. * @returns the Plane hash code.
  62230. */
  62231. getHashCode(): number;
  62232. /**
  62233. * Normalize the current Plane in place.
  62234. * @returns the updated Plane.
  62235. */
  62236. normalize(): Plane;
  62237. /**
  62238. * Applies a transformation the plane and returns the result
  62239. * @param transformation the transformation matrix to be applied to the plane
  62240. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62241. */
  62242. transform(transformation: DeepImmutable<Matrix>): Plane;
  62243. /**
  62244. * Calcualtte the dot product between the point and the plane normal
  62245. * @param point point to calculate the dot product with
  62246. * @returns the dot product (float) of the point coordinates and the plane normal.
  62247. */
  62248. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62249. /**
  62250. * Updates the current Plane from the plane defined by the three given points.
  62251. * @param point1 one of the points used to contruct the plane
  62252. * @param point2 one of the points used to contruct the plane
  62253. * @param point3 one of the points used to contruct the plane
  62254. * @returns the updated Plane.
  62255. */
  62256. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62257. /**
  62258. * Checks if the plane is facing a given direction
  62259. * @param direction the direction to check if the plane is facing
  62260. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62261. * @returns True is the vector "direction" is the same side than the plane normal.
  62262. */
  62263. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62264. /**
  62265. * Calculates the distance to a point
  62266. * @param point point to calculate distance to
  62267. * @returns the signed distance (float) from the given point to the Plane.
  62268. */
  62269. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62270. /**
  62271. * Creates a plane from an array
  62272. * @param array the array to create a plane from
  62273. * @returns a new Plane from the given array.
  62274. */
  62275. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62276. /**
  62277. * Creates a plane from three points
  62278. * @param point1 point used to create the plane
  62279. * @param point2 point used to create the plane
  62280. * @param point3 point used to create the plane
  62281. * @returns a new Plane defined by the three given points.
  62282. */
  62283. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62284. /**
  62285. * Creates a plane from an origin point and a normal
  62286. * @param origin origin of the plane to be constructed
  62287. * @param normal normal of the plane to be constructed
  62288. * @returns a new Plane the normal vector to this plane at the given origin point.
  62289. * Note : the vector "normal" is updated because normalized.
  62290. */
  62291. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62292. /**
  62293. * Calculates the distance from a plane and a point
  62294. * @param origin origin of the plane to be constructed
  62295. * @param normal normal of the plane to be constructed
  62296. * @param point point to calculate distance to
  62297. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62298. */
  62299. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62300. }
  62301. /**
  62302. * Class used to represent a viewport on screen
  62303. */
  62304. export class Viewport {
  62305. /** viewport left coordinate */
  62306. x: number;
  62307. /** viewport top coordinate */
  62308. y: number;
  62309. /**viewport width */
  62310. width: number;
  62311. /** viewport height */
  62312. height: number;
  62313. /**
  62314. * Creates a Viewport object located at (x, y) and sized (width, height)
  62315. * @param x defines viewport left coordinate
  62316. * @param y defines viewport top coordinate
  62317. * @param width defines the viewport width
  62318. * @param height defines the viewport height
  62319. */
  62320. constructor(
  62321. /** viewport left coordinate */
  62322. x: number,
  62323. /** viewport top coordinate */
  62324. y: number,
  62325. /**viewport width */
  62326. width: number,
  62327. /** viewport height */
  62328. height: number);
  62329. /**
  62330. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62331. * @param renderWidth defines the rendering width
  62332. * @param renderHeight defines the rendering height
  62333. * @returns a new Viewport
  62334. */
  62335. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62336. /**
  62337. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62338. * @param renderWidth defines the rendering width
  62339. * @param renderHeight defines the rendering height
  62340. * @param ref defines the target viewport
  62341. * @returns the current viewport
  62342. */
  62343. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62344. /**
  62345. * Returns a new Viewport copied from the current one
  62346. * @returns a new Viewport
  62347. */
  62348. clone(): Viewport;
  62349. }
  62350. /**
  62351. * Reprasents a camera frustum
  62352. */
  62353. export class Frustum {
  62354. /**
  62355. * Gets the planes representing the frustum
  62356. * @param transform matrix to be applied to the returned planes
  62357. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62358. */
  62359. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62360. /**
  62361. * Gets the near frustum plane transformed by the transform matrix
  62362. * @param transform transformation matrix to be applied to the resulting frustum plane
  62363. * @param frustumPlane the resuling frustum plane
  62364. */
  62365. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62366. /**
  62367. * Gets the far frustum plane transformed by the transform matrix
  62368. * @param transform transformation matrix to be applied to the resulting frustum plane
  62369. * @param frustumPlane the resuling frustum plane
  62370. */
  62371. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62372. /**
  62373. * Gets the left frustum plane transformed by the transform matrix
  62374. * @param transform transformation matrix to be applied to the resulting frustum plane
  62375. * @param frustumPlane the resuling frustum plane
  62376. */
  62377. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62378. /**
  62379. * Gets the right frustum plane transformed by the transform matrix
  62380. * @param transform transformation matrix to be applied to the resulting frustum plane
  62381. * @param frustumPlane the resuling frustum plane
  62382. */
  62383. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62384. /**
  62385. * Gets the top frustum plane transformed by the transform matrix
  62386. * @param transform transformation matrix to be applied to the resulting frustum plane
  62387. * @param frustumPlane the resuling frustum plane
  62388. */
  62389. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62390. /**
  62391. * Gets the bottom frustum plane transformed by the transform matrix
  62392. * @param transform transformation matrix to be applied to the resulting frustum plane
  62393. * @param frustumPlane the resuling frustum plane
  62394. */
  62395. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62396. /**
  62397. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62398. * @param transform transformation matrix to be applied to the resulting frustum planes
  62399. * @param frustumPlanes the resuling frustum planes
  62400. */
  62401. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62402. }
  62403. /** Defines supported spaces */
  62404. export enum Space {
  62405. /** Local (object) space */
  62406. LOCAL = 0,
  62407. /** World space */
  62408. WORLD = 1,
  62409. /** Bone space */
  62410. BONE = 2
  62411. }
  62412. /** Defines the 3 main axes */
  62413. export class Axis {
  62414. /** X axis */
  62415. static X: Vector3;
  62416. /** Y axis */
  62417. static Y: Vector3;
  62418. /** Z axis */
  62419. static Z: Vector3;
  62420. }
  62421. /** Class used to represent a Bezier curve */
  62422. export class BezierCurve {
  62423. /**
  62424. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62425. * @param t defines the time
  62426. * @param x1 defines the left coordinate on X axis
  62427. * @param y1 defines the left coordinate on Y axis
  62428. * @param x2 defines the right coordinate on X axis
  62429. * @param y2 defines the right coordinate on Y axis
  62430. * @returns the interpolated value
  62431. */
  62432. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62433. }
  62434. /**
  62435. * Defines potential orientation for back face culling
  62436. */
  62437. export enum Orientation {
  62438. /**
  62439. * Clockwise
  62440. */
  62441. CW = 0,
  62442. /** Counter clockwise */
  62443. CCW = 1
  62444. }
  62445. /**
  62446. * Defines angle representation
  62447. */
  62448. export class Angle {
  62449. private _radians;
  62450. /**
  62451. * Creates an Angle object of "radians" radians (float).
  62452. * @param radians the angle in radians
  62453. */
  62454. constructor(radians: number);
  62455. /**
  62456. * Get value in degrees
  62457. * @returns the Angle value in degrees (float)
  62458. */
  62459. degrees(): number;
  62460. /**
  62461. * Get value in radians
  62462. * @returns the Angle value in radians (float)
  62463. */
  62464. radians(): number;
  62465. /**
  62466. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62467. * @param a defines first vector
  62468. * @param b defines second vector
  62469. * @returns a new Angle
  62470. */
  62471. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62472. /**
  62473. * Gets a new Angle object from the given float in radians
  62474. * @param radians defines the angle value in radians
  62475. * @returns a new Angle
  62476. */
  62477. static FromRadians(radians: number): Angle;
  62478. /**
  62479. * Gets a new Angle object from the given float in degrees
  62480. * @param degrees defines the angle value in degrees
  62481. * @returns a new Angle
  62482. */
  62483. static FromDegrees(degrees: number): Angle;
  62484. }
  62485. /**
  62486. * This represents an arc in a 2d space.
  62487. */
  62488. export class Arc2 {
  62489. /** Defines the start point of the arc */
  62490. startPoint: Vector2;
  62491. /** Defines the mid point of the arc */
  62492. midPoint: Vector2;
  62493. /** Defines the end point of the arc */
  62494. endPoint: Vector2;
  62495. /**
  62496. * Defines the center point of the arc.
  62497. */
  62498. centerPoint: Vector2;
  62499. /**
  62500. * Defines the radius of the arc.
  62501. */
  62502. radius: number;
  62503. /**
  62504. * Defines the angle of the arc (from mid point to end point).
  62505. */
  62506. angle: Angle;
  62507. /**
  62508. * Defines the start angle of the arc (from start point to middle point).
  62509. */
  62510. startAngle: Angle;
  62511. /**
  62512. * Defines the orientation of the arc (clock wise/counter clock wise).
  62513. */
  62514. orientation: Orientation;
  62515. /**
  62516. * Creates an Arc object from the three given points : start, middle and end.
  62517. * @param startPoint Defines the start point of the arc
  62518. * @param midPoint Defines the midlle point of the arc
  62519. * @param endPoint Defines the end point of the arc
  62520. */
  62521. constructor(
  62522. /** Defines the start point of the arc */
  62523. startPoint: Vector2,
  62524. /** Defines the mid point of the arc */
  62525. midPoint: Vector2,
  62526. /** Defines the end point of the arc */
  62527. endPoint: Vector2);
  62528. }
  62529. /**
  62530. * Represents a 2D path made up of multiple 2D points
  62531. */
  62532. export class Path2 {
  62533. private _points;
  62534. private _length;
  62535. /**
  62536. * If the path start and end point are the same
  62537. */
  62538. closed: boolean;
  62539. /**
  62540. * Creates a Path2 object from the starting 2D coordinates x and y.
  62541. * @param x the starting points x value
  62542. * @param y the starting points y value
  62543. */
  62544. constructor(x: number, y: number);
  62545. /**
  62546. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  62547. * @param x the added points x value
  62548. * @param y the added points y value
  62549. * @returns the updated Path2.
  62550. */
  62551. addLineTo(x: number, y: number): Path2;
  62552. /**
  62553. * 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.
  62554. * @param midX middle point x value
  62555. * @param midY middle point y value
  62556. * @param endX end point x value
  62557. * @param endY end point y value
  62558. * @param numberOfSegments (default: 36)
  62559. * @returns the updated Path2.
  62560. */
  62561. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  62562. /**
  62563. * Closes the Path2.
  62564. * @returns the Path2.
  62565. */
  62566. close(): Path2;
  62567. /**
  62568. * Gets the sum of the distance between each sequential point in the path
  62569. * @returns the Path2 total length (float).
  62570. */
  62571. length(): number;
  62572. /**
  62573. * Gets the points which construct the path
  62574. * @returns the Path2 internal array of points.
  62575. */
  62576. getPoints(): Vector2[];
  62577. /**
  62578. * Retreives the point at the distance aways from the starting point
  62579. * @param normalizedLengthPosition the length along the path to retreive the point from
  62580. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  62581. */
  62582. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  62583. /**
  62584. * Creates a new path starting from an x and y position
  62585. * @param x starting x value
  62586. * @param y starting y value
  62587. * @returns a new Path2 starting at the coordinates (x, y).
  62588. */
  62589. static StartingAt(x: number, y: number): Path2;
  62590. }
  62591. /**
  62592. * Represents a 3D path made up of multiple 3D points
  62593. */
  62594. export class Path3D {
  62595. /**
  62596. * an array of Vector3, the curve axis of the Path3D
  62597. */
  62598. path: Vector3[];
  62599. private _curve;
  62600. private _distances;
  62601. private _tangents;
  62602. private _normals;
  62603. private _binormals;
  62604. private _raw;
  62605. /**
  62606. * new Path3D(path, normal, raw)
  62607. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  62608. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  62609. * @param path an array of Vector3, the curve axis of the Path3D
  62610. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  62611. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  62612. */
  62613. constructor(
  62614. /**
  62615. * an array of Vector3, the curve axis of the Path3D
  62616. */
  62617. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  62618. /**
  62619. * Returns the Path3D array of successive Vector3 designing its curve.
  62620. * @returns the Path3D array of successive Vector3 designing its curve.
  62621. */
  62622. getCurve(): Vector3[];
  62623. /**
  62624. * Returns an array populated with tangent vectors on each Path3D curve point.
  62625. * @returns an array populated with tangent vectors on each Path3D curve point.
  62626. */
  62627. getTangents(): Vector3[];
  62628. /**
  62629. * Returns an array populated with normal vectors on each Path3D curve point.
  62630. * @returns an array populated with normal vectors on each Path3D curve point.
  62631. */
  62632. getNormals(): Vector3[];
  62633. /**
  62634. * Returns an array populated with binormal vectors on each Path3D curve point.
  62635. * @returns an array populated with binormal vectors on each Path3D curve point.
  62636. */
  62637. getBinormals(): Vector3[];
  62638. /**
  62639. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  62640. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  62641. */
  62642. getDistances(): number[];
  62643. /**
  62644. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  62645. * @param path path which all values are copied into the curves points
  62646. * @param firstNormal which should be projected onto the curve
  62647. * @returns the same object updated.
  62648. */
  62649. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  62650. private _compute;
  62651. private _getFirstNonNullVector;
  62652. private _getLastNonNullVector;
  62653. private _normalVector;
  62654. }
  62655. /**
  62656. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62657. * A Curve3 is designed from a series of successive Vector3.
  62658. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  62659. */
  62660. export class Curve3 {
  62661. private _points;
  62662. private _length;
  62663. /**
  62664. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  62665. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  62666. * @param v1 (Vector3) the control point
  62667. * @param v2 (Vector3) the end point of the Quadratic Bezier
  62668. * @param nbPoints (integer) the wanted number of points in the curve
  62669. * @returns the created Curve3
  62670. */
  62671. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62672. /**
  62673. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  62674. * @param v0 (Vector3) the origin point of the Cubic Bezier
  62675. * @param v1 (Vector3) the first control point
  62676. * @param v2 (Vector3) the second control point
  62677. * @param v3 (Vector3) the end point of the Cubic Bezier
  62678. * @param nbPoints (integer) the wanted number of points in the curve
  62679. * @returns the created Curve3
  62680. */
  62681. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62682. /**
  62683. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  62684. * @param p1 (Vector3) the origin point of the Hermite Spline
  62685. * @param t1 (Vector3) the tangent vector at the origin point
  62686. * @param p2 (Vector3) the end point of the Hermite Spline
  62687. * @param t2 (Vector3) the tangent vector at the end point
  62688. * @param nbPoints (integer) the wanted number of points in the curve
  62689. * @returns the created Curve3
  62690. */
  62691. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62692. /**
  62693. * Returns a Curve3 object along a CatmullRom Spline curve :
  62694. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  62695. * @param nbPoints (integer) the wanted number of points between each curve control points
  62696. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  62697. * @returns the created Curve3
  62698. */
  62699. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  62700. /**
  62701. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62702. * A Curve3 is designed from a series of successive Vector3.
  62703. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  62704. * @param points points which make up the curve
  62705. */
  62706. constructor(points: Vector3[]);
  62707. /**
  62708. * @returns the Curve3 stored array of successive Vector3
  62709. */
  62710. getPoints(): Vector3[];
  62711. /**
  62712. * @returns the computed length (float) of the curve.
  62713. */
  62714. length(): number;
  62715. /**
  62716. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  62717. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  62718. * curveA and curveB keep unchanged.
  62719. * @param curve the curve to continue from this curve
  62720. * @returns the newly constructed curve
  62721. */
  62722. continue(curve: DeepImmutable<Curve3>): Curve3;
  62723. private _computeLength;
  62724. }
  62725. /**
  62726. * Contains position and normal vectors for a vertex
  62727. */
  62728. export class PositionNormalVertex {
  62729. /** the position of the vertex (defaut: 0,0,0) */
  62730. position: Vector3;
  62731. /** the normal of the vertex (defaut: 0,1,0) */
  62732. normal: Vector3;
  62733. /**
  62734. * Creates a PositionNormalVertex
  62735. * @param position the position of the vertex (defaut: 0,0,0)
  62736. * @param normal the normal of the vertex (defaut: 0,1,0)
  62737. */
  62738. constructor(
  62739. /** the position of the vertex (defaut: 0,0,0) */
  62740. position?: Vector3,
  62741. /** the normal of the vertex (defaut: 0,1,0) */
  62742. normal?: Vector3);
  62743. /**
  62744. * Clones the PositionNormalVertex
  62745. * @returns the cloned PositionNormalVertex
  62746. */
  62747. clone(): PositionNormalVertex;
  62748. }
  62749. /**
  62750. * Contains position, normal and uv vectors for a vertex
  62751. */
  62752. export class PositionNormalTextureVertex {
  62753. /** the position of the vertex (defaut: 0,0,0) */
  62754. position: Vector3;
  62755. /** the normal of the vertex (defaut: 0,1,0) */
  62756. normal: Vector3;
  62757. /** the uv of the vertex (default: 0,0) */
  62758. uv: Vector2;
  62759. /**
  62760. * Creates a PositionNormalTextureVertex
  62761. * @param position the position of the vertex (defaut: 0,0,0)
  62762. * @param normal the normal of the vertex (defaut: 0,1,0)
  62763. * @param uv the uv of the vertex (default: 0,0)
  62764. */
  62765. constructor(
  62766. /** the position of the vertex (defaut: 0,0,0) */
  62767. position?: Vector3,
  62768. /** the normal of the vertex (defaut: 0,1,0) */
  62769. normal?: Vector3,
  62770. /** the uv of the vertex (default: 0,0) */
  62771. uv?: Vector2);
  62772. /**
  62773. * Clones the PositionNormalTextureVertex
  62774. * @returns the cloned PositionNormalTextureVertex
  62775. */
  62776. clone(): PositionNormalTextureVertex;
  62777. }
  62778. /**
  62779. * @hidden
  62780. */
  62781. export class Tmp {
  62782. static Color3: Color3[];
  62783. static Color4: Color4[];
  62784. static Vector2: Vector2[];
  62785. static Vector3: Vector3[];
  62786. static Vector4: Vector4[];
  62787. static Quaternion: Quaternion[];
  62788. static Matrix: Matrix[];
  62789. }
  62790. }
  62791. declare module BABYLON {
  62792. /**
  62793. * Class used to enable access to offline support
  62794. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62795. */
  62796. export interface IOfflineProvider {
  62797. /**
  62798. * Gets a boolean indicating if scene must be saved in the database
  62799. */
  62800. enableSceneOffline: boolean;
  62801. /**
  62802. * Gets a boolean indicating if textures must be saved in the database
  62803. */
  62804. enableTexturesOffline: boolean;
  62805. /**
  62806. * Open the offline support and make it available
  62807. * @param successCallback defines the callback to call on success
  62808. * @param errorCallback defines the callback to call on error
  62809. */
  62810. open(successCallback: () => void, errorCallback: () => void): void;
  62811. /**
  62812. * Loads an image from the offline support
  62813. * @param url defines the url to load from
  62814. * @param image defines the target DOM image
  62815. */
  62816. loadImage(url: string, image: HTMLImageElement): void;
  62817. /**
  62818. * Loads a file from offline support
  62819. * @param url defines the URL to load from
  62820. * @param sceneLoaded defines a callback to call on success
  62821. * @param progressCallBack defines a callback to call when progress changed
  62822. * @param errorCallback defines a callback to call on error
  62823. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62824. */
  62825. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62826. }
  62827. }
  62828. declare module BABYLON {
  62829. /**
  62830. * A class serves as a medium between the observable and its observers
  62831. */
  62832. export class EventState {
  62833. /**
  62834. * Create a new EventState
  62835. * @param mask defines the mask associated with this state
  62836. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62837. * @param target defines the original target of the state
  62838. * @param currentTarget defines the current target of the state
  62839. */
  62840. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62841. /**
  62842. * Initialize the current event state
  62843. * @param mask defines the mask associated with this state
  62844. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62845. * @param target defines the original target of the state
  62846. * @param currentTarget defines the current target of the state
  62847. * @returns the current event state
  62848. */
  62849. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62850. /**
  62851. * An Observer can set this property to true to prevent subsequent observers of being notified
  62852. */
  62853. skipNextObservers: boolean;
  62854. /**
  62855. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62856. */
  62857. mask: number;
  62858. /**
  62859. * The object that originally notified the event
  62860. */
  62861. target?: any;
  62862. /**
  62863. * The current object in the bubbling phase
  62864. */
  62865. currentTarget?: any;
  62866. /**
  62867. * This will be populated with the return value of the last function that was executed.
  62868. * If it is the first function in the callback chain it will be the event data.
  62869. */
  62870. lastReturnValue?: any;
  62871. }
  62872. /**
  62873. * Represent an Observer registered to a given Observable object.
  62874. */
  62875. export class Observer<T> {
  62876. /**
  62877. * Defines the callback to call when the observer is notified
  62878. */
  62879. callback: (eventData: T, eventState: EventState) => void;
  62880. /**
  62881. * Defines the mask of the observer (used to filter notifications)
  62882. */
  62883. mask: number;
  62884. /**
  62885. * Defines the current scope used to restore the JS context
  62886. */
  62887. scope: any;
  62888. /** @hidden */
  62889. _willBeUnregistered: boolean;
  62890. /**
  62891. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62892. */
  62893. unregisterOnNextCall: boolean;
  62894. /**
  62895. * Creates a new observer
  62896. * @param callback defines the callback to call when the observer is notified
  62897. * @param mask defines the mask of the observer (used to filter notifications)
  62898. * @param scope defines the current scope used to restore the JS context
  62899. */
  62900. constructor(
  62901. /**
  62902. * Defines the callback to call when the observer is notified
  62903. */
  62904. callback: (eventData: T, eventState: EventState) => void,
  62905. /**
  62906. * Defines the mask of the observer (used to filter notifications)
  62907. */
  62908. mask: number,
  62909. /**
  62910. * Defines the current scope used to restore the JS context
  62911. */
  62912. scope?: any);
  62913. }
  62914. /**
  62915. * Represent a list of observers registered to multiple Observables object.
  62916. */
  62917. export class MultiObserver<T> {
  62918. private _observers;
  62919. private _observables;
  62920. /**
  62921. * Release associated resources
  62922. */
  62923. dispose(): void;
  62924. /**
  62925. * Raise a callback when one of the observable will notify
  62926. * @param observables defines a list of observables to watch
  62927. * @param callback defines the callback to call on notification
  62928. * @param mask defines the mask used to filter notifications
  62929. * @param scope defines the current scope used to restore the JS context
  62930. * @returns the new MultiObserver
  62931. */
  62932. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62933. }
  62934. /**
  62935. * The Observable class is a simple implementation of the Observable pattern.
  62936. *
  62937. * 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.
  62938. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62939. * 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).
  62940. * 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.
  62941. */
  62942. export class Observable<T> {
  62943. private _observers;
  62944. private _eventState;
  62945. private _onObserverAdded;
  62946. /**
  62947. * Creates a new observable
  62948. * @param onObserverAdded defines a callback to call when a new observer is added
  62949. */
  62950. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62951. /**
  62952. * Create a new Observer with the specified callback
  62953. * @param callback the callback that will be executed for that Observer
  62954. * @param mask the mask used to filter observers
  62955. * @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.
  62956. * @param scope optional scope for the callback to be called from
  62957. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62958. * @returns the new observer created for the callback
  62959. */
  62960. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62961. /**
  62962. * Create a new Observer with the specified callback and unregisters after the next notification
  62963. * @param callback the callback that will be executed for that Observer
  62964. * @returns the new observer created for the callback
  62965. */
  62966. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62967. /**
  62968. * Remove an Observer from the Observable object
  62969. * @param observer the instance of the Observer to remove
  62970. * @returns false if it doesn't belong to this Observable
  62971. */
  62972. remove(observer: Nullable<Observer<T>>): boolean;
  62973. /**
  62974. * Remove a callback from the Observable object
  62975. * @param callback the callback to remove
  62976. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62977. * @returns false if it doesn't belong to this Observable
  62978. */
  62979. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62980. private _deferUnregister;
  62981. private _remove;
  62982. /**
  62983. * Moves the observable to the top of the observer list making it get called first when notified
  62984. * @param observer the observer to move
  62985. */
  62986. makeObserverTopPriority(observer: Observer<T>): void;
  62987. /**
  62988. * Moves the observable to the bottom of the observer list making it get called last when notified
  62989. * @param observer the observer to move
  62990. */
  62991. makeObserverBottomPriority(observer: Observer<T>): void;
  62992. /**
  62993. * Notify all Observers by calling their respective callback with the given data
  62994. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62995. * @param eventData defines the data to send to all observers
  62996. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62997. * @param target defines the original target of the state
  62998. * @param currentTarget defines the current target of the state
  62999. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63000. */
  63001. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63002. /**
  63003. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63004. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63005. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63006. * and it is crucial that all callbacks will be executed.
  63007. * The order of the callbacks is kept, callbacks are not executed parallel.
  63008. *
  63009. * @param eventData The data to be sent to each callback
  63010. * @param mask is used to filter observers defaults to -1
  63011. * @param target defines the callback target (see EventState)
  63012. * @param currentTarget defines he current object in the bubbling phase
  63013. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63014. */
  63015. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63016. /**
  63017. * Notify a specific observer
  63018. * @param observer defines the observer to notify
  63019. * @param eventData defines the data to be sent to each callback
  63020. * @param mask is used to filter observers defaults to -1
  63021. */
  63022. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63023. /**
  63024. * Gets a boolean indicating if the observable has at least one observer
  63025. * @returns true is the Observable has at least one Observer registered
  63026. */
  63027. hasObservers(): boolean;
  63028. /**
  63029. * Clear the list of observers
  63030. */
  63031. clear(): void;
  63032. /**
  63033. * Clone the current observable
  63034. * @returns a new observable
  63035. */
  63036. clone(): Observable<T>;
  63037. /**
  63038. * Does this observable handles observer registered with a given mask
  63039. * @param mask defines the mask to be tested
  63040. * @return whether or not one observer registered with the given mask is handeled
  63041. **/
  63042. hasSpecificMask(mask?: number): boolean;
  63043. }
  63044. }
  63045. declare module BABYLON {
  63046. /**
  63047. * Class used to help managing file picking and drag'n'drop
  63048. * File Storage
  63049. */
  63050. export class FilesInputStore {
  63051. /**
  63052. * List of files ready to be loaded
  63053. */
  63054. static FilesToLoad: {
  63055. [key: string]: File;
  63056. };
  63057. }
  63058. }
  63059. declare module BABYLON {
  63060. /** Defines the cross module used constants to avoid circular dependncies */
  63061. export class Constants {
  63062. /** Defines that alpha blending is disabled */
  63063. static readonly ALPHA_DISABLE: number;
  63064. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63065. static readonly ALPHA_ADD: number;
  63066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63067. static readonly ALPHA_COMBINE: number;
  63068. /** Defines that alpha blending to DEST - SRC * DEST */
  63069. static readonly ALPHA_SUBTRACT: number;
  63070. /** Defines that alpha blending to SRC * DEST */
  63071. static readonly ALPHA_MULTIPLY: number;
  63072. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63073. static readonly ALPHA_MAXIMIZED: number;
  63074. /** Defines that alpha blending to SRC + DEST */
  63075. static readonly ALPHA_ONEONE: number;
  63076. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63077. static readonly ALPHA_PREMULTIPLIED: number;
  63078. /**
  63079. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63080. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63081. */
  63082. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63083. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63084. static readonly ALPHA_INTERPOLATE: number;
  63085. /**
  63086. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63087. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63088. */
  63089. static readonly ALPHA_SCREENMODE: number;
  63090. /** Defines that the ressource is not delayed*/
  63091. static readonly DELAYLOADSTATE_NONE: number;
  63092. /** Defines that the ressource was successfully delay loaded */
  63093. static readonly DELAYLOADSTATE_LOADED: number;
  63094. /** Defines that the ressource is currently delay loading */
  63095. static readonly DELAYLOADSTATE_LOADING: number;
  63096. /** Defines that the ressource is delayed and has not started loading */
  63097. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63099. static readonly NEVER: number;
  63100. /** 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 */
  63101. static readonly ALWAYS: number;
  63102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63103. static readonly LESS: number;
  63104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63105. static readonly EQUAL: number;
  63106. /** 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 */
  63107. static readonly LEQUAL: number;
  63108. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63109. static readonly GREATER: number;
  63110. /** 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 */
  63111. static readonly GEQUAL: number;
  63112. /** 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 */
  63113. static readonly NOTEQUAL: number;
  63114. /** Passed to stencilOperation to specify that stencil value must be kept */
  63115. static readonly KEEP: number;
  63116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63117. static readonly REPLACE: number;
  63118. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63119. static readonly INCR: number;
  63120. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63121. static readonly DECR: number;
  63122. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63123. static readonly INVERT: number;
  63124. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63125. static readonly INCR_WRAP: number;
  63126. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63127. static readonly DECR_WRAP: number;
  63128. /** Texture is not repeating outside of 0..1 UVs */
  63129. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63130. /** Texture is repeating outside of 0..1 UVs */
  63131. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63132. /** Texture is repeating and mirrored */
  63133. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63134. /** ALPHA */
  63135. static readonly TEXTUREFORMAT_ALPHA: number;
  63136. /** LUMINANCE */
  63137. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63138. /** LUMINANCE_ALPHA */
  63139. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63140. /** RGB */
  63141. static readonly TEXTUREFORMAT_RGB: number;
  63142. /** RGBA */
  63143. static readonly TEXTUREFORMAT_RGBA: number;
  63144. /** RED */
  63145. static readonly TEXTUREFORMAT_RED: number;
  63146. /** RED (2nd reference) */
  63147. static readonly TEXTUREFORMAT_R: number;
  63148. /** RG */
  63149. static readonly TEXTUREFORMAT_RG: number;
  63150. /** RED_INTEGER */
  63151. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63152. /** RED_INTEGER (2nd reference) */
  63153. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63154. /** RG_INTEGER */
  63155. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63156. /** RGB_INTEGER */
  63157. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63158. /** RGBA_INTEGER */
  63159. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63160. /** UNSIGNED_BYTE */
  63161. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63162. /** UNSIGNED_BYTE (2nd reference) */
  63163. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63164. /** FLOAT */
  63165. static readonly TEXTURETYPE_FLOAT: number;
  63166. /** HALF_FLOAT */
  63167. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63168. /** BYTE */
  63169. static readonly TEXTURETYPE_BYTE: number;
  63170. /** SHORT */
  63171. static readonly TEXTURETYPE_SHORT: number;
  63172. /** UNSIGNED_SHORT */
  63173. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63174. /** INT */
  63175. static readonly TEXTURETYPE_INT: number;
  63176. /** UNSIGNED_INT */
  63177. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63178. /** UNSIGNED_SHORT_4_4_4_4 */
  63179. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63180. /** UNSIGNED_SHORT_5_5_5_1 */
  63181. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63182. /** UNSIGNED_SHORT_5_6_5 */
  63183. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63184. /** UNSIGNED_INT_2_10_10_10_REV */
  63185. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63186. /** UNSIGNED_INT_24_8 */
  63187. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63188. /** UNSIGNED_INT_10F_11F_11F_REV */
  63189. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63190. /** UNSIGNED_INT_5_9_9_9_REV */
  63191. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63192. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63193. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63194. /** nearest is mag = nearest and min = nearest and mip = linear */
  63195. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63197. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63198. /** Trilinear is mag = linear and min = linear and mip = linear */
  63199. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63200. /** nearest is mag = nearest and min = nearest and mip = linear */
  63201. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63202. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63203. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63204. /** Trilinear is mag = linear and min = linear and mip = linear */
  63205. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63206. /** mag = nearest and min = nearest and mip = nearest */
  63207. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63208. /** mag = nearest and min = linear and mip = nearest */
  63209. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63210. /** mag = nearest and min = linear and mip = linear */
  63211. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63212. /** mag = nearest and min = linear and mip = none */
  63213. static readonly TEXTURE_NEAREST_LINEAR: number;
  63214. /** mag = nearest and min = nearest and mip = none */
  63215. static readonly TEXTURE_NEAREST_NEAREST: number;
  63216. /** mag = linear and min = nearest and mip = nearest */
  63217. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63218. /** mag = linear and min = nearest and mip = linear */
  63219. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63220. /** mag = linear and min = linear and mip = none */
  63221. static readonly TEXTURE_LINEAR_LINEAR: number;
  63222. /** mag = linear and min = nearest and mip = none */
  63223. static readonly TEXTURE_LINEAR_NEAREST: number;
  63224. /** Explicit coordinates mode */
  63225. static readonly TEXTURE_EXPLICIT_MODE: number;
  63226. /** Spherical coordinates mode */
  63227. static readonly TEXTURE_SPHERICAL_MODE: number;
  63228. /** Planar coordinates mode */
  63229. static readonly TEXTURE_PLANAR_MODE: number;
  63230. /** Cubic coordinates mode */
  63231. static readonly TEXTURE_CUBIC_MODE: number;
  63232. /** Projection coordinates mode */
  63233. static readonly TEXTURE_PROJECTION_MODE: number;
  63234. /** Skybox coordinates mode */
  63235. static readonly TEXTURE_SKYBOX_MODE: number;
  63236. /** Inverse Cubic coordinates mode */
  63237. static readonly TEXTURE_INVCUBIC_MODE: number;
  63238. /** Equirectangular coordinates mode */
  63239. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63240. /** Equirectangular Fixed coordinates mode */
  63241. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63242. /** Equirectangular Fixed Mirrored coordinates mode */
  63243. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63244. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63245. static readonly SCALEMODE_FLOOR: number;
  63246. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63247. static readonly SCALEMODE_NEAREST: number;
  63248. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63249. static readonly SCALEMODE_CEILING: number;
  63250. /**
  63251. * The dirty texture flag value
  63252. */
  63253. static readonly MATERIAL_TextureDirtyFlag: number;
  63254. /**
  63255. * The dirty light flag value
  63256. */
  63257. static readonly MATERIAL_LightDirtyFlag: number;
  63258. /**
  63259. * The dirty fresnel flag value
  63260. */
  63261. static readonly MATERIAL_FresnelDirtyFlag: number;
  63262. /**
  63263. * The dirty attribute flag value
  63264. */
  63265. static readonly MATERIAL_AttributesDirtyFlag: number;
  63266. /**
  63267. * The dirty misc flag value
  63268. */
  63269. static readonly MATERIAL_MiscDirtyFlag: number;
  63270. /**
  63271. * The all dirty flag value
  63272. */
  63273. static readonly MATERIAL_AllDirtyFlag: number;
  63274. /**
  63275. * Returns the triangle fill mode
  63276. */
  63277. static readonly MATERIAL_TriangleFillMode: number;
  63278. /**
  63279. * Returns the wireframe mode
  63280. */
  63281. static readonly MATERIAL_WireFrameFillMode: number;
  63282. /**
  63283. * Returns the point fill mode
  63284. */
  63285. static readonly MATERIAL_PointFillMode: number;
  63286. /**
  63287. * Returns the point list draw mode
  63288. */
  63289. static readonly MATERIAL_PointListDrawMode: number;
  63290. /**
  63291. * Returns the line list draw mode
  63292. */
  63293. static readonly MATERIAL_LineListDrawMode: number;
  63294. /**
  63295. * Returns the line loop draw mode
  63296. */
  63297. static readonly MATERIAL_LineLoopDrawMode: number;
  63298. /**
  63299. * Returns the line strip draw mode
  63300. */
  63301. static readonly MATERIAL_LineStripDrawMode: number;
  63302. /**
  63303. * Returns the triangle strip draw mode
  63304. */
  63305. static readonly MATERIAL_TriangleStripDrawMode: number;
  63306. /**
  63307. * Returns the triangle fan draw mode
  63308. */
  63309. static readonly MATERIAL_TriangleFanDrawMode: number;
  63310. /**
  63311. * Stores the clock-wise side orientation
  63312. */
  63313. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63314. /**
  63315. * Stores the counter clock-wise side orientation
  63316. */
  63317. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63318. /**
  63319. * Nothing
  63320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63321. */
  63322. static readonly ACTION_NothingTrigger: number;
  63323. /**
  63324. * On pick
  63325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63326. */
  63327. static readonly ACTION_OnPickTrigger: number;
  63328. /**
  63329. * On left pick
  63330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63331. */
  63332. static readonly ACTION_OnLeftPickTrigger: number;
  63333. /**
  63334. * On right pick
  63335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63336. */
  63337. static readonly ACTION_OnRightPickTrigger: number;
  63338. /**
  63339. * On center pick
  63340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63341. */
  63342. static readonly ACTION_OnCenterPickTrigger: number;
  63343. /**
  63344. * On pick down
  63345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63346. */
  63347. static readonly ACTION_OnPickDownTrigger: number;
  63348. /**
  63349. * On double pick
  63350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63351. */
  63352. static readonly ACTION_OnDoublePickTrigger: number;
  63353. /**
  63354. * On pick up
  63355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63356. */
  63357. static readonly ACTION_OnPickUpTrigger: number;
  63358. /**
  63359. * On pick out.
  63360. * This trigger will only be raised if you also declared a OnPickDown
  63361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63362. */
  63363. static readonly ACTION_OnPickOutTrigger: number;
  63364. /**
  63365. * On long press
  63366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63367. */
  63368. static readonly ACTION_OnLongPressTrigger: number;
  63369. /**
  63370. * On pointer over
  63371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63372. */
  63373. static readonly ACTION_OnPointerOverTrigger: number;
  63374. /**
  63375. * On pointer out
  63376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63377. */
  63378. static readonly ACTION_OnPointerOutTrigger: number;
  63379. /**
  63380. * On every frame
  63381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63382. */
  63383. static readonly ACTION_OnEveryFrameTrigger: number;
  63384. /**
  63385. * On intersection enter
  63386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63387. */
  63388. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63389. /**
  63390. * On intersection exit
  63391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63392. */
  63393. static readonly ACTION_OnIntersectionExitTrigger: number;
  63394. /**
  63395. * On key down
  63396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63397. */
  63398. static readonly ACTION_OnKeyDownTrigger: number;
  63399. /**
  63400. * On key up
  63401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63402. */
  63403. static readonly ACTION_OnKeyUpTrigger: number;
  63404. /**
  63405. * Billboard mode will only apply to Y axis
  63406. */
  63407. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63408. /**
  63409. * Billboard mode will apply to all axes
  63410. */
  63411. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63412. /**
  63413. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63414. */
  63415. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63416. /**
  63417. * Gets or sets base Assets URL
  63418. */
  63419. static readonly PARTICLES_BaseAssetsUrl: string;
  63420. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63421. * Test order :
  63422. * Is the bounding sphere outside the frustum ?
  63423. * If not, are the bounding box vertices outside the frustum ?
  63424. * It not, then the cullable object is in the frustum.
  63425. */
  63426. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63427. /** Culling strategy : Bounding Sphere Only.
  63428. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63429. * It's also less accurate than the standard because some not visible objects can still be selected.
  63430. * Test : is the bounding sphere outside the frustum ?
  63431. * If not, then the cullable object is in the frustum.
  63432. */
  63433. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63434. /** Culling strategy : Optimistic Inclusion.
  63435. * This in an inclusion test first, then the standard exclusion test.
  63436. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63437. * 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.
  63438. * Anyway, it's as accurate as the standard strategy.
  63439. * Test :
  63440. * Is the cullable object bounding sphere center in the frustum ?
  63441. * If not, apply the default culling strategy.
  63442. */
  63443. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63444. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63445. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63446. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63447. * 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.
  63448. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63449. * Test :
  63450. * Is the cullable object bounding sphere center in the frustum ?
  63451. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63452. */
  63453. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63454. /**
  63455. * No logging while loading
  63456. */
  63457. static readonly SCENELOADER_NO_LOGGING: number;
  63458. /**
  63459. * Minimal logging while loading
  63460. */
  63461. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63462. /**
  63463. * Summary logging while loading
  63464. */
  63465. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63466. /**
  63467. * Detailled logging while loading
  63468. */
  63469. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63470. }
  63471. }
  63472. declare module BABYLON {
  63473. /**
  63474. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63475. * Babylon.js
  63476. */
  63477. export class DomManagement {
  63478. /**
  63479. * Checks if the window object exists
  63480. * @returns true if the window object exists
  63481. */
  63482. static IsWindowObjectExist(): boolean;
  63483. /**
  63484. * Extracts text content from a DOM element hierarchy
  63485. * @param element defines the root element
  63486. * @returns a string
  63487. */
  63488. static GetDOMTextContent(element: HTMLElement): string;
  63489. }
  63490. }
  63491. declare module BABYLON {
  63492. /**
  63493. * Logger used througouht the application to allow configuration of
  63494. * the log level required for the messages.
  63495. */
  63496. export class Logger {
  63497. /**
  63498. * No log
  63499. */
  63500. static readonly NoneLogLevel: number;
  63501. /**
  63502. * Only message logs
  63503. */
  63504. static readonly MessageLogLevel: number;
  63505. /**
  63506. * Only warning logs
  63507. */
  63508. static readonly WarningLogLevel: number;
  63509. /**
  63510. * Only error logs
  63511. */
  63512. static readonly ErrorLogLevel: number;
  63513. /**
  63514. * All logs
  63515. */
  63516. static readonly AllLogLevel: number;
  63517. private static _LogCache;
  63518. /**
  63519. * Gets a value indicating the number of loading errors
  63520. * @ignorenaming
  63521. */
  63522. static errorsCount: number;
  63523. /**
  63524. * Callback called when a new log is added
  63525. */
  63526. static OnNewCacheEntry: (entry: string) => void;
  63527. private static _AddLogEntry;
  63528. private static _FormatMessage;
  63529. private static _LogDisabled;
  63530. private static _LogEnabled;
  63531. private static _WarnDisabled;
  63532. private static _WarnEnabled;
  63533. private static _ErrorDisabled;
  63534. private static _ErrorEnabled;
  63535. /**
  63536. * Log a message to the console
  63537. */
  63538. static Log: (message: string) => void;
  63539. /**
  63540. * Write a warning message to the console
  63541. */
  63542. static Warn: (message: string) => void;
  63543. /**
  63544. * Write an error message to the console
  63545. */
  63546. static Error: (message: string) => void;
  63547. /**
  63548. * Gets current log cache (list of logs)
  63549. */
  63550. static readonly LogCache: string;
  63551. /**
  63552. * Clears the log cache
  63553. */
  63554. static ClearLogCache(): void;
  63555. /**
  63556. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63557. */
  63558. static LogLevels: number;
  63559. }
  63560. }
  63561. declare module BABYLON {
  63562. /** @hidden */
  63563. export class _TypeStore {
  63564. /** @hidden */
  63565. static RegisteredTypes: {
  63566. [key: string]: Object;
  63567. };
  63568. /** @hidden */
  63569. static GetClass(fqdn: string): any;
  63570. }
  63571. }
  63572. declare module BABYLON {
  63573. /**
  63574. * Class containing a set of static utilities functions for deep copy.
  63575. */
  63576. export class DeepCopier {
  63577. /**
  63578. * Tries to copy an object by duplicating every property
  63579. * @param source defines the source object
  63580. * @param destination defines the target object
  63581. * @param doNotCopyList defines a list of properties to avoid
  63582. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63583. */
  63584. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63585. }
  63586. }
  63587. declare module BABYLON {
  63588. /**
  63589. * Class containing a set of static utilities functions for precision date
  63590. */
  63591. export class PrecisionDate {
  63592. /**
  63593. * Gets either window.performance.now() if supported or Date.now() else
  63594. */
  63595. static readonly Now: number;
  63596. }
  63597. }
  63598. declare module BABYLON {
  63599. /** @hidden */
  63600. export class _DevTools {
  63601. static WarnImport(name: string): string;
  63602. }
  63603. }
  63604. declare module BABYLON {
  63605. /**
  63606. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63607. */
  63608. export class WebRequest {
  63609. private _xhr;
  63610. /**
  63611. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63612. * i.e. when loading files, where the server/service expects an Authorization header
  63613. */
  63614. static CustomRequestHeaders: {
  63615. [key: string]: string;
  63616. };
  63617. /**
  63618. * Add callback functions in this array to update all the requests before they get sent to the network
  63619. */
  63620. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  63621. private _injectCustomRequestHeaders;
  63622. /**
  63623. * Gets or sets a function to be called when loading progress changes
  63624. */
  63625. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63626. /**
  63627. * Returns client's state
  63628. */
  63629. readonly readyState: number;
  63630. /**
  63631. * Returns client's status
  63632. */
  63633. readonly status: number;
  63634. /**
  63635. * Returns client's status as a text
  63636. */
  63637. readonly statusText: string;
  63638. /**
  63639. * Returns client's response
  63640. */
  63641. readonly response: any;
  63642. /**
  63643. * Returns client's response url
  63644. */
  63645. readonly responseURL: string;
  63646. /**
  63647. * Returns client's response as text
  63648. */
  63649. readonly responseText: string;
  63650. /**
  63651. * Gets or sets the expected response type
  63652. */
  63653. responseType: XMLHttpRequestResponseType;
  63654. /** @hidden */
  63655. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63656. /** @hidden */
  63657. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63658. /**
  63659. * Cancels any network activity
  63660. */
  63661. abort(): void;
  63662. /**
  63663. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63664. * @param body defines an optional request body
  63665. */
  63666. send(body?: Document | BodyInit | null): void;
  63667. /**
  63668. * Sets the request method, request URL
  63669. * @param method defines the method to use (GET, POST, etc..)
  63670. * @param url defines the url to connect with
  63671. */
  63672. open(method: string, url: string): void;
  63673. }
  63674. }
  63675. declare module BABYLON {
  63676. /**
  63677. * Class used to evalaute queries containing `and` and `or` operators
  63678. */
  63679. export class AndOrNotEvaluator {
  63680. /**
  63681. * Evaluate a query
  63682. * @param query defines the query to evaluate
  63683. * @param evaluateCallback defines the callback used to filter result
  63684. * @returns true if the query matches
  63685. */
  63686. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  63687. private static _HandleParenthesisContent;
  63688. private static _SimplifyNegation;
  63689. }
  63690. }
  63691. declare module BABYLON {
  63692. /**
  63693. * Class used to store custom tags
  63694. */
  63695. export class Tags {
  63696. /**
  63697. * Adds support for tags on the given object
  63698. * @param obj defines the object to use
  63699. */
  63700. static EnableFor(obj: any): void;
  63701. /**
  63702. * Removes tags support
  63703. * @param obj defines the object to use
  63704. */
  63705. static DisableFor(obj: any): void;
  63706. /**
  63707. * Gets a boolean indicating if the given object has tags
  63708. * @param obj defines the object to use
  63709. * @returns a boolean
  63710. */
  63711. static HasTags(obj: any): boolean;
  63712. /**
  63713. * Gets the tags available on a given object
  63714. * @param obj defines the object to use
  63715. * @param asString defines if the tags must be returned as a string instead of an array of strings
  63716. * @returns the tags
  63717. */
  63718. static GetTags(obj: any, asString?: boolean): any;
  63719. /**
  63720. * Adds tags to an object
  63721. * @param obj defines the object to use
  63722. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  63723. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  63724. */
  63725. static AddTagsTo(obj: any, tagsString: string): void;
  63726. /**
  63727. * @hidden
  63728. */
  63729. static _AddTagTo(obj: any, tag: string): void;
  63730. /**
  63731. * Removes specific tags from a specific object
  63732. * @param obj defines the object to use
  63733. * @param tagsString defines the tags to remove
  63734. */
  63735. static RemoveTagsFrom(obj: any, tagsString: string): void;
  63736. /**
  63737. * @hidden
  63738. */
  63739. static _RemoveTagFrom(obj: any, tag: string): void;
  63740. /**
  63741. * Defines if tags hosted on an object match a given query
  63742. * @param obj defines the object to use
  63743. * @param tagsQuery defines the tag query
  63744. * @returns a boolean
  63745. */
  63746. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63747. }
  63748. }
  63749. declare module BABYLON {
  63750. /**
  63751. * Manages the defines for the Material
  63752. */
  63753. export class MaterialDefines {
  63754. private _keys;
  63755. private _isDirty;
  63756. /** @hidden */
  63757. _renderId: number;
  63758. /** @hidden */
  63759. _areLightsDirty: boolean;
  63760. /** @hidden */
  63761. _areAttributesDirty: boolean;
  63762. /** @hidden */
  63763. _areTexturesDirty: boolean;
  63764. /** @hidden */
  63765. _areFresnelDirty: boolean;
  63766. /** @hidden */
  63767. _areMiscDirty: boolean;
  63768. /** @hidden */
  63769. _areImageProcessingDirty: boolean;
  63770. /** @hidden */
  63771. _normals: boolean;
  63772. /** @hidden */
  63773. _uvs: boolean;
  63774. /** @hidden */
  63775. _needNormals: boolean;
  63776. /** @hidden */
  63777. _needUVs: boolean;
  63778. /**
  63779. * Specifies if the material needs to be re-calculated
  63780. */
  63781. readonly isDirty: boolean;
  63782. /**
  63783. * Marks the material to indicate that it has been re-calculated
  63784. */
  63785. markAsProcessed(): void;
  63786. /**
  63787. * Marks the material to indicate that it needs to be re-calculated
  63788. */
  63789. markAsUnprocessed(): void;
  63790. /**
  63791. * Marks the material to indicate all of its defines need to be re-calculated
  63792. */
  63793. markAllAsDirty(): void;
  63794. /**
  63795. * Marks the material to indicate that image processing needs to be re-calculated
  63796. */
  63797. markAsImageProcessingDirty(): void;
  63798. /**
  63799. * Marks the material to indicate the lights need to be re-calculated
  63800. */
  63801. markAsLightDirty(): void;
  63802. /**
  63803. * Marks the attribute state as changed
  63804. */
  63805. markAsAttributesDirty(): void;
  63806. /**
  63807. * Marks the texture state as changed
  63808. */
  63809. markAsTexturesDirty(): void;
  63810. /**
  63811. * Marks the fresnel state as changed
  63812. */
  63813. markAsFresnelDirty(): void;
  63814. /**
  63815. * Marks the misc state as changed
  63816. */
  63817. markAsMiscDirty(): void;
  63818. /**
  63819. * Rebuilds the material defines
  63820. */
  63821. rebuild(): void;
  63822. /**
  63823. * Specifies if two material defines are equal
  63824. * @param other - A material define instance to compare to
  63825. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63826. */
  63827. isEqual(other: MaterialDefines): boolean;
  63828. /**
  63829. * Clones this instance's defines to another instance
  63830. * @param other - material defines to clone values to
  63831. */
  63832. cloneTo(other: MaterialDefines): void;
  63833. /**
  63834. * Resets the material define values
  63835. */
  63836. reset(): void;
  63837. /**
  63838. * Converts the material define values to a string
  63839. * @returns - String of material define information
  63840. */
  63841. toString(): string;
  63842. }
  63843. }
  63844. declare module BABYLON {
  63845. /**
  63846. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63847. */
  63848. export class PerformanceMonitor {
  63849. private _enabled;
  63850. private _rollingFrameTime;
  63851. private _lastFrameTimeMs;
  63852. /**
  63853. * constructor
  63854. * @param frameSampleSize The number of samples required to saturate the sliding window
  63855. */
  63856. constructor(frameSampleSize?: number);
  63857. /**
  63858. * Samples current frame
  63859. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63860. */
  63861. sampleFrame(timeMs?: number): void;
  63862. /**
  63863. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63864. */
  63865. readonly averageFrameTime: number;
  63866. /**
  63867. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63868. */
  63869. readonly averageFrameTimeVariance: number;
  63870. /**
  63871. * Returns the frame time of the most recent frame
  63872. */
  63873. readonly instantaneousFrameTime: number;
  63874. /**
  63875. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63876. */
  63877. readonly averageFPS: number;
  63878. /**
  63879. * Returns the average framerate in frames per second using the most recent frame time
  63880. */
  63881. readonly instantaneousFPS: number;
  63882. /**
  63883. * Returns true if enough samples have been taken to completely fill the sliding window
  63884. */
  63885. readonly isSaturated: boolean;
  63886. /**
  63887. * Enables contributions to the sliding window sample set
  63888. */
  63889. enable(): void;
  63890. /**
  63891. * Disables contributions to the sliding window sample set
  63892. * Samples will not be interpolated over the disabled period
  63893. */
  63894. disable(): void;
  63895. /**
  63896. * Returns true if sampling is enabled
  63897. */
  63898. readonly isEnabled: boolean;
  63899. /**
  63900. * Resets performance monitor
  63901. */
  63902. reset(): void;
  63903. }
  63904. /**
  63905. * RollingAverage
  63906. *
  63907. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63908. */
  63909. export class RollingAverage {
  63910. /**
  63911. * Current average
  63912. */
  63913. average: number;
  63914. /**
  63915. * Current variance
  63916. */
  63917. variance: number;
  63918. protected _samples: Array<number>;
  63919. protected _sampleCount: number;
  63920. protected _pos: number;
  63921. protected _m2: number;
  63922. /**
  63923. * constructor
  63924. * @param length The number of samples required to saturate the sliding window
  63925. */
  63926. constructor(length: number);
  63927. /**
  63928. * Adds a sample to the sample set
  63929. * @param v The sample value
  63930. */
  63931. add(v: number): void;
  63932. /**
  63933. * Returns previously added values or null if outside of history or outside the sliding window domain
  63934. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63935. * @return Value previously recorded with add() or null if outside of range
  63936. */
  63937. history(i: number): number;
  63938. /**
  63939. * Returns true if enough samples have been taken to completely fill the sliding window
  63940. * @return true if sample-set saturated
  63941. */
  63942. isSaturated(): boolean;
  63943. /**
  63944. * Resets the rolling average (equivalent to 0 samples taken so far)
  63945. */
  63946. reset(): void;
  63947. /**
  63948. * Wraps a value around the sample range boundaries
  63949. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63950. * @return Wrapped position in sample range
  63951. */
  63952. protected _wrapPosition(i: number): number;
  63953. }
  63954. }
  63955. declare module BABYLON {
  63956. /**
  63957. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63958. * The underlying implementation relies on an associative array to ensure the best performances.
  63959. * The value can be anything including 'null' but except 'undefined'
  63960. */
  63961. export class StringDictionary<T> {
  63962. /**
  63963. * This will clear this dictionary and copy the content from the 'source' one.
  63964. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63965. * @param source the dictionary to take the content from and copy to this dictionary
  63966. */
  63967. copyFrom(source: StringDictionary<T>): void;
  63968. /**
  63969. * Get a value based from its key
  63970. * @param key the given key to get the matching value from
  63971. * @return the value if found, otherwise undefined is returned
  63972. */
  63973. get(key: string): T | undefined;
  63974. /**
  63975. * Get a value from its key or add it if it doesn't exist.
  63976. * This method will ensure you that a given key/data will be present in the dictionary.
  63977. * @param key the given key to get the matching value from
  63978. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63979. * The factory will only be invoked if there's no data for the given key.
  63980. * @return the value corresponding to the key.
  63981. */
  63982. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63983. /**
  63984. * Get a value from its key if present in the dictionary otherwise add it
  63985. * @param key the key to get the value from
  63986. * @param val if there's no such key/value pair in the dictionary add it with this value
  63987. * @return the value corresponding to the key
  63988. */
  63989. getOrAdd(key: string, val: T): T;
  63990. /**
  63991. * Check if there's a given key in the dictionary
  63992. * @param key the key to check for
  63993. * @return true if the key is present, false otherwise
  63994. */
  63995. contains(key: string): boolean;
  63996. /**
  63997. * Add a new key and its corresponding value
  63998. * @param key the key to add
  63999. * @param value the value corresponding to the key
  64000. * @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
  64001. */
  64002. add(key: string, value: T): boolean;
  64003. /**
  64004. * Update a specific value associated to a key
  64005. * @param key defines the key to use
  64006. * @param value defines the value to store
  64007. * @returns true if the value was updated (or false if the key was not found)
  64008. */
  64009. set(key: string, value: T): boolean;
  64010. /**
  64011. * Get the element of the given key and remove it from the dictionary
  64012. * @param key defines the key to search
  64013. * @returns the value associated with the key or null if not found
  64014. */
  64015. getAndRemove(key: string): Nullable<T>;
  64016. /**
  64017. * Remove a key/value from the dictionary.
  64018. * @param key the key to remove
  64019. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64020. */
  64021. remove(key: string): boolean;
  64022. /**
  64023. * Clear the whole content of the dictionary
  64024. */
  64025. clear(): void;
  64026. /**
  64027. * Gets the current count
  64028. */
  64029. readonly count: number;
  64030. /**
  64031. * Execute a callback on each key/val of the dictionary.
  64032. * Note that you can remove any element in this dictionary in the callback implementation
  64033. * @param callback the callback to execute on a given key/value pair
  64034. */
  64035. forEach(callback: (key: string, val: T) => void): void;
  64036. /**
  64037. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64038. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64039. * Note that you can remove any element in this dictionary in the callback implementation
  64040. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64041. * @returns the first item
  64042. */
  64043. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64044. private _count;
  64045. private _data;
  64046. }
  64047. }
  64048. declare module BABYLON {
  64049. /**
  64050. * Helper class that provides a small promise polyfill
  64051. */
  64052. export class PromisePolyfill {
  64053. /**
  64054. * Static function used to check if the polyfill is required
  64055. * If this is the case then the function will inject the polyfill to window.Promise
  64056. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64057. */
  64058. static Apply(force?: boolean): void;
  64059. }
  64060. }
  64061. declare module BABYLON {
  64062. /**
  64063. * Class used to store data that will be store in GPU memory
  64064. */
  64065. export class Buffer {
  64066. private _engine;
  64067. private _buffer;
  64068. /** @hidden */
  64069. _data: Nullable<DataArray>;
  64070. private _updatable;
  64071. private _instanced;
  64072. /**
  64073. * Gets the byte stride.
  64074. */
  64075. readonly byteStride: number;
  64076. /**
  64077. * Constructor
  64078. * @param engine the engine
  64079. * @param data the data to use for this buffer
  64080. * @param updatable whether the data is updatable
  64081. * @param stride the stride (optional)
  64082. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64083. * @param instanced whether the buffer is instanced (optional)
  64084. * @param useBytes set to true if the stride in in bytes (optional)
  64085. */
  64086. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64087. /**
  64088. * Create a new VertexBuffer based on the current buffer
  64089. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64090. * @param offset defines offset in the buffer (0 by default)
  64091. * @param size defines the size in floats of attributes (position is 3 for instance)
  64092. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64093. * @param instanced defines if the vertex buffer contains indexed data
  64094. * @param useBytes defines if the offset and stride are in bytes
  64095. * @returns the new vertex buffer
  64096. */
  64097. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64098. /**
  64099. * Gets a boolean indicating if the Buffer is updatable?
  64100. * @returns true if the buffer is updatable
  64101. */
  64102. isUpdatable(): boolean;
  64103. /**
  64104. * Gets current buffer's data
  64105. * @returns a DataArray or null
  64106. */
  64107. getData(): Nullable<DataArray>;
  64108. /**
  64109. * Gets underlying native buffer
  64110. * @returns underlying native buffer
  64111. */
  64112. getBuffer(): Nullable<WebGLBuffer>;
  64113. /**
  64114. * Gets the stride in float32 units (i.e. byte stride / 4).
  64115. * May not be an integer if the byte stride is not divisible by 4.
  64116. * DEPRECATED. Use byteStride instead.
  64117. * @returns the stride in float32 units
  64118. */
  64119. getStrideSize(): number;
  64120. /**
  64121. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64122. * @param data defines the data to store
  64123. */
  64124. create(data?: Nullable<DataArray>): void;
  64125. /** @hidden */
  64126. _rebuild(): void;
  64127. /**
  64128. * Update current buffer data
  64129. * @param data defines the data to store
  64130. */
  64131. update(data: DataArray): void;
  64132. /**
  64133. * Updates the data directly.
  64134. * @param data the new data
  64135. * @param offset the new offset
  64136. * @param vertexCount the vertex count (optional)
  64137. * @param useBytes set to true if the offset is in bytes
  64138. */
  64139. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64140. /**
  64141. * Release all resources
  64142. */
  64143. dispose(): void;
  64144. }
  64145. /**
  64146. * Specialized buffer used to store vertex data
  64147. */
  64148. export class VertexBuffer {
  64149. /** @hidden */
  64150. _buffer: Buffer;
  64151. private _kind;
  64152. private _size;
  64153. private _ownsBuffer;
  64154. private _instanced;
  64155. private _instanceDivisor;
  64156. /**
  64157. * The byte type.
  64158. */
  64159. static readonly BYTE: number;
  64160. /**
  64161. * The unsigned byte type.
  64162. */
  64163. static readonly UNSIGNED_BYTE: number;
  64164. /**
  64165. * The short type.
  64166. */
  64167. static readonly SHORT: number;
  64168. /**
  64169. * The unsigned short type.
  64170. */
  64171. static readonly UNSIGNED_SHORT: number;
  64172. /**
  64173. * The integer type.
  64174. */
  64175. static readonly INT: number;
  64176. /**
  64177. * The unsigned integer type.
  64178. */
  64179. static readonly UNSIGNED_INT: number;
  64180. /**
  64181. * The float type.
  64182. */
  64183. static readonly FLOAT: number;
  64184. /**
  64185. * Gets or sets the instance divisor when in instanced mode
  64186. */
  64187. instanceDivisor: number;
  64188. /**
  64189. * Gets the byte stride.
  64190. */
  64191. readonly byteStride: number;
  64192. /**
  64193. * Gets the byte offset.
  64194. */
  64195. readonly byteOffset: number;
  64196. /**
  64197. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64198. */
  64199. readonly normalized: boolean;
  64200. /**
  64201. * Gets the data type of each component in the array.
  64202. */
  64203. readonly type: number;
  64204. /**
  64205. * Constructor
  64206. * @param engine the engine
  64207. * @param data the data to use for this vertex buffer
  64208. * @param kind the vertex buffer kind
  64209. * @param updatable whether the data is updatable
  64210. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64211. * @param stride the stride (optional)
  64212. * @param instanced whether the buffer is instanced (optional)
  64213. * @param offset the offset of the data (optional)
  64214. * @param size the number of components (optional)
  64215. * @param type the type of the component (optional)
  64216. * @param normalized whether the data contains normalized data (optional)
  64217. * @param useBytes set to true if stride and offset are in bytes (optional)
  64218. */
  64219. 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);
  64220. /** @hidden */
  64221. _rebuild(): void;
  64222. /**
  64223. * Returns the kind of the VertexBuffer (string)
  64224. * @returns a string
  64225. */
  64226. getKind(): string;
  64227. /**
  64228. * Gets a boolean indicating if the VertexBuffer is updatable?
  64229. * @returns true if the buffer is updatable
  64230. */
  64231. isUpdatable(): boolean;
  64232. /**
  64233. * Gets current buffer's data
  64234. * @returns a DataArray or null
  64235. */
  64236. getData(): Nullable<DataArray>;
  64237. /**
  64238. * Gets underlying native buffer
  64239. * @returns underlying native buffer
  64240. */
  64241. getBuffer(): Nullable<WebGLBuffer>;
  64242. /**
  64243. * Gets the stride in float32 units (i.e. byte stride / 4).
  64244. * May not be an integer if the byte stride is not divisible by 4.
  64245. * DEPRECATED. Use byteStride instead.
  64246. * @returns the stride in float32 units
  64247. */
  64248. getStrideSize(): number;
  64249. /**
  64250. * Returns the offset as a multiple of the type byte length.
  64251. * DEPRECATED. Use byteOffset instead.
  64252. * @returns the offset in bytes
  64253. */
  64254. getOffset(): number;
  64255. /**
  64256. * Returns the number of components per vertex attribute (integer)
  64257. * @returns the size in float
  64258. */
  64259. getSize(): number;
  64260. /**
  64261. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64262. * @returns true if this buffer is instanced
  64263. */
  64264. getIsInstanced(): boolean;
  64265. /**
  64266. * Returns the instancing divisor, zero for non-instanced (integer).
  64267. * @returns a number
  64268. */
  64269. getInstanceDivisor(): number;
  64270. /**
  64271. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64272. * @param data defines the data to store
  64273. */
  64274. create(data?: DataArray): void;
  64275. /**
  64276. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64277. * This function will create a new buffer if the current one is not updatable
  64278. * @param data defines the data to store
  64279. */
  64280. update(data: DataArray): void;
  64281. /**
  64282. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64283. * Returns the directly updated WebGLBuffer.
  64284. * @param data the new data
  64285. * @param offset the new offset
  64286. * @param useBytes set to true if the offset is in bytes
  64287. */
  64288. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64289. /**
  64290. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64291. */
  64292. dispose(): void;
  64293. /**
  64294. * Enumerates each value of this vertex buffer as numbers.
  64295. * @param count the number of values to enumerate
  64296. * @param callback the callback function called for each value
  64297. */
  64298. forEach(count: number, callback: (value: number, index: number) => void): void;
  64299. /**
  64300. * Positions
  64301. */
  64302. static readonly PositionKind: string;
  64303. /**
  64304. * Normals
  64305. */
  64306. static readonly NormalKind: string;
  64307. /**
  64308. * Tangents
  64309. */
  64310. static readonly TangentKind: string;
  64311. /**
  64312. * Texture coordinates
  64313. */
  64314. static readonly UVKind: string;
  64315. /**
  64316. * Texture coordinates 2
  64317. */
  64318. static readonly UV2Kind: string;
  64319. /**
  64320. * Texture coordinates 3
  64321. */
  64322. static readonly UV3Kind: string;
  64323. /**
  64324. * Texture coordinates 4
  64325. */
  64326. static readonly UV4Kind: string;
  64327. /**
  64328. * Texture coordinates 5
  64329. */
  64330. static readonly UV5Kind: string;
  64331. /**
  64332. * Texture coordinates 6
  64333. */
  64334. static readonly UV6Kind: string;
  64335. /**
  64336. * Colors
  64337. */
  64338. static readonly ColorKind: string;
  64339. /**
  64340. * Matrix indices (for bones)
  64341. */
  64342. static readonly MatricesIndicesKind: string;
  64343. /**
  64344. * Matrix weights (for bones)
  64345. */
  64346. static readonly MatricesWeightsKind: string;
  64347. /**
  64348. * Additional matrix indices (for bones)
  64349. */
  64350. static readonly MatricesIndicesExtraKind: string;
  64351. /**
  64352. * Additional matrix weights (for bones)
  64353. */
  64354. static readonly MatricesWeightsExtraKind: string;
  64355. /**
  64356. * Deduces the stride given a kind.
  64357. * @param kind The kind string to deduce
  64358. * @returns The deduced stride
  64359. */
  64360. static DeduceStride(kind: string): number;
  64361. /**
  64362. * Gets the byte length of the given type.
  64363. * @param type the type
  64364. * @returns the number of bytes
  64365. */
  64366. static GetTypeByteLength(type: number): number;
  64367. /**
  64368. * Enumerates each value of the given parameters as numbers.
  64369. * @param data the data to enumerate
  64370. * @param byteOffset the byte offset of the data
  64371. * @param byteStride the byte stride of the data
  64372. * @param componentCount the number of components per element
  64373. * @param componentType the type of the component
  64374. * @param count the total number of components
  64375. * @param normalized whether the data is normalized
  64376. * @param callback the callback function called for each value
  64377. */
  64378. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64379. private static _GetFloatValue;
  64380. }
  64381. }
  64382. declare module BABYLON {
  64383. /**
  64384. * Class representing spherical polynomial coefficients to the 3rd degree
  64385. */
  64386. export class SphericalPolynomial {
  64387. /**
  64388. * The x coefficients of the spherical polynomial
  64389. */
  64390. x: Vector3;
  64391. /**
  64392. * The y coefficients of the spherical polynomial
  64393. */
  64394. y: Vector3;
  64395. /**
  64396. * The z coefficients of the spherical polynomial
  64397. */
  64398. z: Vector3;
  64399. /**
  64400. * The xx coefficients of the spherical polynomial
  64401. */
  64402. xx: Vector3;
  64403. /**
  64404. * The yy coefficients of the spherical polynomial
  64405. */
  64406. yy: Vector3;
  64407. /**
  64408. * The zz coefficients of the spherical polynomial
  64409. */
  64410. zz: Vector3;
  64411. /**
  64412. * The xy coefficients of the spherical polynomial
  64413. */
  64414. xy: Vector3;
  64415. /**
  64416. * The yz coefficients of the spherical polynomial
  64417. */
  64418. yz: Vector3;
  64419. /**
  64420. * The zx coefficients of the spherical polynomial
  64421. */
  64422. zx: Vector3;
  64423. /**
  64424. * Adds an ambient color to the spherical polynomial
  64425. * @param color the color to add
  64426. */
  64427. addAmbient(color: Color3): void;
  64428. /**
  64429. * Scales the spherical polynomial by the given amount
  64430. * @param scale the amount to scale
  64431. */
  64432. scale(scale: number): void;
  64433. /**
  64434. * Gets the spherical polynomial from harmonics
  64435. * @param harmonics the spherical harmonics
  64436. * @returns the spherical polynomial
  64437. */
  64438. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64439. /**
  64440. * Constructs a spherical polynomial from an array.
  64441. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64442. * @returns the spherical polynomial
  64443. */
  64444. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64445. }
  64446. /**
  64447. * Class representing spherical harmonics coefficients to the 3rd degree
  64448. */
  64449. export class SphericalHarmonics {
  64450. /**
  64451. * The l0,0 coefficients of the spherical harmonics
  64452. */
  64453. l00: Vector3;
  64454. /**
  64455. * The l1,-1 coefficients of the spherical harmonics
  64456. */
  64457. l1_1: Vector3;
  64458. /**
  64459. * The l1,0 coefficients of the spherical harmonics
  64460. */
  64461. l10: Vector3;
  64462. /**
  64463. * The l1,1 coefficients of the spherical harmonics
  64464. */
  64465. l11: Vector3;
  64466. /**
  64467. * The l2,-2 coefficients of the spherical harmonics
  64468. */
  64469. l2_2: Vector3;
  64470. /**
  64471. * The l2,-1 coefficients of the spherical harmonics
  64472. */
  64473. l2_1: Vector3;
  64474. /**
  64475. * The l2,0 coefficients of the spherical harmonics
  64476. */
  64477. l20: Vector3;
  64478. /**
  64479. * The l2,1 coefficients of the spherical harmonics
  64480. */
  64481. l21: Vector3;
  64482. /**
  64483. * The l2,2 coefficients of the spherical harmonics
  64484. */
  64485. lL22: Vector3;
  64486. /**
  64487. * Adds a light to the spherical harmonics
  64488. * @param direction the direction of the light
  64489. * @param color the color of the light
  64490. * @param deltaSolidAngle the delta solid angle of the light
  64491. */
  64492. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64493. /**
  64494. * Scales the spherical harmonics by the given amount
  64495. * @param scale the amount to scale
  64496. */
  64497. scale(scale: number): void;
  64498. /**
  64499. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64500. *
  64501. * ```
  64502. * E_lm = A_l * L_lm
  64503. * ```
  64504. *
  64505. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64506. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64507. * the scaling factors are given in equation 9.
  64508. */
  64509. convertIncidentRadianceToIrradiance(): void;
  64510. /**
  64511. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64512. *
  64513. * ```
  64514. * L = (1/pi) * E * rho
  64515. * ```
  64516. *
  64517. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64518. */
  64519. convertIrradianceToLambertianRadiance(): void;
  64520. /**
  64521. * Gets the spherical harmonics from polynomial
  64522. * @param polynomial the spherical polynomial
  64523. * @returns the spherical harmonics
  64524. */
  64525. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64526. /**
  64527. * Constructs a spherical harmonics from an array.
  64528. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64529. * @returns the spherical harmonics
  64530. */
  64531. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64532. }
  64533. }
  64534. declare module BABYLON {
  64535. /**
  64536. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64537. */
  64538. export interface CubeMapInfo {
  64539. /**
  64540. * The pixel array for the front face.
  64541. * This is stored in format, left to right, up to down format.
  64542. */
  64543. front: Nullable<ArrayBufferView>;
  64544. /**
  64545. * The pixel array for the back face.
  64546. * This is stored in format, left to right, up to down format.
  64547. */
  64548. back: Nullable<ArrayBufferView>;
  64549. /**
  64550. * The pixel array for the left face.
  64551. * This is stored in format, left to right, up to down format.
  64552. */
  64553. left: Nullable<ArrayBufferView>;
  64554. /**
  64555. * The pixel array for the right face.
  64556. * This is stored in format, left to right, up to down format.
  64557. */
  64558. right: Nullable<ArrayBufferView>;
  64559. /**
  64560. * The pixel array for the up face.
  64561. * This is stored in format, left to right, up to down format.
  64562. */
  64563. up: Nullable<ArrayBufferView>;
  64564. /**
  64565. * The pixel array for the down face.
  64566. * This is stored in format, left to right, up to down format.
  64567. */
  64568. down: Nullable<ArrayBufferView>;
  64569. /**
  64570. * The size of the cubemap stored.
  64571. *
  64572. * Each faces will be size * size pixels.
  64573. */
  64574. size: number;
  64575. /**
  64576. * The format of the texture.
  64577. *
  64578. * RGBA, RGB.
  64579. */
  64580. format: number;
  64581. /**
  64582. * The type of the texture data.
  64583. *
  64584. * UNSIGNED_INT, FLOAT.
  64585. */
  64586. type: number;
  64587. /**
  64588. * Specifies whether the texture is in gamma space.
  64589. */
  64590. gammaSpace: boolean;
  64591. }
  64592. /**
  64593. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  64594. */
  64595. export class PanoramaToCubeMapTools {
  64596. private static FACE_FRONT;
  64597. private static FACE_BACK;
  64598. private static FACE_RIGHT;
  64599. private static FACE_LEFT;
  64600. private static FACE_DOWN;
  64601. private static FACE_UP;
  64602. /**
  64603. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  64604. *
  64605. * @param float32Array The source data.
  64606. * @param inputWidth The width of the input panorama.
  64607. * @param inputHeight The height of the input panorama.
  64608. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  64609. * @return The cubemap data
  64610. */
  64611. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  64612. private static CreateCubemapTexture;
  64613. private static CalcProjectionSpherical;
  64614. }
  64615. }
  64616. declare module BABYLON {
  64617. /**
  64618. * Helper class dealing with the extraction of spherical polynomial dataArray
  64619. * from a cube map.
  64620. */
  64621. export class CubeMapToSphericalPolynomialTools {
  64622. private static FileFaces;
  64623. /**
  64624. * Converts a texture to the according Spherical Polynomial data.
  64625. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64626. *
  64627. * @param texture The texture to extract the information from.
  64628. * @return The Spherical Polynomial data.
  64629. */
  64630. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  64631. /**
  64632. * Converts a cubemap to the according Spherical Polynomial data.
  64633. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64634. *
  64635. * @param cubeInfo The Cube map to extract the information from.
  64636. * @return The Spherical Polynomial data.
  64637. */
  64638. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  64639. }
  64640. }
  64641. declare module BABYLON {
  64642. /**
  64643. * The engine store class is responsible to hold all the instances of Engine and Scene created
  64644. * during the life time of the application.
  64645. */
  64646. export class EngineStore {
  64647. /** Gets the list of created engines */
  64648. static Instances: Engine[];
  64649. /**
  64650. * Gets the latest created engine
  64651. */
  64652. static readonly LastCreatedEngine: Nullable<Engine>;
  64653. /**
  64654. * Gets the latest created scene
  64655. */
  64656. static readonly LastCreatedScene: Nullable<Scene>;
  64657. }
  64658. }
  64659. declare module BABYLON {
  64660. /**
  64661. * Define options used to create a render target texture
  64662. */
  64663. export class RenderTargetCreationOptions {
  64664. /**
  64665. * Specifies is mipmaps must be generated
  64666. */
  64667. generateMipMaps?: boolean;
  64668. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  64669. generateDepthBuffer?: boolean;
  64670. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  64671. generateStencilBuffer?: boolean;
  64672. /** Defines texture type (int by default) */
  64673. type?: number;
  64674. /** Defines sampling mode (trilinear by default) */
  64675. samplingMode?: number;
  64676. /** Defines format (RGBA by default) */
  64677. format?: number;
  64678. }
  64679. }
  64680. declare module BABYLON {
  64681. /**
  64682. * @hidden
  64683. **/
  64684. export class _AlphaState {
  64685. private _isAlphaBlendDirty;
  64686. private _isBlendFunctionParametersDirty;
  64687. private _isBlendEquationParametersDirty;
  64688. private _isBlendConstantsDirty;
  64689. private _alphaBlend;
  64690. private _blendFunctionParameters;
  64691. private _blendEquationParameters;
  64692. private _blendConstants;
  64693. /**
  64694. * Initializes the state.
  64695. */
  64696. constructor();
  64697. readonly isDirty: boolean;
  64698. alphaBlend: boolean;
  64699. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  64700. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  64701. setAlphaEquationParameters(rgb: number, alpha: number): void;
  64702. reset(): void;
  64703. apply(gl: WebGLRenderingContext): void;
  64704. }
  64705. }
  64706. declare module BABYLON {
  64707. /**
  64708. * @hidden
  64709. **/
  64710. export class _DepthCullingState {
  64711. private _isDepthTestDirty;
  64712. private _isDepthMaskDirty;
  64713. private _isDepthFuncDirty;
  64714. private _isCullFaceDirty;
  64715. private _isCullDirty;
  64716. private _isZOffsetDirty;
  64717. private _isFrontFaceDirty;
  64718. private _depthTest;
  64719. private _depthMask;
  64720. private _depthFunc;
  64721. private _cull;
  64722. private _cullFace;
  64723. private _zOffset;
  64724. private _frontFace;
  64725. /**
  64726. * Initializes the state.
  64727. */
  64728. constructor();
  64729. readonly isDirty: boolean;
  64730. zOffset: number;
  64731. cullFace: Nullable<number>;
  64732. cull: Nullable<boolean>;
  64733. depthFunc: Nullable<number>;
  64734. depthMask: boolean;
  64735. depthTest: boolean;
  64736. frontFace: Nullable<number>;
  64737. reset(): void;
  64738. apply(gl: WebGLRenderingContext): void;
  64739. }
  64740. }
  64741. declare module BABYLON {
  64742. /**
  64743. * @hidden
  64744. **/
  64745. export class _StencilState {
  64746. /** 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 */
  64747. static readonly ALWAYS: number;
  64748. /** Passed to stencilOperation to specify that stencil value must be kept */
  64749. static readonly KEEP: number;
  64750. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64751. static readonly REPLACE: number;
  64752. private _isStencilTestDirty;
  64753. private _isStencilMaskDirty;
  64754. private _isStencilFuncDirty;
  64755. private _isStencilOpDirty;
  64756. private _stencilTest;
  64757. private _stencilMask;
  64758. private _stencilFunc;
  64759. private _stencilFuncRef;
  64760. private _stencilFuncMask;
  64761. private _stencilOpStencilFail;
  64762. private _stencilOpDepthFail;
  64763. private _stencilOpStencilDepthPass;
  64764. readonly isDirty: boolean;
  64765. stencilFunc: number;
  64766. stencilFuncRef: number;
  64767. stencilFuncMask: number;
  64768. stencilOpStencilFail: number;
  64769. stencilOpDepthFail: number;
  64770. stencilOpStencilDepthPass: number;
  64771. stencilMask: number;
  64772. stencilTest: boolean;
  64773. constructor();
  64774. reset(): void;
  64775. apply(gl: WebGLRenderingContext): void;
  64776. }
  64777. }
  64778. declare module BABYLON {
  64779. /**
  64780. * @hidden
  64781. **/
  64782. export class _TimeToken {
  64783. _startTimeQuery: Nullable<WebGLQuery>;
  64784. _endTimeQuery: Nullable<WebGLQuery>;
  64785. _timeElapsedQuery: Nullable<WebGLQuery>;
  64786. _timeElapsedQueryEnded: boolean;
  64787. }
  64788. }
  64789. declare module BABYLON {
  64790. /**
  64791. * Internal interface used to track InternalTexture already bound to the GL context
  64792. */
  64793. export interface IInternalTextureTracker {
  64794. /**
  64795. * Gets or set the previous tracker in the list
  64796. */
  64797. previous: Nullable<IInternalTextureTracker>;
  64798. /**
  64799. * Gets or set the next tracker in the list
  64800. */
  64801. next: Nullable<IInternalTextureTracker>;
  64802. }
  64803. /**
  64804. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64805. */
  64806. export class DummyInternalTextureTracker {
  64807. /**
  64808. * Gets or set the previous tracker in the list
  64809. */
  64810. previous: Nullable<IInternalTextureTracker>;
  64811. /**
  64812. * Gets or set the next tracker in the list
  64813. */
  64814. next: Nullable<IInternalTextureTracker>;
  64815. }
  64816. }
  64817. declare module BABYLON {
  64818. /**
  64819. * Class used to store data associated with WebGL texture data for the engine
  64820. * This class should not be used directly
  64821. */
  64822. export class InternalTexture implements IInternalTextureTracker {
  64823. /** hidden */
  64824. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64825. /**
  64826. * The source of the texture data is unknown
  64827. */
  64828. static DATASOURCE_UNKNOWN: number;
  64829. /**
  64830. * Texture data comes from an URL
  64831. */
  64832. static DATASOURCE_URL: number;
  64833. /**
  64834. * Texture data is only used for temporary storage
  64835. */
  64836. static DATASOURCE_TEMP: number;
  64837. /**
  64838. * Texture data comes from raw data (ArrayBuffer)
  64839. */
  64840. static DATASOURCE_RAW: number;
  64841. /**
  64842. * Texture content is dynamic (video or dynamic texture)
  64843. */
  64844. static DATASOURCE_DYNAMIC: number;
  64845. /**
  64846. * Texture content is generated by rendering to it
  64847. */
  64848. static DATASOURCE_RENDERTARGET: number;
  64849. /**
  64850. * Texture content is part of a multi render target process
  64851. */
  64852. static DATASOURCE_MULTIRENDERTARGET: number;
  64853. /**
  64854. * Texture data comes from a cube data file
  64855. */
  64856. static DATASOURCE_CUBE: number;
  64857. /**
  64858. * Texture data comes from a raw cube data
  64859. */
  64860. static DATASOURCE_CUBERAW: number;
  64861. /**
  64862. * Texture data come from a prefiltered cube data file
  64863. */
  64864. static DATASOURCE_CUBEPREFILTERED: number;
  64865. /**
  64866. * Texture content is raw 3D data
  64867. */
  64868. static DATASOURCE_RAW3D: number;
  64869. /**
  64870. * Texture content is a depth texture
  64871. */
  64872. static DATASOURCE_DEPTHTEXTURE: number;
  64873. /**
  64874. * Texture data comes from a raw cube data encoded with RGBD
  64875. */
  64876. static DATASOURCE_CUBERAW_RGBD: number;
  64877. /**
  64878. * Defines if the texture is ready
  64879. */
  64880. isReady: boolean;
  64881. /**
  64882. * Defines if the texture is a cube texture
  64883. */
  64884. isCube: boolean;
  64885. /**
  64886. * Defines if the texture contains 3D data
  64887. */
  64888. is3D: boolean;
  64889. /**
  64890. * Defines if the texture contains multiview data
  64891. */
  64892. isMultiview: boolean;
  64893. /**
  64894. * Gets the URL used to load this texture
  64895. */
  64896. url: string;
  64897. /**
  64898. * Gets the sampling mode of the texture
  64899. */
  64900. samplingMode: number;
  64901. /**
  64902. * Gets a boolean indicating if the texture needs mipmaps generation
  64903. */
  64904. generateMipMaps: boolean;
  64905. /**
  64906. * Gets the number of samples used by the texture (WebGL2+ only)
  64907. */
  64908. samples: number;
  64909. /**
  64910. * Gets the type of the texture (int, float...)
  64911. */
  64912. type: number;
  64913. /**
  64914. * Gets the format of the texture (RGB, RGBA...)
  64915. */
  64916. format: number;
  64917. /**
  64918. * Observable called when the texture is loaded
  64919. */
  64920. onLoadedObservable: Observable<InternalTexture>;
  64921. /**
  64922. * Gets the width of the texture
  64923. */
  64924. width: number;
  64925. /**
  64926. * Gets the height of the texture
  64927. */
  64928. height: number;
  64929. /**
  64930. * Gets the depth of the texture
  64931. */
  64932. depth: number;
  64933. /**
  64934. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64935. */
  64936. baseWidth: number;
  64937. /**
  64938. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64939. */
  64940. baseHeight: number;
  64941. /**
  64942. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64943. */
  64944. baseDepth: number;
  64945. /**
  64946. * Gets a boolean indicating if the texture is inverted on Y axis
  64947. */
  64948. invertY: boolean;
  64949. /**
  64950. * Gets or set the previous tracker in the list
  64951. */
  64952. previous: Nullable<IInternalTextureTracker>;
  64953. /**
  64954. * Gets or set the next tracker in the list
  64955. */
  64956. next: Nullable<IInternalTextureTracker>;
  64957. /** @hidden */
  64958. _invertVScale: boolean;
  64959. /** @hidden */
  64960. _initialSlot: number;
  64961. /** @hidden */
  64962. _designatedSlot: number;
  64963. /** @hidden */
  64964. _dataSource: number;
  64965. /** @hidden */
  64966. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64967. /** @hidden */
  64968. _bufferView: Nullable<ArrayBufferView>;
  64969. /** @hidden */
  64970. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64971. /** @hidden */
  64972. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64973. /** @hidden */
  64974. _size: number;
  64975. /** @hidden */
  64976. _extension: string;
  64977. /** @hidden */
  64978. _files: Nullable<string[]>;
  64979. /** @hidden */
  64980. _workingCanvas: HTMLCanvasElement;
  64981. /** @hidden */
  64982. _workingContext: CanvasRenderingContext2D;
  64983. /** @hidden */
  64984. _framebuffer: Nullable<WebGLFramebuffer>;
  64985. /** @hidden */
  64986. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64987. /** @hidden */
  64988. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64989. /** @hidden */
  64990. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64991. /** @hidden */
  64992. _attachments: Nullable<number[]>;
  64993. /** @hidden */
  64994. _cachedCoordinatesMode: Nullable<number>;
  64995. /** @hidden */
  64996. _cachedWrapU: Nullable<number>;
  64997. /** @hidden */
  64998. _cachedWrapV: Nullable<number>;
  64999. /** @hidden */
  65000. _cachedWrapR: Nullable<number>;
  65001. /** @hidden */
  65002. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65003. /** @hidden */
  65004. _isDisabled: boolean;
  65005. /** @hidden */
  65006. _compression: Nullable<string>;
  65007. /** @hidden */
  65008. _generateStencilBuffer: boolean;
  65009. /** @hidden */
  65010. _generateDepthBuffer: boolean;
  65011. /** @hidden */
  65012. _comparisonFunction: number;
  65013. /** @hidden */
  65014. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65015. /** @hidden */
  65016. _lodGenerationScale: number;
  65017. /** @hidden */
  65018. _lodGenerationOffset: number;
  65019. /** @hidden */
  65020. _colorTextureArray: Nullable<WebGLTexture>;
  65021. /** @hidden */
  65022. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65023. /** @hidden */
  65024. _lodTextureHigh: BaseTexture;
  65025. /** @hidden */
  65026. _lodTextureMid: BaseTexture;
  65027. /** @hidden */
  65028. _lodTextureLow: BaseTexture;
  65029. /** @hidden */
  65030. _isRGBD: boolean;
  65031. /** @hidden */
  65032. _webGLTexture: Nullable<WebGLTexture>;
  65033. /** @hidden */
  65034. _references: number;
  65035. private _engine;
  65036. /**
  65037. * Gets the Engine the texture belongs to.
  65038. * @returns The babylon engine
  65039. */
  65040. getEngine(): Engine;
  65041. /**
  65042. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65043. */
  65044. readonly dataSource: number;
  65045. /**
  65046. * Creates a new InternalTexture
  65047. * @param engine defines the engine to use
  65048. * @param dataSource defines the type of data that will be used
  65049. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65050. */
  65051. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65052. /**
  65053. * Increments the number of references (ie. the number of Texture that point to it)
  65054. */
  65055. incrementReferences(): void;
  65056. /**
  65057. * Change the size of the texture (not the size of the content)
  65058. * @param width defines the new width
  65059. * @param height defines the new height
  65060. * @param depth defines the new depth (1 by default)
  65061. */
  65062. updateSize(width: int, height: int, depth?: int): void;
  65063. /** @hidden */
  65064. _rebuild(): void;
  65065. /** @hidden */
  65066. _swapAndDie(target: InternalTexture): void;
  65067. /**
  65068. * Dispose the current allocated resources
  65069. */
  65070. dispose(): void;
  65071. }
  65072. }
  65073. declare module BABYLON {
  65074. /**
  65075. * This represents the main contract an easing function should follow.
  65076. * Easing functions are used throughout the animation system.
  65077. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65078. */
  65079. export interface IEasingFunction {
  65080. /**
  65081. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65082. * of the easing function.
  65083. * The link below provides some of the most common examples of easing functions.
  65084. * @see https://easings.net/
  65085. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65086. * @returns the corresponding value on the curve defined by the easing function
  65087. */
  65088. ease(gradient: number): number;
  65089. }
  65090. /**
  65091. * Base class used for every default easing function.
  65092. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65093. */
  65094. export class EasingFunction implements IEasingFunction {
  65095. /**
  65096. * Interpolation follows the mathematical formula associated with the easing function.
  65097. */
  65098. static readonly EASINGMODE_EASEIN: number;
  65099. /**
  65100. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65101. */
  65102. static readonly EASINGMODE_EASEOUT: number;
  65103. /**
  65104. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65105. */
  65106. static readonly EASINGMODE_EASEINOUT: number;
  65107. private _easingMode;
  65108. /**
  65109. * Sets the easing mode of the current function.
  65110. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65111. */
  65112. setEasingMode(easingMode: number): void;
  65113. /**
  65114. * Gets the current easing mode.
  65115. * @returns the easing mode
  65116. */
  65117. getEasingMode(): number;
  65118. /**
  65119. * @hidden
  65120. */
  65121. easeInCore(gradient: number): number;
  65122. /**
  65123. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65124. * of the easing function.
  65125. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65126. * @returns the corresponding value on the curve defined by the easing function
  65127. */
  65128. ease(gradient: number): number;
  65129. }
  65130. /**
  65131. * Easing function with a circle shape (see link below).
  65132. * @see https://easings.net/#easeInCirc
  65133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65134. */
  65135. export class CircleEase extends EasingFunction implements IEasingFunction {
  65136. /** @hidden */
  65137. easeInCore(gradient: number): number;
  65138. }
  65139. /**
  65140. * Easing function with a ease back shape (see link below).
  65141. * @see https://easings.net/#easeInBack
  65142. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65143. */
  65144. export class BackEase extends EasingFunction implements IEasingFunction {
  65145. /** Defines the amplitude of the function */
  65146. amplitude: number;
  65147. /**
  65148. * Instantiates a back ease easing
  65149. * @see https://easings.net/#easeInBack
  65150. * @param amplitude Defines the amplitude of the function
  65151. */
  65152. constructor(
  65153. /** Defines the amplitude of the function */
  65154. amplitude?: number);
  65155. /** @hidden */
  65156. easeInCore(gradient: number): number;
  65157. }
  65158. /**
  65159. * Easing function with a bouncing shape (see link below).
  65160. * @see https://easings.net/#easeInBounce
  65161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65162. */
  65163. export class BounceEase extends EasingFunction implements IEasingFunction {
  65164. /** Defines the number of bounces */
  65165. bounces: number;
  65166. /** Defines the amplitude of the bounce */
  65167. bounciness: number;
  65168. /**
  65169. * Instantiates a bounce easing
  65170. * @see https://easings.net/#easeInBounce
  65171. * @param bounces Defines the number of bounces
  65172. * @param bounciness Defines the amplitude of the bounce
  65173. */
  65174. constructor(
  65175. /** Defines the number of bounces */
  65176. bounces?: number,
  65177. /** Defines the amplitude of the bounce */
  65178. bounciness?: number);
  65179. /** @hidden */
  65180. easeInCore(gradient: number): number;
  65181. }
  65182. /**
  65183. * Easing function with a power of 3 shape (see link below).
  65184. * @see https://easings.net/#easeInCubic
  65185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65186. */
  65187. export class CubicEase extends EasingFunction implements IEasingFunction {
  65188. /** @hidden */
  65189. easeInCore(gradient: number): number;
  65190. }
  65191. /**
  65192. * Easing function with an elastic shape (see link below).
  65193. * @see https://easings.net/#easeInElastic
  65194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65195. */
  65196. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65197. /** Defines the number of oscillations*/
  65198. oscillations: number;
  65199. /** Defines the amplitude of the oscillations*/
  65200. springiness: number;
  65201. /**
  65202. * Instantiates an elastic easing function
  65203. * @see https://easings.net/#easeInElastic
  65204. * @param oscillations Defines the number of oscillations
  65205. * @param springiness Defines the amplitude of the oscillations
  65206. */
  65207. constructor(
  65208. /** Defines the number of oscillations*/
  65209. oscillations?: number,
  65210. /** Defines the amplitude of the oscillations*/
  65211. springiness?: number);
  65212. /** @hidden */
  65213. easeInCore(gradient: number): number;
  65214. }
  65215. /**
  65216. * Easing function with an exponential shape (see link below).
  65217. * @see https://easings.net/#easeInExpo
  65218. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65219. */
  65220. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65221. /** Defines the exponent of the function */
  65222. exponent: number;
  65223. /**
  65224. * Instantiates an exponential easing function
  65225. * @see https://easings.net/#easeInExpo
  65226. * @param exponent Defines the exponent of the function
  65227. */
  65228. constructor(
  65229. /** Defines the exponent of the function */
  65230. exponent?: number);
  65231. /** @hidden */
  65232. easeInCore(gradient: number): number;
  65233. }
  65234. /**
  65235. * Easing function with a power shape (see link below).
  65236. * @see https://easings.net/#easeInQuad
  65237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65238. */
  65239. export class PowerEase extends EasingFunction implements IEasingFunction {
  65240. /** Defines the power of the function */
  65241. power: number;
  65242. /**
  65243. * Instantiates an power base easing function
  65244. * @see https://easings.net/#easeInQuad
  65245. * @param power Defines the power of the function
  65246. */
  65247. constructor(
  65248. /** Defines the power of the function */
  65249. power?: number);
  65250. /** @hidden */
  65251. easeInCore(gradient: number): number;
  65252. }
  65253. /**
  65254. * Easing function with a power of 2 shape (see link below).
  65255. * @see https://easings.net/#easeInQuad
  65256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65257. */
  65258. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65259. /** @hidden */
  65260. easeInCore(gradient: number): number;
  65261. }
  65262. /**
  65263. * Easing function with a power of 4 shape (see link below).
  65264. * @see https://easings.net/#easeInQuart
  65265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65266. */
  65267. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65268. /** @hidden */
  65269. easeInCore(gradient: number): number;
  65270. }
  65271. /**
  65272. * Easing function with a power of 5 shape (see link below).
  65273. * @see https://easings.net/#easeInQuint
  65274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65275. */
  65276. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65277. /** @hidden */
  65278. easeInCore(gradient: number): number;
  65279. }
  65280. /**
  65281. * Easing function with a sin shape (see link below).
  65282. * @see https://easings.net/#easeInSine
  65283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65284. */
  65285. export class SineEase extends EasingFunction implements IEasingFunction {
  65286. /** @hidden */
  65287. easeInCore(gradient: number): number;
  65288. }
  65289. /**
  65290. * Easing function with a bezier shape (see link below).
  65291. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65292. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65293. */
  65294. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65295. /** Defines the x component of the start tangent in the bezier curve */
  65296. x1: number;
  65297. /** Defines the y component of the start tangent in the bezier curve */
  65298. y1: number;
  65299. /** Defines the x component of the end tangent in the bezier curve */
  65300. x2: number;
  65301. /** Defines the y component of the end tangent in the bezier curve */
  65302. y2: number;
  65303. /**
  65304. * Instantiates a bezier function
  65305. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65306. * @param x1 Defines the x component of the start tangent in the bezier curve
  65307. * @param y1 Defines the y component of the start tangent in the bezier curve
  65308. * @param x2 Defines the x component of the end tangent in the bezier curve
  65309. * @param y2 Defines the y component of the end tangent in the bezier curve
  65310. */
  65311. constructor(
  65312. /** Defines the x component of the start tangent in the bezier curve */
  65313. x1?: number,
  65314. /** Defines the y component of the start tangent in the bezier curve */
  65315. y1?: number,
  65316. /** Defines the x component of the end tangent in the bezier curve */
  65317. x2?: number,
  65318. /** Defines the y component of the end tangent in the bezier curve */
  65319. y2?: number);
  65320. /** @hidden */
  65321. easeInCore(gradient: number): number;
  65322. }
  65323. }
  65324. declare module BABYLON {
  65325. /**
  65326. * Defines an interface which represents an animation key frame
  65327. */
  65328. export interface IAnimationKey {
  65329. /**
  65330. * Frame of the key frame
  65331. */
  65332. frame: number;
  65333. /**
  65334. * Value at the specifies key frame
  65335. */
  65336. value: any;
  65337. /**
  65338. * The input tangent for the cubic hermite spline
  65339. */
  65340. inTangent?: any;
  65341. /**
  65342. * The output tangent for the cubic hermite spline
  65343. */
  65344. outTangent?: any;
  65345. /**
  65346. * The animation interpolation type
  65347. */
  65348. interpolation?: AnimationKeyInterpolation;
  65349. }
  65350. /**
  65351. * Enum for the animation key frame interpolation type
  65352. */
  65353. export enum AnimationKeyInterpolation {
  65354. /**
  65355. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65356. */
  65357. STEP = 1
  65358. }
  65359. }
  65360. declare module BABYLON {
  65361. /**
  65362. * Represents the range of an animation
  65363. */
  65364. export class AnimationRange {
  65365. /**The name of the animation range**/
  65366. name: string;
  65367. /**The starting frame of the animation */
  65368. from: number;
  65369. /**The ending frame of the animation*/
  65370. to: number;
  65371. /**
  65372. * Initializes the range of an animation
  65373. * @param name The name of the animation range
  65374. * @param from The starting frame of the animation
  65375. * @param to The ending frame of the animation
  65376. */
  65377. constructor(
  65378. /**The name of the animation range**/
  65379. name: string,
  65380. /**The starting frame of the animation */
  65381. from: number,
  65382. /**The ending frame of the animation*/
  65383. to: number);
  65384. /**
  65385. * Makes a copy of the animation range
  65386. * @returns A copy of the animation range
  65387. */
  65388. clone(): AnimationRange;
  65389. }
  65390. }
  65391. declare module BABYLON {
  65392. /**
  65393. * Composed of a frame, and an action function
  65394. */
  65395. export class AnimationEvent {
  65396. /** The frame for which the event is triggered **/
  65397. frame: number;
  65398. /** The event to perform when triggered **/
  65399. action: (currentFrame: number) => void;
  65400. /** Specifies if the event should be triggered only once**/
  65401. onlyOnce?: boolean | undefined;
  65402. /**
  65403. * Specifies if the animation event is done
  65404. */
  65405. isDone: boolean;
  65406. /**
  65407. * Initializes the animation event
  65408. * @param frame The frame for which the event is triggered
  65409. * @param action The event to perform when triggered
  65410. * @param onlyOnce Specifies if the event should be triggered only once
  65411. */
  65412. constructor(
  65413. /** The frame for which the event is triggered **/
  65414. frame: number,
  65415. /** The event to perform when triggered **/
  65416. action: (currentFrame: number) => void,
  65417. /** Specifies if the event should be triggered only once**/
  65418. onlyOnce?: boolean | undefined);
  65419. /** @hidden */
  65420. _clone(): AnimationEvent;
  65421. }
  65422. }
  65423. declare module BABYLON {
  65424. /**
  65425. * Interface used to define a behavior
  65426. */
  65427. export interface Behavior<T> {
  65428. /** gets or sets behavior's name */
  65429. name: string;
  65430. /**
  65431. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65432. */
  65433. init(): void;
  65434. /**
  65435. * Called when the behavior is attached to a target
  65436. * @param target defines the target where the behavior is attached to
  65437. */
  65438. attach(target: T): void;
  65439. /**
  65440. * Called when the behavior is detached from its target
  65441. */
  65442. detach(): void;
  65443. }
  65444. /**
  65445. * Interface implemented by classes supporting behaviors
  65446. */
  65447. export interface IBehaviorAware<T> {
  65448. /**
  65449. * Attach a behavior
  65450. * @param behavior defines the behavior to attach
  65451. * @returns the current host
  65452. */
  65453. addBehavior(behavior: Behavior<T>): T;
  65454. /**
  65455. * Remove a behavior from the current object
  65456. * @param behavior defines the behavior to detach
  65457. * @returns the current host
  65458. */
  65459. removeBehavior(behavior: Behavior<T>): T;
  65460. /**
  65461. * Gets a behavior using its name to search
  65462. * @param name defines the name to search
  65463. * @returns the behavior or null if not found
  65464. */
  65465. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65466. }
  65467. }
  65468. declare module BABYLON {
  65469. /**
  65470. * @hidden
  65471. */
  65472. export class IntersectionInfo {
  65473. bu: Nullable<number>;
  65474. bv: Nullable<number>;
  65475. distance: number;
  65476. faceId: number;
  65477. subMeshId: number;
  65478. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65479. }
  65480. }
  65481. declare module BABYLON {
  65482. /**
  65483. * Class used to store bounding sphere information
  65484. */
  65485. export class BoundingSphere {
  65486. /**
  65487. * Gets the center of the bounding sphere in local space
  65488. */
  65489. readonly center: Vector3;
  65490. /**
  65491. * Radius of the bounding sphere in local space
  65492. */
  65493. radius: number;
  65494. /**
  65495. * Gets the center of the bounding sphere in world space
  65496. */
  65497. readonly centerWorld: Vector3;
  65498. /**
  65499. * Radius of the bounding sphere in world space
  65500. */
  65501. radiusWorld: number;
  65502. /**
  65503. * Gets the minimum vector in local space
  65504. */
  65505. readonly minimum: Vector3;
  65506. /**
  65507. * Gets the maximum vector in local space
  65508. */
  65509. readonly maximum: Vector3;
  65510. private _worldMatrix;
  65511. private static readonly TmpVector3;
  65512. /**
  65513. * Creates a new bounding sphere
  65514. * @param min defines the minimum vector (in local space)
  65515. * @param max defines the maximum vector (in local space)
  65516. * @param worldMatrix defines the new world matrix
  65517. */
  65518. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65519. /**
  65520. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65521. * @param min defines the new minimum vector (in local space)
  65522. * @param max defines the new maximum vector (in local space)
  65523. * @param worldMatrix defines the new world matrix
  65524. */
  65525. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65526. /**
  65527. * Scale the current bounding sphere by applying a scale factor
  65528. * @param factor defines the scale factor to apply
  65529. * @returns the current bounding box
  65530. */
  65531. scale(factor: number): BoundingSphere;
  65532. /**
  65533. * Gets the world matrix of the bounding box
  65534. * @returns a matrix
  65535. */
  65536. getWorldMatrix(): DeepImmutable<Matrix>;
  65537. /** @hidden */
  65538. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65539. /**
  65540. * Tests if the bounding sphere is intersecting the frustum planes
  65541. * @param frustumPlanes defines the frustum planes to test
  65542. * @returns true if there is an intersection
  65543. */
  65544. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65545. /**
  65546. * Tests if the bounding sphere center is in between the frustum planes.
  65547. * Used for optimistic fast inclusion.
  65548. * @param frustumPlanes defines the frustum planes to test
  65549. * @returns true if the sphere center is in between the frustum planes
  65550. */
  65551. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65552. /**
  65553. * Tests if a point is inside the bounding sphere
  65554. * @param point defines the point to test
  65555. * @returns true if the point is inside the bounding sphere
  65556. */
  65557. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65558. /**
  65559. * Checks if two sphere intersct
  65560. * @param sphere0 sphere 0
  65561. * @param sphere1 sphere 1
  65562. * @returns true if the speres intersect
  65563. */
  65564. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  65565. }
  65566. }
  65567. declare module BABYLON {
  65568. /**
  65569. * Class used to store bounding box information
  65570. */
  65571. export class BoundingBox implements ICullable {
  65572. /**
  65573. * Gets the 8 vectors representing the bounding box in local space
  65574. */
  65575. readonly vectors: Vector3[];
  65576. /**
  65577. * Gets the center of the bounding box in local space
  65578. */
  65579. readonly center: Vector3;
  65580. /**
  65581. * Gets the center of the bounding box in world space
  65582. */
  65583. readonly centerWorld: Vector3;
  65584. /**
  65585. * Gets the extend size in local space
  65586. */
  65587. readonly extendSize: Vector3;
  65588. /**
  65589. * Gets the extend size in world space
  65590. */
  65591. readonly extendSizeWorld: Vector3;
  65592. /**
  65593. * Gets the OBB (object bounding box) directions
  65594. */
  65595. readonly directions: Vector3[];
  65596. /**
  65597. * Gets the 8 vectors representing the bounding box in world space
  65598. */
  65599. readonly vectorsWorld: Vector3[];
  65600. /**
  65601. * Gets the minimum vector in world space
  65602. */
  65603. readonly minimumWorld: Vector3;
  65604. /**
  65605. * Gets the maximum vector in world space
  65606. */
  65607. readonly maximumWorld: Vector3;
  65608. /**
  65609. * Gets the minimum vector in local space
  65610. */
  65611. readonly minimum: Vector3;
  65612. /**
  65613. * Gets the maximum vector in local space
  65614. */
  65615. readonly maximum: Vector3;
  65616. private _worldMatrix;
  65617. private static readonly TmpVector3;
  65618. /**
  65619. * @hidden
  65620. */
  65621. _tag: number;
  65622. /**
  65623. * Creates a new bounding box
  65624. * @param min defines the minimum vector (in local space)
  65625. * @param max defines the maximum vector (in local space)
  65626. * @param worldMatrix defines the new world matrix
  65627. */
  65628. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65629. /**
  65630. * Recreates the entire bounding box from scratch as if we call the constructor in place
  65631. * @param min defines the new minimum vector (in local space)
  65632. * @param max defines the new maximum vector (in local space)
  65633. * @param worldMatrix defines the new world matrix
  65634. */
  65635. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65636. /**
  65637. * Scale the current bounding box by applying a scale factor
  65638. * @param factor defines the scale factor to apply
  65639. * @returns the current bounding box
  65640. */
  65641. scale(factor: number): BoundingBox;
  65642. /**
  65643. * Gets the world matrix of the bounding box
  65644. * @returns a matrix
  65645. */
  65646. getWorldMatrix(): DeepImmutable<Matrix>;
  65647. /** @hidden */
  65648. _update(world: DeepImmutable<Matrix>): void;
  65649. /**
  65650. * Tests if the bounding box is intersecting the frustum planes
  65651. * @param frustumPlanes defines the frustum planes to test
  65652. * @returns true if there is an intersection
  65653. */
  65654. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65655. /**
  65656. * Tests if the bounding box is entirely inside the frustum planes
  65657. * @param frustumPlanes defines the frustum planes to test
  65658. * @returns true if there is an inclusion
  65659. */
  65660. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65661. /**
  65662. * Tests if a point is inside the bounding box
  65663. * @param point defines the point to test
  65664. * @returns true if the point is inside the bounding box
  65665. */
  65666. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65667. /**
  65668. * Tests if the bounding box intersects with a bounding sphere
  65669. * @param sphere defines the sphere to test
  65670. * @returns true if there is an intersection
  65671. */
  65672. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  65673. /**
  65674. * Tests if the bounding box intersects with a box defined by a min and max vectors
  65675. * @param min defines the min vector to use
  65676. * @param max defines the max vector to use
  65677. * @returns true if there is an intersection
  65678. */
  65679. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  65680. /**
  65681. * Tests if two bounding boxes are intersections
  65682. * @param box0 defines the first box to test
  65683. * @param box1 defines the second box to test
  65684. * @returns true if there is an intersection
  65685. */
  65686. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  65687. /**
  65688. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  65689. * @param minPoint defines the minimum vector of the bounding box
  65690. * @param maxPoint defines the maximum vector of the bounding box
  65691. * @param sphereCenter defines the sphere center
  65692. * @param sphereRadius defines the sphere radius
  65693. * @returns true if there is an intersection
  65694. */
  65695. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  65696. /**
  65697. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  65698. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65699. * @param frustumPlanes defines the frustum planes to test
  65700. * @return true if there is an inclusion
  65701. */
  65702. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65703. /**
  65704. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  65705. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65706. * @param frustumPlanes defines the frustum planes to test
  65707. * @return true if there is an intersection
  65708. */
  65709. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65710. }
  65711. }
  65712. declare module BABYLON {
  65713. /** @hidden */
  65714. export class Collider {
  65715. /** Define if a collision was found */
  65716. collisionFound: boolean;
  65717. /**
  65718. * Define last intersection point in local space
  65719. */
  65720. intersectionPoint: Vector3;
  65721. /**
  65722. * Define last collided mesh
  65723. */
  65724. collidedMesh: Nullable<AbstractMesh>;
  65725. private _collisionPoint;
  65726. private _planeIntersectionPoint;
  65727. private _tempVector;
  65728. private _tempVector2;
  65729. private _tempVector3;
  65730. private _tempVector4;
  65731. private _edge;
  65732. private _baseToVertex;
  65733. private _destinationPoint;
  65734. private _slidePlaneNormal;
  65735. private _displacementVector;
  65736. /** @hidden */
  65737. _radius: Vector3;
  65738. /** @hidden */
  65739. _retry: number;
  65740. private _velocity;
  65741. private _basePoint;
  65742. private _epsilon;
  65743. /** @hidden */
  65744. _velocityWorldLength: number;
  65745. /** @hidden */
  65746. _basePointWorld: Vector3;
  65747. private _velocityWorld;
  65748. private _normalizedVelocity;
  65749. /** @hidden */
  65750. _initialVelocity: Vector3;
  65751. /** @hidden */
  65752. _initialPosition: Vector3;
  65753. private _nearestDistance;
  65754. private _collisionMask;
  65755. collisionMask: number;
  65756. /**
  65757. * Gets the plane normal used to compute the sliding response (in local space)
  65758. */
  65759. readonly slidePlaneNormal: Vector3;
  65760. /** @hidden */
  65761. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65762. /** @hidden */
  65763. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65764. /** @hidden */
  65765. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65766. /** @hidden */
  65767. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65768. /** @hidden */
  65769. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65770. /** @hidden */
  65771. _getResponse(pos: Vector3, vel: Vector3): void;
  65772. }
  65773. }
  65774. declare module BABYLON {
  65775. /**
  65776. * Interface for cullable objects
  65777. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65778. */
  65779. export interface ICullable {
  65780. /**
  65781. * Checks if the object or part of the object is in the frustum
  65782. * @param frustumPlanes Camera near/planes
  65783. * @returns true if the object is in frustum otherwise false
  65784. */
  65785. isInFrustum(frustumPlanes: Plane[]): boolean;
  65786. /**
  65787. * Checks if a cullable object (mesh...) is in the camera frustum
  65788. * Unlike isInFrustum this cheks the full bounding box
  65789. * @param frustumPlanes Camera near/planes
  65790. * @returns true if the object is in frustum otherwise false
  65791. */
  65792. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65793. }
  65794. /**
  65795. * Info for a bounding data of a mesh
  65796. */
  65797. export class BoundingInfo implements ICullable {
  65798. /**
  65799. * Bounding box for the mesh
  65800. */
  65801. readonly boundingBox: BoundingBox;
  65802. /**
  65803. * Bounding sphere for the mesh
  65804. */
  65805. readonly boundingSphere: BoundingSphere;
  65806. private _isLocked;
  65807. private static readonly TmpVector3;
  65808. /**
  65809. * Constructs bounding info
  65810. * @param minimum min vector of the bounding box/sphere
  65811. * @param maximum max vector of the bounding box/sphere
  65812. * @param worldMatrix defines the new world matrix
  65813. */
  65814. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65815. /**
  65816. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65817. * @param min defines the new minimum vector (in local space)
  65818. * @param max defines the new maximum vector (in local space)
  65819. * @param worldMatrix defines the new world matrix
  65820. */
  65821. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65822. /**
  65823. * min vector of the bounding box/sphere
  65824. */
  65825. readonly minimum: Vector3;
  65826. /**
  65827. * max vector of the bounding box/sphere
  65828. */
  65829. readonly maximum: Vector3;
  65830. /**
  65831. * If the info is locked and won't be updated to avoid perf overhead
  65832. */
  65833. isLocked: boolean;
  65834. /**
  65835. * Updates the bounding sphere and box
  65836. * @param world world matrix to be used to update
  65837. */
  65838. update(world: DeepImmutable<Matrix>): void;
  65839. /**
  65840. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65841. * @param center New center of the bounding info
  65842. * @param extend New extend of the bounding info
  65843. * @returns the current bounding info
  65844. */
  65845. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65846. /**
  65847. * Scale the current bounding info by applying a scale factor
  65848. * @param factor defines the scale factor to apply
  65849. * @returns the current bounding info
  65850. */
  65851. scale(factor: number): BoundingInfo;
  65852. /**
  65853. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65854. * @param frustumPlanes defines the frustum to test
  65855. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65856. * @returns true if the bounding info is in the frustum planes
  65857. */
  65858. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65859. /**
  65860. * Gets the world distance between the min and max points of the bounding box
  65861. */
  65862. readonly diagonalLength: number;
  65863. /**
  65864. * Checks if a cullable object (mesh...) is in the camera frustum
  65865. * Unlike isInFrustum this cheks the full bounding box
  65866. * @param frustumPlanes Camera near/planes
  65867. * @returns true if the object is in frustum otherwise false
  65868. */
  65869. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65870. /** @hidden */
  65871. _checkCollision(collider: Collider): boolean;
  65872. /**
  65873. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65874. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65875. * @param point the point to check intersection with
  65876. * @returns if the point intersects
  65877. */
  65878. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65879. /**
  65880. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65881. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65882. * @param boundingInfo the bounding info to check intersection with
  65883. * @param precise if the intersection should be done using OBB
  65884. * @returns if the bounding info intersects
  65885. */
  65886. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65887. }
  65888. }
  65889. declare module BABYLON {
  65890. /**
  65891. * Defines an array and its length.
  65892. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65893. */
  65894. export interface ISmartArrayLike<T> {
  65895. /**
  65896. * The data of the array.
  65897. */
  65898. data: Array<T>;
  65899. /**
  65900. * The active length of the array.
  65901. */
  65902. length: number;
  65903. }
  65904. /**
  65905. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65906. */
  65907. export class SmartArray<T> implements ISmartArrayLike<T> {
  65908. /**
  65909. * The full set of data from the array.
  65910. */
  65911. data: Array<T>;
  65912. /**
  65913. * The active length of the array.
  65914. */
  65915. length: number;
  65916. protected _id: number;
  65917. /**
  65918. * Instantiates a Smart Array.
  65919. * @param capacity defines the default capacity of the array.
  65920. */
  65921. constructor(capacity: number);
  65922. /**
  65923. * Pushes a value at the end of the active data.
  65924. * @param value defines the object to push in the array.
  65925. */
  65926. push(value: T): void;
  65927. /**
  65928. * Iterates over the active data and apply the lambda to them.
  65929. * @param func defines the action to apply on each value.
  65930. */
  65931. forEach(func: (content: T) => void): void;
  65932. /**
  65933. * Sorts the full sets of data.
  65934. * @param compareFn defines the comparison function to apply.
  65935. */
  65936. sort(compareFn: (a: T, b: T) => number): void;
  65937. /**
  65938. * Resets the active data to an empty array.
  65939. */
  65940. reset(): void;
  65941. /**
  65942. * Releases all the data from the array as well as the array.
  65943. */
  65944. dispose(): void;
  65945. /**
  65946. * Concats the active data with a given array.
  65947. * @param array defines the data to concatenate with.
  65948. */
  65949. concat(array: any): void;
  65950. /**
  65951. * Returns the position of a value in the active data.
  65952. * @param value defines the value to find the index for
  65953. * @returns the index if found in the active data otherwise -1
  65954. */
  65955. indexOf(value: T): number;
  65956. /**
  65957. * Returns whether an element is part of the active data.
  65958. * @param value defines the value to look for
  65959. * @returns true if found in the active data otherwise false
  65960. */
  65961. contains(value: T): boolean;
  65962. private static _GlobalId;
  65963. }
  65964. /**
  65965. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65966. * The data in this array can only be present once
  65967. */
  65968. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65969. private _duplicateId;
  65970. /**
  65971. * Pushes a value at the end of the active data.
  65972. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65973. * @param value defines the object to push in the array.
  65974. */
  65975. push(value: T): void;
  65976. /**
  65977. * Pushes a value at the end of the active data.
  65978. * If the data is already present, it won t be added again
  65979. * @param value defines the object to push in the array.
  65980. * @returns true if added false if it was already present
  65981. */
  65982. pushNoDuplicate(value: T): boolean;
  65983. /**
  65984. * Resets the active data to an empty array.
  65985. */
  65986. reset(): void;
  65987. /**
  65988. * Concats the active data with a given array.
  65989. * This ensures no dupplicate will be present in the result.
  65990. * @param array defines the data to concatenate with.
  65991. */
  65992. concatWithNoDuplicate(array: any): void;
  65993. }
  65994. }
  65995. declare module BABYLON {
  65996. /**
  65997. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65998. * separate meshes. This can be use to improve performances.
  65999. * @see http://doc.babylonjs.com/how_to/multi_materials
  66000. */
  66001. export class MultiMaterial extends Material {
  66002. private _subMaterials;
  66003. /**
  66004. * Gets or Sets the list of Materials used within the multi material.
  66005. * They need to be ordered according to the submeshes order in the associated mesh
  66006. */
  66007. subMaterials: Nullable<Material>[];
  66008. /**
  66009. * Function used to align with Node.getChildren()
  66010. * @returns the list of Materials used within the multi material
  66011. */
  66012. getChildren(): Nullable<Material>[];
  66013. /**
  66014. * Instantiates a new Multi Material
  66015. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66016. * separate meshes. This can be use to improve performances.
  66017. * @see http://doc.babylonjs.com/how_to/multi_materials
  66018. * @param name Define the name in the scene
  66019. * @param scene Define the scene the material belongs to
  66020. */
  66021. constructor(name: string, scene: Scene);
  66022. private _hookArray;
  66023. /**
  66024. * Get one of the submaterial by its index in the submaterials array
  66025. * @param index The index to look the sub material at
  66026. * @returns The Material if the index has been defined
  66027. */
  66028. getSubMaterial(index: number): Nullable<Material>;
  66029. /**
  66030. * Get the list of active textures for the whole sub materials list.
  66031. * @returns All the textures that will be used during the rendering
  66032. */
  66033. getActiveTextures(): BaseTexture[];
  66034. /**
  66035. * Gets the current class name of the material e.g. "MultiMaterial"
  66036. * Mainly use in serialization.
  66037. * @returns the class name
  66038. */
  66039. getClassName(): string;
  66040. /**
  66041. * Checks if the material is ready to render the requested sub mesh
  66042. * @param mesh Define the mesh the submesh belongs to
  66043. * @param subMesh Define the sub mesh to look readyness for
  66044. * @param useInstances Define whether or not the material is used with instances
  66045. * @returns true if ready, otherwise false
  66046. */
  66047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66048. /**
  66049. * Clones the current material and its related sub materials
  66050. * @param name Define the name of the newly cloned material
  66051. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66052. * @returns the cloned material
  66053. */
  66054. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66055. /**
  66056. * Serializes the materials into a JSON representation.
  66057. * @returns the JSON representation
  66058. */
  66059. serialize(): any;
  66060. /**
  66061. * Dispose the material and release its associated resources
  66062. * @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)
  66063. * @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)
  66064. * @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)
  66065. */
  66066. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66067. /**
  66068. * Creates a MultiMaterial from parsed MultiMaterial data.
  66069. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66070. * @param scene defines the hosting scene
  66071. * @returns a new MultiMaterial
  66072. */
  66073. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66074. }
  66075. }
  66076. declare module BABYLON {
  66077. /**
  66078. * Class used to represent data loading progression
  66079. */
  66080. export class SceneLoaderFlags {
  66081. private static _ForceFullSceneLoadingForIncremental;
  66082. private static _ShowLoadingScreen;
  66083. private static _CleanBoneMatrixWeights;
  66084. private static _loggingLevel;
  66085. /**
  66086. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66087. */
  66088. static ForceFullSceneLoadingForIncremental: boolean;
  66089. /**
  66090. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66091. */
  66092. static ShowLoadingScreen: boolean;
  66093. /**
  66094. * Defines the current logging level (while loading the scene)
  66095. * @ignorenaming
  66096. */
  66097. static loggingLevel: number;
  66098. /**
  66099. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66100. */
  66101. static CleanBoneMatrixWeights: boolean;
  66102. }
  66103. }
  66104. declare module BABYLON {
  66105. /**
  66106. * 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.
  66107. * @see https://doc.babylonjs.com/how_to/transformnode
  66108. */
  66109. export class TransformNode extends Node {
  66110. /**
  66111. * Object will not rotate to face the camera
  66112. */
  66113. static BILLBOARDMODE_NONE: number;
  66114. /**
  66115. * Object will rotate to face the camera but only on the x axis
  66116. */
  66117. static BILLBOARDMODE_X: number;
  66118. /**
  66119. * Object will rotate to face the camera but only on the y axis
  66120. */
  66121. static BILLBOARDMODE_Y: number;
  66122. /**
  66123. * Object will rotate to face the camera but only on the z axis
  66124. */
  66125. static BILLBOARDMODE_Z: number;
  66126. /**
  66127. * Object will rotate to face the camera
  66128. */
  66129. static BILLBOARDMODE_ALL: number;
  66130. private _forward;
  66131. private _forwardInverted;
  66132. private _up;
  66133. private _right;
  66134. private _rightInverted;
  66135. private _position;
  66136. private _rotation;
  66137. private _rotationQuaternion;
  66138. protected _scaling: Vector3;
  66139. protected _isDirty: boolean;
  66140. private _transformToBoneReferal;
  66141. /**
  66142. * Set the billboard mode. Default is 0.
  66143. *
  66144. * | Value | Type | Description |
  66145. * | --- | --- | --- |
  66146. * | 0 | BILLBOARDMODE_NONE | |
  66147. * | 1 | BILLBOARDMODE_X | |
  66148. * | 2 | BILLBOARDMODE_Y | |
  66149. * | 4 | BILLBOARDMODE_Z | |
  66150. * | 7 | BILLBOARDMODE_ALL | |
  66151. *
  66152. */
  66153. billboardMode: number;
  66154. /**
  66155. * 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
  66156. */
  66157. scalingDeterminant: number;
  66158. /**
  66159. * Sets the distance of the object to max, often used by skybox
  66160. */
  66161. infiniteDistance: boolean;
  66162. /**
  66163. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66164. * By default the system will update normals to compensate
  66165. */
  66166. ignoreNonUniformScaling: boolean;
  66167. /** @hidden */
  66168. _poseMatrix: Matrix;
  66169. /** @hidden */
  66170. _localMatrix: Matrix;
  66171. private _absolutePosition;
  66172. private _pivotMatrix;
  66173. private _pivotMatrixInverse;
  66174. protected _postMultiplyPivotMatrix: boolean;
  66175. private _tempMatrix;
  66176. private _tempMatrix2;
  66177. protected _isWorldMatrixFrozen: boolean;
  66178. /** @hidden */
  66179. _indexInSceneTransformNodesArray: number;
  66180. /**
  66181. * An event triggered after the world matrix is updated
  66182. */
  66183. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66184. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66185. /**
  66186. * Gets a string identifying the name of the class
  66187. * @returns "TransformNode" string
  66188. */
  66189. getClassName(): string;
  66190. /**
  66191. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66192. */
  66193. position: Vector3;
  66194. /**
  66195. * 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)).
  66196. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66197. */
  66198. rotation: Vector3;
  66199. /**
  66200. * 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)).
  66201. */
  66202. scaling: Vector3;
  66203. /**
  66204. * 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).
  66205. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66206. */
  66207. rotationQuaternion: Nullable<Quaternion>;
  66208. /**
  66209. * The forward direction of that transform in world space.
  66210. */
  66211. readonly forward: Vector3;
  66212. /**
  66213. * The up direction of that transform in world space.
  66214. */
  66215. readonly up: Vector3;
  66216. /**
  66217. * The right direction of that transform in world space.
  66218. */
  66219. readonly right: Vector3;
  66220. /**
  66221. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66222. * @param matrix the matrix to copy the pose from
  66223. * @returns this TransformNode.
  66224. */
  66225. updatePoseMatrix(matrix: Matrix): TransformNode;
  66226. /**
  66227. * Returns the mesh Pose matrix.
  66228. * @returns the pose matrix
  66229. */
  66230. getPoseMatrix(): Matrix;
  66231. /** @hidden */
  66232. _isSynchronized(): boolean;
  66233. /** @hidden */
  66234. _initCache(): void;
  66235. /**
  66236. * Flag the transform node as dirty (Forcing it to update everything)
  66237. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66238. * @returns this transform node
  66239. */
  66240. markAsDirty(property: string): TransformNode;
  66241. /**
  66242. * Returns the current mesh absolute position.
  66243. * Returns a Vector3.
  66244. */
  66245. readonly absolutePosition: Vector3;
  66246. /**
  66247. * Sets a new matrix to apply before all other transformation
  66248. * @param matrix defines the transform matrix
  66249. * @returns the current TransformNode
  66250. */
  66251. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66252. /**
  66253. * Sets a new pivot matrix to the current node
  66254. * @param matrix defines the new pivot matrix to use
  66255. * @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
  66256. * @returns the current TransformNode
  66257. */
  66258. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66259. /**
  66260. * Returns the mesh pivot matrix.
  66261. * Default : Identity.
  66262. * @returns the matrix
  66263. */
  66264. getPivotMatrix(): Matrix;
  66265. /**
  66266. * Prevents the World matrix to be computed any longer.
  66267. * @returns the TransformNode.
  66268. */
  66269. freezeWorldMatrix(): TransformNode;
  66270. /**
  66271. * Allows back the World matrix computation.
  66272. * @returns the TransformNode.
  66273. */
  66274. unfreezeWorldMatrix(): this;
  66275. /**
  66276. * True if the World matrix has been frozen.
  66277. */
  66278. readonly isWorldMatrixFrozen: boolean;
  66279. /**
  66280. * Retuns the mesh absolute position in the World.
  66281. * @returns a Vector3.
  66282. */
  66283. getAbsolutePosition(): Vector3;
  66284. /**
  66285. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66286. * @param absolutePosition the absolute position to set
  66287. * @returns the TransformNode.
  66288. */
  66289. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66290. /**
  66291. * Sets the mesh position in its local space.
  66292. * @param vector3 the position to set in localspace
  66293. * @returns the TransformNode.
  66294. */
  66295. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66296. /**
  66297. * Returns the mesh position in the local space from the current World matrix values.
  66298. * @returns a new Vector3.
  66299. */
  66300. getPositionExpressedInLocalSpace(): Vector3;
  66301. /**
  66302. * Translates the mesh along the passed Vector3 in its local space.
  66303. * @param vector3 the distance to translate in localspace
  66304. * @returns the TransformNode.
  66305. */
  66306. locallyTranslate(vector3: Vector3): TransformNode;
  66307. private static _lookAtVectorCache;
  66308. /**
  66309. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66310. * @param targetPoint the position (must be in same space as current mesh) to look at
  66311. * @param yawCor optional yaw (y-axis) correction in radians
  66312. * @param pitchCor optional pitch (x-axis) correction in radians
  66313. * @param rollCor optional roll (z-axis) correction in radians
  66314. * @param space the choosen space of the target
  66315. * @returns the TransformNode.
  66316. */
  66317. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66318. /**
  66319. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66320. * This Vector3 is expressed in the World space.
  66321. * @param localAxis axis to rotate
  66322. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66323. */
  66324. getDirection(localAxis: Vector3): Vector3;
  66325. /**
  66326. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66327. * localAxis is expressed in the mesh local space.
  66328. * result is computed in the Wordl space from the mesh World matrix.
  66329. * @param localAxis axis to rotate
  66330. * @param result the resulting transformnode
  66331. * @returns this TransformNode.
  66332. */
  66333. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66334. /**
  66335. * Sets this transform node rotation to the given local axis.
  66336. * @param localAxis the axis in local space
  66337. * @param yawCor optional yaw (y-axis) correction in radians
  66338. * @param pitchCor optional pitch (x-axis) correction in radians
  66339. * @param rollCor optional roll (z-axis) correction in radians
  66340. * @returns this TransformNode
  66341. */
  66342. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66343. /**
  66344. * Sets a new pivot point to the current node
  66345. * @param point defines the new pivot point to use
  66346. * @param space defines if the point is in world or local space (local by default)
  66347. * @returns the current TransformNode
  66348. */
  66349. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66350. /**
  66351. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66352. * @returns the pivot point
  66353. */
  66354. getPivotPoint(): Vector3;
  66355. /**
  66356. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66357. * @param result the vector3 to store the result
  66358. * @returns this TransformNode.
  66359. */
  66360. getPivotPointToRef(result: Vector3): TransformNode;
  66361. /**
  66362. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66363. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66364. */
  66365. getAbsolutePivotPoint(): Vector3;
  66366. /**
  66367. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66368. * @param result vector3 to store the result
  66369. * @returns this TransformNode.
  66370. */
  66371. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66372. /**
  66373. * Defines the passed node as the parent of the current node.
  66374. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66375. * @see https://doc.babylonjs.com/how_to/parenting
  66376. * @param node the node ot set as the parent
  66377. * @returns this TransformNode.
  66378. */
  66379. setParent(node: Nullable<Node>): TransformNode;
  66380. private _nonUniformScaling;
  66381. /**
  66382. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66383. */
  66384. readonly nonUniformScaling: boolean;
  66385. /** @hidden */
  66386. _updateNonUniformScalingState(value: boolean): boolean;
  66387. /**
  66388. * Attach the current TransformNode to another TransformNode associated with a bone
  66389. * @param bone Bone affecting the TransformNode
  66390. * @param affectedTransformNode TransformNode associated with the bone
  66391. * @returns this object
  66392. */
  66393. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66394. /**
  66395. * Detach the transform node if its associated with a bone
  66396. * @returns this object
  66397. */
  66398. detachFromBone(): TransformNode;
  66399. private static _rotationAxisCache;
  66400. /**
  66401. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66402. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66403. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66404. * The passed axis is also normalized.
  66405. * @param axis the axis to rotate around
  66406. * @param amount the amount to rotate in radians
  66407. * @param space Space to rotate in (Default: local)
  66408. * @returns the TransformNode.
  66409. */
  66410. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66411. /**
  66412. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66413. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66414. * The passed axis is also normalized. .
  66415. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66416. * @param point the point to rotate around
  66417. * @param axis the axis to rotate around
  66418. * @param amount the amount to rotate in radians
  66419. * @returns the TransformNode
  66420. */
  66421. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66422. /**
  66423. * Translates the mesh along the axis vector for the passed distance in the given space.
  66424. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66425. * @param axis the axis to translate in
  66426. * @param distance the distance to translate
  66427. * @param space Space to rotate in (Default: local)
  66428. * @returns the TransformNode.
  66429. */
  66430. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66431. /**
  66432. * Adds a rotation step to the mesh current rotation.
  66433. * x, y, z are Euler angles expressed in radians.
  66434. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66435. * This means this rotation is made in the mesh local space only.
  66436. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66437. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66438. * ```javascript
  66439. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66440. * ```
  66441. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66442. * 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.
  66443. * @param x Rotation to add
  66444. * @param y Rotation to add
  66445. * @param z Rotation to add
  66446. * @returns the TransformNode.
  66447. */
  66448. addRotation(x: number, y: number, z: number): TransformNode;
  66449. /**
  66450. * Computes the world matrix of the node
  66451. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66452. * @returns the world matrix
  66453. */
  66454. computeWorldMatrix(force?: boolean): Matrix;
  66455. protected _afterComputeWorldMatrix(): void;
  66456. /**
  66457. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66458. * @param func callback function to add
  66459. *
  66460. * @returns the TransformNode.
  66461. */
  66462. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66463. /**
  66464. * Removes a registered callback function.
  66465. * @param func callback function to remove
  66466. * @returns the TransformNode.
  66467. */
  66468. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66469. /**
  66470. * Gets the position of the current mesh in camera space
  66471. * @param camera defines the camera to use
  66472. * @returns a position
  66473. */
  66474. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66475. /**
  66476. * Returns the distance from the mesh to the active camera
  66477. * @param camera defines the camera to use
  66478. * @returns the distance
  66479. */
  66480. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66481. /**
  66482. * Clone the current transform node
  66483. * @param name Name of the new clone
  66484. * @param newParent New parent for the clone
  66485. * @param doNotCloneChildren Do not clone children hierarchy
  66486. * @returns the new transform node
  66487. */
  66488. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66489. /**
  66490. * Serializes the objects information.
  66491. * @param currentSerializationObject defines the object to serialize in
  66492. * @returns the serialized object
  66493. */
  66494. serialize(currentSerializationObject?: any): any;
  66495. /**
  66496. * Returns a new TransformNode object parsed from the source provided.
  66497. * @param parsedTransformNode is the source.
  66498. * @param scene the scne the object belongs to
  66499. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66500. * @returns a new TransformNode object parsed from the source provided.
  66501. */
  66502. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66503. /**
  66504. * Get all child-transformNodes of this node
  66505. * @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
  66506. * @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
  66507. * @returns an array of TransformNode
  66508. */
  66509. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66510. /**
  66511. * Releases resources associated with this transform node.
  66512. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66513. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66514. */
  66515. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66516. }
  66517. }
  66518. declare module BABYLON {
  66519. /**
  66520. * Class used to override all child animations of a given target
  66521. */
  66522. export class AnimationPropertiesOverride {
  66523. /**
  66524. * Gets or sets a value indicating if animation blending must be used
  66525. */
  66526. enableBlending: boolean;
  66527. /**
  66528. * Gets or sets the blending speed to use when enableBlending is true
  66529. */
  66530. blendingSpeed: number;
  66531. /**
  66532. * Gets or sets the default loop mode to use
  66533. */
  66534. loopMode: number;
  66535. }
  66536. }
  66537. declare module BABYLON {
  66538. /**
  66539. * Class used to store bone information
  66540. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66541. */
  66542. export class Bone extends Node {
  66543. /**
  66544. * defines the bone name
  66545. */
  66546. name: string;
  66547. private static _tmpVecs;
  66548. private static _tmpQuat;
  66549. private static _tmpMats;
  66550. /**
  66551. * Gets the list of child bones
  66552. */
  66553. children: Bone[];
  66554. /** Gets the animations associated with this bone */
  66555. animations: Animation[];
  66556. /**
  66557. * Gets or sets bone length
  66558. */
  66559. length: number;
  66560. /**
  66561. * @hidden Internal only
  66562. * Set this value to map this bone to a different index in the transform matrices
  66563. * Set this value to -1 to exclude the bone from the transform matrices
  66564. */
  66565. _index: Nullable<number>;
  66566. private _skeleton;
  66567. private _localMatrix;
  66568. private _restPose;
  66569. private _baseMatrix;
  66570. private _absoluteTransform;
  66571. private _invertedAbsoluteTransform;
  66572. private _parent;
  66573. private _scalingDeterminant;
  66574. private _worldTransform;
  66575. private _localScaling;
  66576. private _localRotation;
  66577. private _localPosition;
  66578. private _needToDecompose;
  66579. private _needToCompose;
  66580. /** @hidden */
  66581. _linkedTransformNode: Nullable<TransformNode>;
  66582. /** @hidden */
  66583. /** @hidden */
  66584. _matrix: Matrix;
  66585. /**
  66586. * Create a new bone
  66587. * @param name defines the bone name
  66588. * @param skeleton defines the parent skeleton
  66589. * @param parentBone defines the parent (can be null if the bone is the root)
  66590. * @param localMatrix defines the local matrix
  66591. * @param restPose defines the rest pose matrix
  66592. * @param baseMatrix defines the base matrix
  66593. * @param index defines index of the bone in the hiearchy
  66594. */
  66595. constructor(
  66596. /**
  66597. * defines the bone name
  66598. */
  66599. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  66600. /**
  66601. * Gets the current object class name.
  66602. * @return the class name
  66603. */
  66604. getClassName(): string;
  66605. /**
  66606. * Gets the parent skeleton
  66607. * @returns a skeleton
  66608. */
  66609. getSkeleton(): Skeleton;
  66610. /**
  66611. * Gets parent bone
  66612. * @returns a bone or null if the bone is the root of the bone hierarchy
  66613. */
  66614. getParent(): Nullable<Bone>;
  66615. /**
  66616. * Returns an array containing the root bones
  66617. * @returns an array containing the root bones
  66618. */
  66619. getChildren(): Array<Bone>;
  66620. /**
  66621. * Sets the parent bone
  66622. * @param parent defines the parent (can be null if the bone is the root)
  66623. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66624. */
  66625. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  66626. /**
  66627. * Gets the local matrix
  66628. * @returns a matrix
  66629. */
  66630. getLocalMatrix(): Matrix;
  66631. /**
  66632. * Gets the base matrix (initial matrix which remains unchanged)
  66633. * @returns a matrix
  66634. */
  66635. getBaseMatrix(): Matrix;
  66636. /**
  66637. * Gets the rest pose matrix
  66638. * @returns a matrix
  66639. */
  66640. getRestPose(): Matrix;
  66641. /**
  66642. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  66643. */
  66644. getWorldMatrix(): Matrix;
  66645. /**
  66646. * Sets the local matrix to rest pose matrix
  66647. */
  66648. returnToRest(): void;
  66649. /**
  66650. * Gets the inverse of the absolute transform matrix.
  66651. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  66652. * @returns a matrix
  66653. */
  66654. getInvertedAbsoluteTransform(): Matrix;
  66655. /**
  66656. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  66657. * @returns a matrix
  66658. */
  66659. getAbsoluteTransform(): Matrix;
  66660. /**
  66661. * Links with the given transform node.
  66662. * The local matrix of this bone is copied from the transform node every frame.
  66663. * @param transformNode defines the transform node to link to
  66664. */
  66665. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  66666. /** Gets or sets current position (in local space) */
  66667. position: Vector3;
  66668. /** Gets or sets current rotation (in local space) */
  66669. rotation: Vector3;
  66670. /** Gets or sets current rotation quaternion (in local space) */
  66671. rotationQuaternion: Quaternion;
  66672. /** Gets or sets current scaling (in local space) */
  66673. scaling: Vector3;
  66674. /**
  66675. * Gets the animation properties override
  66676. */
  66677. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  66678. private _decompose;
  66679. private _compose;
  66680. /**
  66681. * Update the base and local matrices
  66682. * @param matrix defines the new base or local matrix
  66683. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66684. * @param updateLocalMatrix defines if the local matrix should be updated
  66685. */
  66686. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  66687. /** @hidden */
  66688. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  66689. /**
  66690. * Flag the bone as dirty (Forcing it to update everything)
  66691. */
  66692. markAsDirty(): void;
  66693. private _markAsDirtyAndCompose;
  66694. private _markAsDirtyAndDecompose;
  66695. /**
  66696. * Translate the bone in local or world space
  66697. * @param vec The amount to translate the bone
  66698. * @param space The space that the translation is in
  66699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66700. */
  66701. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66702. /**
  66703. * Set the postion of the bone in local or world space
  66704. * @param position The position to set the bone
  66705. * @param space The space that the position is in
  66706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66707. */
  66708. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66709. /**
  66710. * Set the absolute position of the bone (world space)
  66711. * @param position The position to set the bone
  66712. * @param mesh The mesh that this bone is attached to
  66713. */
  66714. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  66715. /**
  66716. * Scale the bone on the x, y and z axes (in local space)
  66717. * @param x The amount to scale the bone on the x axis
  66718. * @param y The amount to scale the bone on the y axis
  66719. * @param z The amount to scale the bone on the z axis
  66720. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  66721. */
  66722. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  66723. /**
  66724. * Set the bone scaling in local space
  66725. * @param scale defines the scaling vector
  66726. */
  66727. setScale(scale: Vector3): void;
  66728. /**
  66729. * Gets the current scaling in local space
  66730. * @returns the current scaling vector
  66731. */
  66732. getScale(): Vector3;
  66733. /**
  66734. * Gets the current scaling in local space and stores it in a target vector
  66735. * @param result defines the target vector
  66736. */
  66737. getScaleToRef(result: Vector3): void;
  66738. /**
  66739. * Set the yaw, pitch, and roll of the bone in local or world space
  66740. * @param yaw The rotation of the bone on the y axis
  66741. * @param pitch The rotation of the bone on the x axis
  66742. * @param roll The rotation of the bone on the z axis
  66743. * @param space The space that the axes of rotation are in
  66744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66745. */
  66746. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  66747. /**
  66748. * Add a rotation to the bone on an axis in local or world space
  66749. * @param axis The axis to rotate the bone on
  66750. * @param amount The amount to rotate the bone
  66751. * @param space The space that the axis is in
  66752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66753. */
  66754. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66755. /**
  66756. * Set the rotation of the bone to a particular axis angle in local or world space
  66757. * @param axis The axis to rotate the bone on
  66758. * @param angle The angle that the bone should be rotated to
  66759. * @param space The space that the axis is in
  66760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66761. */
  66762. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66763. /**
  66764. * Set the euler rotation of the bone in local of world space
  66765. * @param rotation The euler rotation that the bone should be set to
  66766. * @param space The space that the rotation is in
  66767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66768. */
  66769. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66770. /**
  66771. * Set the quaternion rotation of the bone in local of world space
  66772. * @param quat The quaternion rotation that the bone should be set to
  66773. * @param space The space that the rotation is in
  66774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66775. */
  66776. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66777. /**
  66778. * Set the rotation matrix of the bone in local of world space
  66779. * @param rotMat The rotation matrix that the bone should be set to
  66780. * @param space The space that the rotation is in
  66781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66782. */
  66783. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66784. private _rotateWithMatrix;
  66785. private _getNegativeRotationToRef;
  66786. /**
  66787. * Get the position of the bone in local or world space
  66788. * @param space The space that the returned position is in
  66789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66790. * @returns The position of the bone
  66791. */
  66792. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66793. /**
  66794. * Copy the position of the bone to a vector3 in local or world space
  66795. * @param space The space that the returned position is in
  66796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66797. * @param result The vector3 to copy the position to
  66798. */
  66799. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66800. /**
  66801. * Get the absolute position of the bone (world space)
  66802. * @param mesh The mesh that this bone is attached to
  66803. * @returns The absolute position of the bone
  66804. */
  66805. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66806. /**
  66807. * Copy the absolute position of the bone (world space) to the result param
  66808. * @param mesh The mesh that this bone is attached to
  66809. * @param result The vector3 to copy the absolute position to
  66810. */
  66811. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66812. /**
  66813. * Compute the absolute transforms of this bone and its children
  66814. */
  66815. computeAbsoluteTransforms(): void;
  66816. /**
  66817. * Get the world direction from an axis that is in the local space of the bone
  66818. * @param localAxis The local direction that is used to compute the world direction
  66819. * @param mesh The mesh that this bone is attached to
  66820. * @returns The world direction
  66821. */
  66822. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66823. /**
  66824. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66825. * @param localAxis The local direction that is used to compute the world direction
  66826. * @param mesh The mesh that this bone is attached to
  66827. * @param result The vector3 that the world direction will be copied to
  66828. */
  66829. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66830. /**
  66831. * Get the euler rotation of the bone in local or world space
  66832. * @param space The space that the rotation should be in
  66833. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66834. * @returns The euler rotation
  66835. */
  66836. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66837. /**
  66838. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66839. * @param space The space that the rotation should be in
  66840. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66841. * @param result The vector3 that the rotation should be copied to
  66842. */
  66843. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66844. /**
  66845. * Get the quaternion rotation of the bone in either local or world space
  66846. * @param space The space that the rotation should be in
  66847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66848. * @returns The quaternion rotation
  66849. */
  66850. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66851. /**
  66852. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66853. * @param space The space that the rotation should be in
  66854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66855. * @param result The quaternion that the rotation should be copied to
  66856. */
  66857. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66858. /**
  66859. * Get the rotation matrix of the bone in local or world space
  66860. * @param space The space that the rotation should be in
  66861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66862. * @returns The rotation matrix
  66863. */
  66864. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66865. /**
  66866. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66867. * @param space The space that the rotation should be in
  66868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66869. * @param result The quaternion that the rotation should be copied to
  66870. */
  66871. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66872. /**
  66873. * Get the world position of a point that is in the local space of the bone
  66874. * @param position The local position
  66875. * @param mesh The mesh that this bone is attached to
  66876. * @returns The world position
  66877. */
  66878. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66879. /**
  66880. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66881. * @param position The local position
  66882. * @param mesh The mesh that this bone is attached to
  66883. * @param result The vector3 that the world position should be copied to
  66884. */
  66885. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66886. /**
  66887. * Get the local position of a point that is in world space
  66888. * @param position The world position
  66889. * @param mesh The mesh that this bone is attached to
  66890. * @returns The local position
  66891. */
  66892. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66893. /**
  66894. * Get the local position of a point that is in world space and copy it to the result param
  66895. * @param position The world position
  66896. * @param mesh The mesh that this bone is attached to
  66897. * @param result The vector3 that the local position should be copied to
  66898. */
  66899. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66900. }
  66901. }
  66902. declare module BABYLON {
  66903. /**
  66904. * Enum that determines the text-wrapping mode to use.
  66905. */
  66906. export enum InspectableType {
  66907. /**
  66908. * Checkbox for booleans
  66909. */
  66910. Checkbox = 0,
  66911. /**
  66912. * Sliders for numbers
  66913. */
  66914. Slider = 1,
  66915. /**
  66916. * Vector3
  66917. */
  66918. Vector3 = 2,
  66919. /**
  66920. * Quaternions
  66921. */
  66922. Quaternion = 3,
  66923. /**
  66924. * Color3
  66925. */
  66926. Color3 = 4
  66927. }
  66928. /**
  66929. * Interface used to define custom inspectable properties.
  66930. * This interface is used by the inspector to display custom property grids
  66931. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66932. */
  66933. export interface IInspectable {
  66934. /**
  66935. * Gets the label to display
  66936. */
  66937. label: string;
  66938. /**
  66939. * Gets the name of the property to edit
  66940. */
  66941. propertyName: string;
  66942. /**
  66943. * Gets the type of the editor to use
  66944. */
  66945. type: InspectableType;
  66946. /**
  66947. * Gets the minimum value of the property when using in "slider" mode
  66948. */
  66949. min?: number;
  66950. /**
  66951. * Gets the maximum value of the property when using in "slider" mode
  66952. */
  66953. max?: number;
  66954. /**
  66955. * Gets the setp to use when using in "slider" mode
  66956. */
  66957. step?: number;
  66958. }
  66959. }
  66960. declare module BABYLON {
  66961. /**
  66962. * Class for creating a cube texture
  66963. */
  66964. export class CubeTexture extends BaseTexture {
  66965. private _delayedOnLoad;
  66966. /**
  66967. * The url of the texture
  66968. */
  66969. url: string;
  66970. /**
  66971. * Gets or sets the center of the bounding box associated with the cube texture.
  66972. * It must define where the camera used to render the texture was set
  66973. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66974. */
  66975. boundingBoxPosition: Vector3;
  66976. private _boundingBoxSize;
  66977. /**
  66978. * Gets or sets the size of the bounding box associated with the cube texture
  66979. * When defined, the cubemap will switch to local mode
  66980. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66981. * @example https://www.babylonjs-playground.com/#RNASML
  66982. */
  66983. /**
  66984. * Returns the bounding box size
  66985. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66986. */
  66987. boundingBoxSize: Vector3;
  66988. protected _rotationY: number;
  66989. /**
  66990. * Sets texture matrix rotation angle around Y axis in radians.
  66991. */
  66992. /**
  66993. * Gets texture matrix rotation angle around Y axis radians.
  66994. */
  66995. rotationY: number;
  66996. /**
  66997. * Are mip maps generated for this texture or not.
  66998. */
  66999. readonly noMipmap: boolean;
  67000. private _noMipmap;
  67001. private _files;
  67002. private _extensions;
  67003. private _textureMatrix;
  67004. private _format;
  67005. private _createPolynomials;
  67006. /** @hidden */
  67007. _prefiltered: boolean;
  67008. /**
  67009. * Creates a cube texture from an array of image urls
  67010. * @param files defines an array of image urls
  67011. * @param scene defines the hosting scene
  67012. * @param noMipmap specifies if mip maps are not used
  67013. * @returns a cube texture
  67014. */
  67015. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67016. /**
  67017. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67018. * @param url defines the url of the prefiltered texture
  67019. * @param scene defines the scene the texture is attached to
  67020. * @param forcedExtension defines the extension of the file if different from the url
  67021. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67022. * @return the prefiltered texture
  67023. */
  67024. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67025. /**
  67026. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67027. * as prefiltered data.
  67028. * @param rootUrl defines the url of the texture or the root name of the six images
  67029. * @param scene defines the scene the texture is attached to
  67030. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67031. * @param noMipmap defines if mipmaps should be created or not
  67032. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67033. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67034. * @param onError defines a callback triggered in case of error during load
  67035. * @param format defines the internal format to use for the texture once loaded
  67036. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67037. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67038. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67039. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67040. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67041. * @return the cube texture
  67042. */
  67043. 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);
  67044. /**
  67045. * Get the current class name of the texture useful for serialization or dynamic coding.
  67046. * @returns "CubeTexture"
  67047. */
  67048. getClassName(): string;
  67049. /**
  67050. * Update the url (and optional buffer) of this texture if url was null during construction.
  67051. * @param url the url of the texture
  67052. * @param forcedExtension defines the extension to use
  67053. * @param onLoad callback called when the texture is loaded (defaults to null)
  67054. */
  67055. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67056. /**
  67057. * Delays loading of the cube texture
  67058. * @param forcedExtension defines the extension to use
  67059. */
  67060. delayLoad(forcedExtension?: string): void;
  67061. /**
  67062. * Returns the reflection texture matrix
  67063. * @returns the reflection texture matrix
  67064. */
  67065. getReflectionTextureMatrix(): Matrix;
  67066. /**
  67067. * Sets the reflection texture matrix
  67068. * @param value Reflection texture matrix
  67069. */
  67070. setReflectionTextureMatrix(value: Matrix): void;
  67071. /**
  67072. * Parses text to create a cube texture
  67073. * @param parsedTexture define the serialized text to read from
  67074. * @param scene defines the hosting scene
  67075. * @param rootUrl defines the root url of the cube texture
  67076. * @returns a cube texture
  67077. */
  67078. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67079. /**
  67080. * Makes a clone, or deep copy, of the cube texture
  67081. * @returns a new cube texture
  67082. */
  67083. clone(): CubeTexture;
  67084. }
  67085. }
  67086. declare module BABYLON {
  67087. /** @hidden */
  67088. export var postprocessVertexShader: {
  67089. name: string;
  67090. shader: string;
  67091. };
  67092. }
  67093. declare module BABYLON {
  67094. /**
  67095. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67096. * This is the base of the follow, arc rotate cameras and Free camera
  67097. * @see http://doc.babylonjs.com/features/cameras
  67098. */
  67099. export class TargetCamera extends Camera {
  67100. private static _RigCamTransformMatrix;
  67101. private static _TargetTransformMatrix;
  67102. private static _TargetFocalPoint;
  67103. /**
  67104. * Define the current direction the camera is moving to
  67105. */
  67106. cameraDirection: Vector3;
  67107. /**
  67108. * Define the current rotation the camera is rotating to
  67109. */
  67110. cameraRotation: Vector2;
  67111. /**
  67112. * When set, the up vector of the camera will be updated by the rotation of the camera
  67113. */
  67114. updateUpVectorFromRotation: boolean;
  67115. private _tmpQuaternion;
  67116. /**
  67117. * Define the current rotation of the camera
  67118. */
  67119. rotation: Vector3;
  67120. /**
  67121. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67122. */
  67123. rotationQuaternion: Quaternion;
  67124. /**
  67125. * Define the current speed of the camera
  67126. */
  67127. speed: number;
  67128. /**
  67129. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67130. * around all axis.
  67131. */
  67132. noRotationConstraint: boolean;
  67133. /**
  67134. * Define the current target of the camera as an object or a position.
  67135. */
  67136. lockedTarget: any;
  67137. /** @hidden */
  67138. _currentTarget: Vector3;
  67139. /** @hidden */
  67140. _initialFocalDistance: number;
  67141. /** @hidden */
  67142. _viewMatrix: Matrix;
  67143. /** @hidden */
  67144. _camMatrix: Matrix;
  67145. /** @hidden */
  67146. _cameraTransformMatrix: Matrix;
  67147. /** @hidden */
  67148. _cameraRotationMatrix: Matrix;
  67149. /** @hidden */
  67150. _referencePoint: Vector3;
  67151. /** @hidden */
  67152. _transformedReferencePoint: Vector3;
  67153. protected _globalCurrentTarget: Vector3;
  67154. protected _globalCurrentUpVector: Vector3;
  67155. /** @hidden */
  67156. _reset: () => void;
  67157. private _defaultUp;
  67158. /**
  67159. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67160. * This is the base of the follow, arc rotate cameras and Free camera
  67161. * @see http://doc.babylonjs.com/features/cameras
  67162. * @param name Defines the name of the camera in the scene
  67163. * @param position Defines the start position of the camera in the scene
  67164. * @param scene Defines the scene the camera belongs to
  67165. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67166. */
  67167. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67168. /**
  67169. * Gets the position in front of the camera at a given distance.
  67170. * @param distance The distance from the camera we want the position to be
  67171. * @returns the position
  67172. */
  67173. getFrontPosition(distance: number): Vector3;
  67174. /** @hidden */
  67175. _getLockedTargetPosition(): Nullable<Vector3>;
  67176. private _storedPosition;
  67177. private _storedRotation;
  67178. private _storedRotationQuaternion;
  67179. /**
  67180. * Store current camera state of the camera (fov, position, rotation, etc..)
  67181. * @returns the camera
  67182. */
  67183. storeState(): Camera;
  67184. /**
  67185. * Restored camera state. You must call storeState() first
  67186. * @returns whether it was successful or not
  67187. * @hidden
  67188. */
  67189. _restoreStateValues(): boolean;
  67190. /** @hidden */
  67191. _initCache(): void;
  67192. /** @hidden */
  67193. _updateCache(ignoreParentClass?: boolean): void;
  67194. /** @hidden */
  67195. _isSynchronizedViewMatrix(): boolean;
  67196. /** @hidden */
  67197. _computeLocalCameraSpeed(): number;
  67198. /**
  67199. * Defines the target the camera should look at.
  67200. * This will automatically adapt alpha beta and radius to fit within the new target.
  67201. * @param target Defines the new target as a Vector or a mesh
  67202. */
  67203. setTarget(target: Vector3): void;
  67204. /**
  67205. * Return the current target position of the camera. This value is expressed in local space.
  67206. * @returns the target position
  67207. */
  67208. getTarget(): Vector3;
  67209. /** @hidden */
  67210. _decideIfNeedsToMove(): boolean;
  67211. /** @hidden */
  67212. _updatePosition(): void;
  67213. /** @hidden */
  67214. _checkInputs(): void;
  67215. protected _updateCameraRotationMatrix(): void;
  67216. /**
  67217. * 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)
  67218. * @returns the current camera
  67219. */
  67220. private _rotateUpVectorWithCameraRotationMatrix;
  67221. private _cachedRotationZ;
  67222. private _cachedQuaternionRotationZ;
  67223. /** @hidden */
  67224. _getViewMatrix(): Matrix;
  67225. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67226. /**
  67227. * @hidden
  67228. */
  67229. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67230. /**
  67231. * @hidden
  67232. */
  67233. _updateRigCameras(): void;
  67234. private _getRigCamPositionAndTarget;
  67235. /**
  67236. * Gets the current object class name.
  67237. * @return the class name
  67238. */
  67239. getClassName(): string;
  67240. }
  67241. }
  67242. declare module BABYLON {
  67243. /**
  67244. * @ignore
  67245. * This is a list of all the different input types that are available in the application.
  67246. * Fo instance: ArcRotateCameraGamepadInput...
  67247. */
  67248. export var CameraInputTypes: {};
  67249. /**
  67250. * This is the contract to implement in order to create a new input class.
  67251. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67252. */
  67253. export interface ICameraInput<TCamera extends Camera> {
  67254. /**
  67255. * Defines the camera the input is attached to.
  67256. */
  67257. camera: Nullable<TCamera>;
  67258. /**
  67259. * Gets the class name of the current intput.
  67260. * @returns the class name
  67261. */
  67262. getClassName(): string;
  67263. /**
  67264. * Get the friendly name associated with the input class.
  67265. * @returns the input friendly name
  67266. */
  67267. getSimpleName(): string;
  67268. /**
  67269. * Attach the input controls to a specific dom element to get the input from.
  67270. * @param element Defines the element the controls should be listened from
  67271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67272. */
  67273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67274. /**
  67275. * Detach the current controls from the specified dom element.
  67276. * @param element Defines the element to stop listening the inputs from
  67277. */
  67278. detachControl(element: Nullable<HTMLElement>): void;
  67279. /**
  67280. * Update the current camera state depending on the inputs that have been used this frame.
  67281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67282. */
  67283. checkInputs?: () => void;
  67284. }
  67285. /**
  67286. * Represents a map of input types to input instance or input index to input instance.
  67287. */
  67288. export interface CameraInputsMap<TCamera extends Camera> {
  67289. /**
  67290. * Accessor to the input by input type.
  67291. */
  67292. [name: string]: ICameraInput<TCamera>;
  67293. /**
  67294. * Accessor to the input by input index.
  67295. */
  67296. [idx: number]: ICameraInput<TCamera>;
  67297. }
  67298. /**
  67299. * This represents the input manager used within a camera.
  67300. * It helps dealing with all the different kind of input attached to a camera.
  67301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67302. */
  67303. export class CameraInputsManager<TCamera extends Camera> {
  67304. /**
  67305. * Defines the list of inputs attahed to the camera.
  67306. */
  67307. attached: CameraInputsMap<TCamera>;
  67308. /**
  67309. * Defines the dom element the camera is collecting inputs from.
  67310. * This is null if the controls have not been attached.
  67311. */
  67312. attachedElement: Nullable<HTMLElement>;
  67313. /**
  67314. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67315. */
  67316. noPreventDefault: boolean;
  67317. /**
  67318. * Defined the camera the input manager belongs to.
  67319. */
  67320. camera: TCamera;
  67321. /**
  67322. * Update the current camera state depending on the inputs that have been used this frame.
  67323. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67324. */
  67325. checkInputs: () => void;
  67326. /**
  67327. * Instantiate a new Camera Input Manager.
  67328. * @param camera Defines the camera the input manager blongs to
  67329. */
  67330. constructor(camera: TCamera);
  67331. /**
  67332. * Add an input method to a camera
  67333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67334. * @param input camera input method
  67335. */
  67336. add(input: ICameraInput<TCamera>): void;
  67337. /**
  67338. * Remove a specific input method from a camera
  67339. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67340. * @param inputToRemove camera input method
  67341. */
  67342. remove(inputToRemove: ICameraInput<TCamera>): void;
  67343. /**
  67344. * Remove a specific input type from a camera
  67345. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67346. * @param inputType the type of the input to remove
  67347. */
  67348. removeByType(inputType: string): void;
  67349. private _addCheckInputs;
  67350. /**
  67351. * Attach the input controls to the currently attached dom element to listen the events from.
  67352. * @param input Defines the input to attach
  67353. */
  67354. attachInput(input: ICameraInput<TCamera>): void;
  67355. /**
  67356. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67357. * @param element Defines the dom element to collect the events from
  67358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67359. */
  67360. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67361. /**
  67362. * Detach the current manager inputs controls from a specific dom element.
  67363. * @param element Defines the dom element to collect the events from
  67364. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67365. */
  67366. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67367. /**
  67368. * Rebuild the dynamic inputCheck function from the current list of
  67369. * defined inputs in the manager.
  67370. */
  67371. rebuildInputCheck(): void;
  67372. /**
  67373. * Remove all attached input methods from a camera
  67374. */
  67375. clear(): void;
  67376. /**
  67377. * Serialize the current input manager attached to a camera.
  67378. * This ensures than once parsed,
  67379. * the input associated to the camera will be identical to the current ones
  67380. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67381. */
  67382. serialize(serializedCamera: any): void;
  67383. /**
  67384. * Parses an input manager serialized JSON to restore the previous list of inputs
  67385. * and states associated to a camera.
  67386. * @param parsedCamera Defines the JSON to parse
  67387. */
  67388. parse(parsedCamera: any): void;
  67389. }
  67390. }
  67391. declare module BABYLON {
  67392. /**
  67393. * Gather the list of keyboard event types as constants.
  67394. */
  67395. export class KeyboardEventTypes {
  67396. /**
  67397. * The keydown event is fired when a key becomes active (pressed).
  67398. */
  67399. static readonly KEYDOWN: number;
  67400. /**
  67401. * The keyup event is fired when a key has been released.
  67402. */
  67403. static readonly KEYUP: number;
  67404. }
  67405. /**
  67406. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67407. */
  67408. export class KeyboardInfo {
  67409. /**
  67410. * Defines the type of event (KeyboardEventTypes)
  67411. */
  67412. type: number;
  67413. /**
  67414. * Defines the related dom event
  67415. */
  67416. event: KeyboardEvent;
  67417. /**
  67418. * Instantiates a new keyboard info.
  67419. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67420. * @param type Defines the type of event (KeyboardEventTypes)
  67421. * @param event Defines the related dom event
  67422. */
  67423. constructor(
  67424. /**
  67425. * Defines the type of event (KeyboardEventTypes)
  67426. */
  67427. type: number,
  67428. /**
  67429. * Defines the related dom event
  67430. */
  67431. event: KeyboardEvent);
  67432. }
  67433. /**
  67434. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67435. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67436. */
  67437. export class KeyboardInfoPre extends KeyboardInfo {
  67438. /**
  67439. * Defines the type of event (KeyboardEventTypes)
  67440. */
  67441. type: number;
  67442. /**
  67443. * Defines the related dom event
  67444. */
  67445. event: KeyboardEvent;
  67446. /**
  67447. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67448. */
  67449. skipOnPointerObservable: boolean;
  67450. /**
  67451. * Instantiates a new keyboard pre info.
  67452. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67453. * @param type Defines the type of event (KeyboardEventTypes)
  67454. * @param event Defines the related dom event
  67455. */
  67456. constructor(
  67457. /**
  67458. * Defines the type of event (KeyboardEventTypes)
  67459. */
  67460. type: number,
  67461. /**
  67462. * Defines the related dom event
  67463. */
  67464. event: KeyboardEvent);
  67465. }
  67466. }
  67467. declare module BABYLON {
  67468. /**
  67469. * Manage the keyboard inputs to control the movement of a free camera.
  67470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67471. */
  67472. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67473. /**
  67474. * Defines the camera the input is attached to.
  67475. */
  67476. camera: FreeCamera;
  67477. /**
  67478. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67479. */
  67480. keysUp: number[];
  67481. /**
  67482. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67483. */
  67484. keysDown: number[];
  67485. /**
  67486. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67487. */
  67488. keysLeft: number[];
  67489. /**
  67490. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67491. */
  67492. keysRight: number[];
  67493. private _keys;
  67494. private _onCanvasBlurObserver;
  67495. private _onKeyboardObserver;
  67496. private _engine;
  67497. private _scene;
  67498. /**
  67499. * Attach the input controls to a specific dom element to get the input from.
  67500. * @param element Defines the element the controls should be listened from
  67501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67502. */
  67503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67504. /**
  67505. * Detach the current controls from the specified dom element.
  67506. * @param element Defines the element to stop listening the inputs from
  67507. */
  67508. detachControl(element: Nullable<HTMLElement>): void;
  67509. /**
  67510. * Update the current camera state depending on the inputs that have been used this frame.
  67511. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67512. */
  67513. checkInputs(): void;
  67514. /**
  67515. * Gets the class name of the current intput.
  67516. * @returns the class name
  67517. */
  67518. getClassName(): string;
  67519. /** @hidden */
  67520. _onLostFocus(): void;
  67521. /**
  67522. * Get the friendly name associated with the input class.
  67523. * @returns the input friendly name
  67524. */
  67525. getSimpleName(): string;
  67526. }
  67527. }
  67528. declare module BABYLON {
  67529. /**
  67530. * Interface describing all the common properties and methods a shadow light needs to implement.
  67531. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67532. * as well as binding the different shadow properties to the effects.
  67533. */
  67534. export interface IShadowLight extends Light {
  67535. /**
  67536. * The light id in the scene (used in scene.findLighById for instance)
  67537. */
  67538. id: string;
  67539. /**
  67540. * The position the shdow will be casted from.
  67541. */
  67542. position: Vector3;
  67543. /**
  67544. * In 2d mode (needCube being false), the direction used to cast the shadow.
  67545. */
  67546. direction: Vector3;
  67547. /**
  67548. * The transformed position. Position of the light in world space taking parenting in account.
  67549. */
  67550. transformedPosition: Vector3;
  67551. /**
  67552. * The transformed direction. Direction of the light in world space taking parenting in account.
  67553. */
  67554. transformedDirection: Vector3;
  67555. /**
  67556. * The friendly name of the light in the scene.
  67557. */
  67558. name: string;
  67559. /**
  67560. * Defines the shadow projection clipping minimum z value.
  67561. */
  67562. shadowMinZ: number;
  67563. /**
  67564. * Defines the shadow projection clipping maximum z value.
  67565. */
  67566. shadowMaxZ: number;
  67567. /**
  67568. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67569. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67570. */
  67571. computeTransformedInformation(): boolean;
  67572. /**
  67573. * Gets the scene the light belongs to.
  67574. * @returns The scene
  67575. */
  67576. getScene(): Scene;
  67577. /**
  67578. * Callback defining a custom Projection Matrix Builder.
  67579. * This can be used to override the default projection matrix computation.
  67580. */
  67581. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67582. /**
  67583. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67584. * @param matrix The materix to updated with the projection information
  67585. * @param viewMatrix The transform matrix of the light
  67586. * @param renderList The list of mesh to render in the map
  67587. * @returns The current light
  67588. */
  67589. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67590. /**
  67591. * Gets the current depth scale used in ESM.
  67592. * @returns The scale
  67593. */
  67594. getDepthScale(): number;
  67595. /**
  67596. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67597. * @returns true if a cube texture needs to be use
  67598. */
  67599. needCube(): boolean;
  67600. /**
  67601. * Detects if the projection matrix requires to be recomputed this frame.
  67602. * @returns true if it requires to be recomputed otherwise, false.
  67603. */
  67604. needProjectionMatrixCompute(): boolean;
  67605. /**
  67606. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67607. */
  67608. forceProjectionMatrixCompute(): void;
  67609. /**
  67610. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67611. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67612. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67613. */
  67614. getShadowDirection(faceIndex?: number): Vector3;
  67615. /**
  67616. * Gets the minZ used for shadow according to both the scene and the light.
  67617. * @param activeCamera The camera we are returning the min for
  67618. * @returns the depth min z
  67619. */
  67620. getDepthMinZ(activeCamera: Camera): number;
  67621. /**
  67622. * Gets the maxZ used for shadow according to both the scene and the light.
  67623. * @param activeCamera The camera we are returning the max for
  67624. * @returns the depth max z
  67625. */
  67626. getDepthMaxZ(activeCamera: Camera): number;
  67627. }
  67628. /**
  67629. * Base implementation IShadowLight
  67630. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  67631. */
  67632. export abstract class ShadowLight extends Light implements IShadowLight {
  67633. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67634. protected _position: Vector3;
  67635. protected _setPosition(value: Vector3): void;
  67636. /**
  67637. * Sets the position the shadow will be casted from. Also use as the light position for both
  67638. * point and spot lights.
  67639. */
  67640. /**
  67641. * Sets the position the shadow will be casted from. Also use as the light position for both
  67642. * point and spot lights.
  67643. */
  67644. position: Vector3;
  67645. protected _direction: Vector3;
  67646. protected _setDirection(value: Vector3): void;
  67647. /**
  67648. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  67649. * Also use as the light direction on spot and directional lights.
  67650. */
  67651. /**
  67652. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  67653. * Also use as the light direction on spot and directional lights.
  67654. */
  67655. direction: Vector3;
  67656. private _shadowMinZ;
  67657. /**
  67658. * Gets the shadow projection clipping minimum z value.
  67659. */
  67660. /**
  67661. * Sets the shadow projection clipping minimum z value.
  67662. */
  67663. shadowMinZ: number;
  67664. private _shadowMaxZ;
  67665. /**
  67666. * Sets the shadow projection clipping maximum z value.
  67667. */
  67668. /**
  67669. * Gets the shadow projection clipping maximum z value.
  67670. */
  67671. shadowMaxZ: number;
  67672. /**
  67673. * Callback defining a custom Projection Matrix Builder.
  67674. * This can be used to override the default projection matrix computation.
  67675. */
  67676. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67677. /**
  67678. * The transformed position. Position of the light in world space taking parenting in account.
  67679. */
  67680. transformedPosition: Vector3;
  67681. /**
  67682. * The transformed direction. Direction of the light in world space taking parenting in account.
  67683. */
  67684. transformedDirection: Vector3;
  67685. private _needProjectionMatrixCompute;
  67686. /**
  67687. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67688. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67689. */
  67690. computeTransformedInformation(): boolean;
  67691. /**
  67692. * Return the depth scale used for the shadow map.
  67693. * @returns the depth scale.
  67694. */
  67695. getDepthScale(): number;
  67696. /**
  67697. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67698. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67699. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67700. */
  67701. getShadowDirection(faceIndex?: number): Vector3;
  67702. /**
  67703. * Returns the ShadowLight absolute position in the World.
  67704. * @returns the position vector in world space
  67705. */
  67706. getAbsolutePosition(): Vector3;
  67707. /**
  67708. * Sets the ShadowLight direction toward the passed target.
  67709. * @param target The point to target in local space
  67710. * @returns the updated ShadowLight direction
  67711. */
  67712. setDirectionToTarget(target: Vector3): Vector3;
  67713. /**
  67714. * Returns the light rotation in euler definition.
  67715. * @returns the x y z rotation in local space.
  67716. */
  67717. getRotation(): Vector3;
  67718. /**
  67719. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67720. * @returns true if a cube texture needs to be use
  67721. */
  67722. needCube(): boolean;
  67723. /**
  67724. * Detects if the projection matrix requires to be recomputed this frame.
  67725. * @returns true if it requires to be recomputed otherwise, false.
  67726. */
  67727. needProjectionMatrixCompute(): boolean;
  67728. /**
  67729. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67730. */
  67731. forceProjectionMatrixCompute(): void;
  67732. /** @hidden */
  67733. _initCache(): void;
  67734. /** @hidden */
  67735. _isSynchronized(): boolean;
  67736. /**
  67737. * Computes the world matrix of the node
  67738. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67739. * @returns the world matrix
  67740. */
  67741. computeWorldMatrix(force?: boolean): Matrix;
  67742. /**
  67743. * Gets the minZ used for shadow according to both the scene and the light.
  67744. * @param activeCamera The camera we are returning the min for
  67745. * @returns the depth min z
  67746. */
  67747. getDepthMinZ(activeCamera: Camera): number;
  67748. /**
  67749. * Gets the maxZ used for shadow according to both the scene and the light.
  67750. * @param activeCamera The camera we are returning the max for
  67751. * @returns the depth max z
  67752. */
  67753. getDepthMaxZ(activeCamera: Camera): number;
  67754. /**
  67755. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67756. * @param matrix The materix to updated with the projection information
  67757. * @param viewMatrix The transform matrix of the light
  67758. * @param renderList The list of mesh to render in the map
  67759. * @returns The current light
  67760. */
  67761. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67762. }
  67763. }
  67764. declare module BABYLON {
  67765. /**
  67766. * "Static Class" containing the most commonly used helper while dealing with material for
  67767. * rendering purpose.
  67768. *
  67769. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67770. *
  67771. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67772. */
  67773. export class MaterialHelper {
  67774. /**
  67775. * Bind the current view position to an effect.
  67776. * @param effect The effect to be bound
  67777. * @param scene The scene the eyes position is used from
  67778. */
  67779. static BindEyePosition(effect: Effect, scene: Scene): void;
  67780. /**
  67781. * Helps preparing the defines values about the UVs in used in the effect.
  67782. * UVs are shared as much as we can accross channels in the shaders.
  67783. * @param texture The texture we are preparing the UVs for
  67784. * @param defines The defines to update
  67785. * @param key The channel key "diffuse", "specular"... used in the shader
  67786. */
  67787. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  67788. /**
  67789. * Binds a texture matrix value to its corrsponding uniform
  67790. * @param texture The texture to bind the matrix for
  67791. * @param uniformBuffer The uniform buffer receivin the data
  67792. * @param key The channel key "diffuse", "specular"... used in the shader
  67793. */
  67794. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  67795. /**
  67796. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67797. * @param mesh defines the current mesh
  67798. * @param scene defines the current scene
  67799. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67800. * @param pointsCloud defines if point cloud rendering has to be turned on
  67801. * @param fogEnabled defines if fog has to be turned on
  67802. * @param alphaTest defines if alpha testing has to be turned on
  67803. * @param defines defines the current list of defines
  67804. */
  67805. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  67806. /**
  67807. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67808. * @param scene defines the current scene
  67809. * @param engine defines the current engine
  67810. * @param defines specifies the list of active defines
  67811. * @param useInstances defines if instances have to be turned on
  67812. * @param useClipPlane defines if clip plane have to be turned on
  67813. */
  67814. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67815. /**
  67816. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67817. * @param mesh The mesh containing the geometry data we will draw
  67818. * @param defines The defines to update
  67819. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67820. * @param useBones Precise whether bones should be used or not (override mesh info)
  67821. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67822. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67823. * @returns false if defines are considered not dirty and have not been checked
  67824. */
  67825. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67826. /**
  67827. * Prepares the defines related to the light information passed in parameter
  67828. * @param scene The scene we are intending to draw
  67829. * @param mesh The mesh the effect is compiling for
  67830. * @param defines The defines to update
  67831. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67832. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67833. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67834. * @returns true if normals will be required for the rest of the effect
  67835. */
  67836. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67837. /**
  67838. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67839. * that won t be acctive due to defines being turned off.
  67840. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67841. * @param samplersList The samplers list
  67842. * @param defines The defines helping in the list generation
  67843. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67844. */
  67845. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67846. /**
  67847. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67848. * @param defines The defines to update while falling back
  67849. * @param fallbacks The authorized effect fallbacks
  67850. * @param maxSimultaneousLights The maximum number of lights allowed
  67851. * @param rank the current rank of the Effect
  67852. * @returns The newly affected rank
  67853. */
  67854. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67855. /**
  67856. * Prepares the list of attributes required for morph targets according to the effect defines.
  67857. * @param attribs The current list of supported attribs
  67858. * @param mesh The mesh to prepare the morph targets attributes for
  67859. * @param defines The current Defines of the effect
  67860. */
  67861. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67862. /**
  67863. * Prepares the list of attributes required for bones according to the effect defines.
  67864. * @param attribs The current list of supported attribs
  67865. * @param mesh The mesh to prepare the bones attributes for
  67866. * @param defines The current Defines of the effect
  67867. * @param fallbacks The current efffect fallback strategy
  67868. */
  67869. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67870. /**
  67871. * Prepares the list of attributes required for instances according to the effect defines.
  67872. * @param attribs The current list of supported attribs
  67873. * @param defines The current Defines of the effect
  67874. */
  67875. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67876. /**
  67877. * Binds the light shadow information to the effect for the given mesh.
  67878. * @param light The light containing the generator
  67879. * @param scene The scene the lights belongs to
  67880. * @param mesh The mesh we are binding the information to render
  67881. * @param lightIndex The light index in the effect used to render the mesh
  67882. * @param effect The effect we are binding the data to
  67883. */
  67884. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67885. /**
  67886. * Binds the light information to the effect.
  67887. * @param light The light containing the generator
  67888. * @param effect The effect we are binding the data to
  67889. * @param lightIndex The light index in the effect used to render
  67890. */
  67891. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67892. /**
  67893. * Binds the lights information from the scene to the effect for the given mesh.
  67894. * @param scene The scene the lights belongs to
  67895. * @param mesh The mesh we are binding the information to render
  67896. * @param effect The effect we are binding the data to
  67897. * @param defines The generated defines for the effect
  67898. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67899. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67900. */
  67901. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67902. private static _tempFogColor;
  67903. /**
  67904. * Binds the fog information from the scene to the effect for the given mesh.
  67905. * @param scene The scene the lights belongs to
  67906. * @param mesh The mesh we are binding the information to render
  67907. * @param effect The effect we are binding the data to
  67908. * @param linearSpace Defines if the fog effect is applied in linear space
  67909. */
  67910. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67911. /**
  67912. * Binds the bones information from the mesh to the effect.
  67913. * @param mesh The mesh we are binding the information to render
  67914. * @param effect The effect we are binding the data to
  67915. */
  67916. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67917. /**
  67918. * Binds the morph targets information from the mesh to the effect.
  67919. * @param abstractMesh The mesh we are binding the information to render
  67920. * @param effect The effect we are binding the data to
  67921. */
  67922. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67923. /**
  67924. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67925. * @param defines The generated defines used in the effect
  67926. * @param effect The effect we are binding the data to
  67927. * @param scene The scene we are willing to render with logarithmic scale for
  67928. */
  67929. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67930. /**
  67931. * Binds the clip plane information from the scene to the effect.
  67932. * @param scene The scene the clip plane information are extracted from
  67933. * @param effect The effect we are binding the data to
  67934. */
  67935. static BindClipPlane(effect: Effect, scene: Scene): void;
  67936. }
  67937. }
  67938. declare module BABYLON {
  67939. /** @hidden */
  67940. export var kernelBlurVaryingDeclaration: {
  67941. name: string;
  67942. shader: string;
  67943. };
  67944. }
  67945. declare module BABYLON {
  67946. /** @hidden */
  67947. export var kernelBlurFragment: {
  67948. name: string;
  67949. shader: string;
  67950. };
  67951. }
  67952. declare module BABYLON {
  67953. /** @hidden */
  67954. export var kernelBlurFragment2: {
  67955. name: string;
  67956. shader: string;
  67957. };
  67958. }
  67959. declare module BABYLON {
  67960. /** @hidden */
  67961. export var kernelBlurPixelShader: {
  67962. name: string;
  67963. shader: string;
  67964. };
  67965. }
  67966. declare module BABYLON {
  67967. /** @hidden */
  67968. export var kernelBlurVertex: {
  67969. name: string;
  67970. shader: string;
  67971. };
  67972. }
  67973. declare module BABYLON {
  67974. /** @hidden */
  67975. export var kernelBlurVertexShader: {
  67976. name: string;
  67977. shader: string;
  67978. };
  67979. }
  67980. declare module BABYLON {
  67981. /**
  67982. * The Blur Post Process which blurs an image based on a kernel and direction.
  67983. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67984. */
  67985. export class BlurPostProcess extends PostProcess {
  67986. /** The direction in which to blur the image. */
  67987. direction: Vector2;
  67988. private blockCompilation;
  67989. protected _kernel: number;
  67990. protected _idealKernel: number;
  67991. protected _packedFloat: boolean;
  67992. private _staticDefines;
  67993. /**
  67994. * Sets the length in pixels of the blur sample region
  67995. */
  67996. /**
  67997. * Gets the length in pixels of the blur sample region
  67998. */
  67999. kernel: number;
  68000. /**
  68001. * Sets wether or not the blur needs to unpack/repack floats
  68002. */
  68003. /**
  68004. * Gets wether or not the blur is unpacking/repacking floats
  68005. */
  68006. packedFloat: boolean;
  68007. /**
  68008. * Creates a new instance BlurPostProcess
  68009. * @param name The name of the effect.
  68010. * @param direction The direction in which to blur the image.
  68011. * @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.
  68012. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68013. * @param camera The camera to apply the render pass to.
  68014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68015. * @param engine The engine which the post process will be applied. (default: current engine)
  68016. * @param reusable If the post process can be reused on the same frame. (default: false)
  68017. * @param textureType Type of textures used when performing the post process. (default: 0)
  68018. * @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)
  68019. */
  68020. constructor(name: string,
  68021. /** The direction in which to blur the image. */
  68022. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68023. /**
  68024. * Updates the effect with the current post process compile time values and recompiles the shader.
  68025. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68026. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68027. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68028. * @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
  68029. * @param onCompiled Called when the shader has been compiled.
  68030. * @param onError Called if there is an error when compiling a shader.
  68031. */
  68032. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68033. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68034. /**
  68035. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68036. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68037. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68038. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68039. * The gaps between physical kernels are compensated for in the weighting of the samples
  68040. * @param idealKernel Ideal blur kernel.
  68041. * @return Nearest best kernel.
  68042. */
  68043. protected _nearestBestKernel(idealKernel: number): number;
  68044. /**
  68045. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68046. * @param x The point on the Gaussian distribution to sample.
  68047. * @return the value of the Gaussian function at x.
  68048. */
  68049. protected _gaussianWeight(x: number): number;
  68050. /**
  68051. * Generates a string that can be used as a floating point number in GLSL.
  68052. * @param x Value to print.
  68053. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68054. * @return GLSL float string.
  68055. */
  68056. protected _glslFloat(x: number, decimalFigures?: number): string;
  68057. }
  68058. }
  68059. declare module BABYLON {
  68060. /** @hidden */
  68061. export var shadowMapPixelShader: {
  68062. name: string;
  68063. shader: string;
  68064. };
  68065. }
  68066. declare module BABYLON {
  68067. /** @hidden */
  68068. export var bonesDeclaration: {
  68069. name: string;
  68070. shader: string;
  68071. };
  68072. }
  68073. declare module BABYLON {
  68074. /** @hidden */
  68075. export var morphTargetsVertexGlobalDeclaration: {
  68076. name: string;
  68077. shader: string;
  68078. };
  68079. }
  68080. declare module BABYLON {
  68081. /** @hidden */
  68082. export var morphTargetsVertexDeclaration: {
  68083. name: string;
  68084. shader: string;
  68085. };
  68086. }
  68087. declare module BABYLON {
  68088. /** @hidden */
  68089. export var instancesDeclaration: {
  68090. name: string;
  68091. shader: string;
  68092. };
  68093. }
  68094. declare module BABYLON {
  68095. /** @hidden */
  68096. export var helperFunctions: {
  68097. name: string;
  68098. shader: string;
  68099. };
  68100. }
  68101. declare module BABYLON {
  68102. /** @hidden */
  68103. export var morphTargetsVertex: {
  68104. name: string;
  68105. shader: string;
  68106. };
  68107. }
  68108. declare module BABYLON {
  68109. /** @hidden */
  68110. export var instancesVertex: {
  68111. name: string;
  68112. shader: string;
  68113. };
  68114. }
  68115. declare module BABYLON {
  68116. /** @hidden */
  68117. export var bonesVertex: {
  68118. name: string;
  68119. shader: string;
  68120. };
  68121. }
  68122. declare module BABYLON {
  68123. /** @hidden */
  68124. export var shadowMapVertexShader: {
  68125. name: string;
  68126. shader: string;
  68127. };
  68128. }
  68129. declare module BABYLON {
  68130. /** @hidden */
  68131. export var depthBoxBlurPixelShader: {
  68132. name: string;
  68133. shader: string;
  68134. };
  68135. }
  68136. declare module BABYLON {
  68137. /**
  68138. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68139. */
  68140. export interface ICustomShaderOptions {
  68141. /**
  68142. * Gets or sets the custom shader name to use
  68143. */
  68144. shaderName: string;
  68145. /**
  68146. * The list of attribute names used in the shader
  68147. */
  68148. attributes?: string[];
  68149. /**
  68150. * The list of unifrom names used in the shader
  68151. */
  68152. uniforms?: string[];
  68153. /**
  68154. * The list of sampler names used in the shader
  68155. */
  68156. samplers?: string[];
  68157. /**
  68158. * The list of defines used in the shader
  68159. */
  68160. defines?: string[];
  68161. }
  68162. /**
  68163. * Interface to implement to create a shadow generator compatible with BJS.
  68164. */
  68165. export interface IShadowGenerator {
  68166. /**
  68167. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68168. * @returns The render target texture if present otherwise, null
  68169. */
  68170. getShadowMap(): Nullable<RenderTargetTexture>;
  68171. /**
  68172. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68173. * @returns The render target texture if the shadow map is present otherwise, null
  68174. */
  68175. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68176. /**
  68177. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68178. * @param subMesh The submesh we want to render in the shadow map
  68179. * @param useInstances Defines wether will draw in the map using instances
  68180. * @returns true if ready otherwise, false
  68181. */
  68182. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68183. /**
  68184. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68185. * @param defines Defines of the material we want to update
  68186. * @param lightIndex Index of the light in the enabled light list of the material
  68187. */
  68188. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68189. /**
  68190. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68191. * defined in the generator but impacting the effect).
  68192. * It implies the unifroms available on the materials are the standard BJS ones.
  68193. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68194. * @param effect The effect we are binfing the information for
  68195. */
  68196. bindShadowLight(lightIndex: string, effect: Effect): void;
  68197. /**
  68198. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68199. * (eq to shadow prjection matrix * light transform matrix)
  68200. * @returns The transform matrix used to create the shadow map
  68201. */
  68202. getTransformMatrix(): Matrix;
  68203. /**
  68204. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68205. * Cube and 2D textures for instance.
  68206. */
  68207. recreateShadowMap(): void;
  68208. /**
  68209. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68210. * @param onCompiled Callback triggered at the and of the effects compilation
  68211. * @param options Sets of optional options forcing the compilation with different modes
  68212. */
  68213. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68214. useInstances: boolean;
  68215. }>): void;
  68216. /**
  68217. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68218. * @param options Sets of optional options forcing the compilation with different modes
  68219. * @returns A promise that resolves when the compilation completes
  68220. */
  68221. forceCompilationAsync(options?: Partial<{
  68222. useInstances: boolean;
  68223. }>): Promise<void>;
  68224. /**
  68225. * Serializes the shadow generator setup to a json object.
  68226. * @returns The serialized JSON object
  68227. */
  68228. serialize(): any;
  68229. /**
  68230. * Disposes the Shadow map and related Textures and effects.
  68231. */
  68232. dispose(): void;
  68233. }
  68234. /**
  68235. * Default implementation IShadowGenerator.
  68236. * This is the main object responsible of generating shadows in the framework.
  68237. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68238. */
  68239. export class ShadowGenerator implements IShadowGenerator {
  68240. /**
  68241. * Shadow generator mode None: no filtering applied.
  68242. */
  68243. static readonly FILTER_NONE: number;
  68244. /**
  68245. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68246. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68247. */
  68248. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68249. /**
  68250. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68251. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68252. */
  68253. static readonly FILTER_POISSONSAMPLING: number;
  68254. /**
  68255. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68256. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68257. */
  68258. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68259. /**
  68260. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68261. * edge artifacts on steep falloff.
  68262. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68263. */
  68264. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68265. /**
  68266. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68267. * edge artifacts on steep falloff.
  68268. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68269. */
  68270. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68271. /**
  68272. * Shadow generator mode PCF: Percentage Closer Filtering
  68273. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68274. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68275. */
  68276. static readonly FILTER_PCF: number;
  68277. /**
  68278. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68279. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68280. * Contact Hardening
  68281. */
  68282. static readonly FILTER_PCSS: number;
  68283. /**
  68284. * Reserved for PCF and PCSS
  68285. * Highest Quality.
  68286. *
  68287. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68288. *
  68289. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68290. */
  68291. static readonly QUALITY_HIGH: number;
  68292. /**
  68293. * Reserved for PCF and PCSS
  68294. * Good tradeoff for quality/perf cross devices
  68295. *
  68296. * Execute PCF on a 3*3 kernel.
  68297. *
  68298. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68299. */
  68300. static readonly QUALITY_MEDIUM: number;
  68301. /**
  68302. * Reserved for PCF and PCSS
  68303. * The lowest quality but the fastest.
  68304. *
  68305. * Execute PCF on a 1*1 kernel.
  68306. *
  68307. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68308. */
  68309. static readonly QUALITY_LOW: number;
  68310. /** Gets or sets the custom shader name to use */
  68311. customShaderOptions: ICustomShaderOptions;
  68312. /**
  68313. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68314. */
  68315. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68316. /**
  68317. * Observable triggered before a mesh is rendered in the shadow map.
  68318. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68319. */
  68320. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68321. private _bias;
  68322. /**
  68323. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68324. */
  68325. /**
  68326. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68327. */
  68328. bias: number;
  68329. private _normalBias;
  68330. /**
  68331. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68332. */
  68333. /**
  68334. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68335. */
  68336. normalBias: number;
  68337. private _blurBoxOffset;
  68338. /**
  68339. * Gets the blur box offset: offset applied during the blur pass.
  68340. * Only useful if useKernelBlur = false
  68341. */
  68342. /**
  68343. * Sets the blur box offset: offset applied during the blur pass.
  68344. * Only useful if useKernelBlur = false
  68345. */
  68346. blurBoxOffset: number;
  68347. private _blurScale;
  68348. /**
  68349. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68350. * 2 means half of the size.
  68351. */
  68352. /**
  68353. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68354. * 2 means half of the size.
  68355. */
  68356. blurScale: number;
  68357. private _blurKernel;
  68358. /**
  68359. * Gets the blur kernel: kernel size of the blur pass.
  68360. * Only useful if useKernelBlur = true
  68361. */
  68362. /**
  68363. * Sets the blur kernel: kernel size of the blur pass.
  68364. * Only useful if useKernelBlur = true
  68365. */
  68366. blurKernel: number;
  68367. private _useKernelBlur;
  68368. /**
  68369. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68370. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68371. */
  68372. /**
  68373. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68374. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68375. */
  68376. useKernelBlur: boolean;
  68377. private _depthScale;
  68378. /**
  68379. * Gets the depth scale used in ESM mode.
  68380. */
  68381. /**
  68382. * Sets the depth scale used in ESM mode.
  68383. * This can override the scale stored on the light.
  68384. */
  68385. depthScale: number;
  68386. private _filter;
  68387. /**
  68388. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68389. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68390. */
  68391. /**
  68392. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68393. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68394. */
  68395. filter: number;
  68396. /**
  68397. * Gets if the current filter is set to Poisson Sampling.
  68398. */
  68399. /**
  68400. * Sets the current filter to Poisson Sampling.
  68401. */
  68402. usePoissonSampling: boolean;
  68403. /**
  68404. * Gets if the current filter is set to ESM.
  68405. */
  68406. /**
  68407. * Sets the current filter is to ESM.
  68408. */
  68409. useExponentialShadowMap: boolean;
  68410. /**
  68411. * Gets if the current filter is set to filtered ESM.
  68412. */
  68413. /**
  68414. * Gets if the current filter is set to filtered ESM.
  68415. */
  68416. useBlurExponentialShadowMap: boolean;
  68417. /**
  68418. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68419. * exponential to prevent steep falloff artifacts).
  68420. */
  68421. /**
  68422. * Sets the current filter to "close ESM" (using the inverse of the
  68423. * exponential to prevent steep falloff artifacts).
  68424. */
  68425. useCloseExponentialShadowMap: boolean;
  68426. /**
  68427. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68428. * exponential to prevent steep falloff artifacts).
  68429. */
  68430. /**
  68431. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68432. * exponential to prevent steep falloff artifacts).
  68433. */
  68434. useBlurCloseExponentialShadowMap: boolean;
  68435. /**
  68436. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68437. */
  68438. /**
  68439. * Sets the current filter to "PCF" (percentage closer filtering).
  68440. */
  68441. usePercentageCloserFiltering: boolean;
  68442. private _filteringQuality;
  68443. /**
  68444. * Gets the PCF or PCSS Quality.
  68445. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68446. */
  68447. /**
  68448. * Sets the PCF or PCSS Quality.
  68449. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68450. */
  68451. filteringQuality: number;
  68452. /**
  68453. * Gets if the current filter is set to "PCSS" (contact hardening).
  68454. */
  68455. /**
  68456. * Sets the current filter to "PCSS" (contact hardening).
  68457. */
  68458. useContactHardeningShadow: boolean;
  68459. private _contactHardeningLightSizeUVRatio;
  68460. /**
  68461. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68462. * Using a ratio helps keeping shape stability independently of the map size.
  68463. *
  68464. * It does not account for the light projection as it was having too much
  68465. * instability during the light setup or during light position changes.
  68466. *
  68467. * Only valid if useContactHardeningShadow is true.
  68468. */
  68469. /**
  68470. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68471. * Using a ratio helps keeping shape stability independently of the map size.
  68472. *
  68473. * It does not account for the light projection as it was having too much
  68474. * instability during the light setup or during light position changes.
  68475. *
  68476. * Only valid if useContactHardeningShadow is true.
  68477. */
  68478. contactHardeningLightSizeUVRatio: number;
  68479. private _darkness;
  68480. /**
  68481. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68482. * 0 means strongest and 1 would means no shadow.
  68483. * @returns the darkness.
  68484. */
  68485. getDarkness(): number;
  68486. /**
  68487. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68488. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68489. * @returns the shadow generator allowing fluent coding.
  68490. */
  68491. setDarkness(darkness: number): ShadowGenerator;
  68492. private _transparencyShadow;
  68493. /**
  68494. * Sets the ability to have transparent shadow (boolean).
  68495. * @param transparent True if transparent else False
  68496. * @returns the shadow generator allowing fluent coding
  68497. */
  68498. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68499. private _shadowMap;
  68500. private _shadowMap2;
  68501. /**
  68502. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68503. * @returns The render target texture if present otherwise, null
  68504. */
  68505. getShadowMap(): Nullable<RenderTargetTexture>;
  68506. /**
  68507. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68508. * @returns The render target texture if the shadow map is present otherwise, null
  68509. */
  68510. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68511. /**
  68512. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68513. * @param mesh Mesh to add
  68514. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68515. * @returns the Shadow Generator itself
  68516. */
  68517. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68518. /**
  68519. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68520. * @param mesh Mesh to remove
  68521. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68522. * @returns the Shadow Generator itself
  68523. */
  68524. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68525. /**
  68526. * Controls the extent to which the shadows fade out at the edge of the frustum
  68527. * Used only by directionals and spots
  68528. */
  68529. frustumEdgeFalloff: number;
  68530. private _light;
  68531. /**
  68532. * Returns the associated light object.
  68533. * @returns the light generating the shadow
  68534. */
  68535. getLight(): IShadowLight;
  68536. /**
  68537. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  68538. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  68539. * It might on the other hand introduce peter panning.
  68540. */
  68541. forceBackFacesOnly: boolean;
  68542. private _scene;
  68543. private _lightDirection;
  68544. private _effect;
  68545. private _viewMatrix;
  68546. private _projectionMatrix;
  68547. private _transformMatrix;
  68548. private _cachedPosition;
  68549. private _cachedDirection;
  68550. private _cachedDefines;
  68551. private _currentRenderID;
  68552. private _boxBlurPostprocess;
  68553. private _kernelBlurXPostprocess;
  68554. private _kernelBlurYPostprocess;
  68555. private _blurPostProcesses;
  68556. private _mapSize;
  68557. private _currentFaceIndex;
  68558. private _currentFaceIndexCache;
  68559. private _textureType;
  68560. private _defaultTextureMatrix;
  68561. /** @hidden */
  68562. static _SceneComponentInitialization: (scene: Scene) => void;
  68563. /**
  68564. * Creates a ShadowGenerator object.
  68565. * A ShadowGenerator is the required tool to use the shadows.
  68566. * Each light casting shadows needs to use its own ShadowGenerator.
  68567. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  68568. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  68569. * @param light The light object generating the shadows.
  68570. * @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.
  68571. */
  68572. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  68573. private _initializeGenerator;
  68574. private _initializeShadowMap;
  68575. private _initializeBlurRTTAndPostProcesses;
  68576. private _renderForShadowMap;
  68577. private _renderSubMeshForShadowMap;
  68578. private _applyFilterValues;
  68579. /**
  68580. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68581. * @param onCompiled Callback triggered at the and of the effects compilation
  68582. * @param options Sets of optional options forcing the compilation with different modes
  68583. */
  68584. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68585. useInstances: boolean;
  68586. }>): void;
  68587. /**
  68588. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68589. * @param options Sets of optional options forcing the compilation with different modes
  68590. * @returns A promise that resolves when the compilation completes
  68591. */
  68592. forceCompilationAsync(options?: Partial<{
  68593. useInstances: boolean;
  68594. }>): Promise<void>;
  68595. /**
  68596. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68597. * @param subMesh The submesh we want to render in the shadow map
  68598. * @param useInstances Defines wether will draw in the map using instances
  68599. * @returns true if ready otherwise, false
  68600. */
  68601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68602. /**
  68603. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68604. * @param defines Defines of the material we want to update
  68605. * @param lightIndex Index of the light in the enabled light list of the material
  68606. */
  68607. prepareDefines(defines: any, lightIndex: number): void;
  68608. /**
  68609. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68610. * defined in the generator but impacting the effect).
  68611. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68612. * @param effect The effect we are binfing the information for
  68613. */
  68614. bindShadowLight(lightIndex: string, effect: Effect): void;
  68615. /**
  68616. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68617. * (eq to shadow prjection matrix * light transform matrix)
  68618. * @returns The transform matrix used to create the shadow map
  68619. */
  68620. getTransformMatrix(): Matrix;
  68621. /**
  68622. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68623. * Cube and 2D textures for instance.
  68624. */
  68625. recreateShadowMap(): void;
  68626. private _disposeBlurPostProcesses;
  68627. private _disposeRTTandPostProcesses;
  68628. /**
  68629. * Disposes the ShadowGenerator.
  68630. * Returns nothing.
  68631. */
  68632. dispose(): void;
  68633. /**
  68634. * Serializes the shadow generator setup to a json object.
  68635. * @returns The serialized JSON object
  68636. */
  68637. serialize(): any;
  68638. /**
  68639. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  68640. * @param parsedShadowGenerator The JSON object to parse
  68641. * @param scene The scene to create the shadow map for
  68642. * @returns The parsed shadow generator
  68643. */
  68644. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  68645. }
  68646. }
  68647. declare module BABYLON {
  68648. /**
  68649. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  68650. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  68651. * 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.
  68652. */
  68653. export abstract class Light extends Node {
  68654. /**
  68655. * Falloff Default: light is falling off following the material specification:
  68656. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  68657. */
  68658. static readonly FALLOFF_DEFAULT: number;
  68659. /**
  68660. * Falloff Physical: light is falling off following the inverse squared distance law.
  68661. */
  68662. static readonly FALLOFF_PHYSICAL: number;
  68663. /**
  68664. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  68665. * to enhance interoperability with other engines.
  68666. */
  68667. static readonly FALLOFF_GLTF: number;
  68668. /**
  68669. * Falloff Standard: light is falling off like in the standard material
  68670. * to enhance interoperability with other materials.
  68671. */
  68672. static readonly FALLOFF_STANDARD: number;
  68673. /**
  68674. * If every light affecting the material is in this lightmapMode,
  68675. * material.lightmapTexture adds or multiplies
  68676. * (depends on material.useLightmapAsShadowmap)
  68677. * after every other light calculations.
  68678. */
  68679. static readonly LIGHTMAP_DEFAULT: number;
  68680. /**
  68681. * material.lightmapTexture as only diffuse lighting from this light
  68682. * adds only specular lighting from this light
  68683. * adds dynamic shadows
  68684. */
  68685. static readonly LIGHTMAP_SPECULAR: number;
  68686. /**
  68687. * material.lightmapTexture as only lighting
  68688. * no light calculation from this light
  68689. * only adds dynamic shadows from this light
  68690. */
  68691. static readonly LIGHTMAP_SHADOWSONLY: number;
  68692. /**
  68693. * Each light type uses the default quantity according to its type:
  68694. * point/spot lights use luminous intensity
  68695. * directional lights use illuminance
  68696. */
  68697. static readonly INTENSITYMODE_AUTOMATIC: number;
  68698. /**
  68699. * lumen (lm)
  68700. */
  68701. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  68702. /**
  68703. * candela (lm/sr)
  68704. */
  68705. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  68706. /**
  68707. * lux (lm/m^2)
  68708. */
  68709. static readonly INTENSITYMODE_ILLUMINANCE: number;
  68710. /**
  68711. * nit (cd/m^2)
  68712. */
  68713. static readonly INTENSITYMODE_LUMINANCE: number;
  68714. /**
  68715. * Light type const id of the point light.
  68716. */
  68717. static readonly LIGHTTYPEID_POINTLIGHT: number;
  68718. /**
  68719. * Light type const id of the directional light.
  68720. */
  68721. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  68722. /**
  68723. * Light type const id of the spot light.
  68724. */
  68725. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  68726. /**
  68727. * Light type const id of the hemispheric light.
  68728. */
  68729. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  68730. /**
  68731. * Diffuse gives the basic color to an object.
  68732. */
  68733. diffuse: Color3;
  68734. /**
  68735. * Specular produces a highlight color on an object.
  68736. * Note: This is note affecting PBR materials.
  68737. */
  68738. specular: Color3;
  68739. /**
  68740. * Defines the falloff type for this light. This lets overrriding how punctual light are
  68741. * falling off base on range or angle.
  68742. * This can be set to any values in Light.FALLOFF_x.
  68743. *
  68744. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  68745. * other types of materials.
  68746. */
  68747. falloffType: number;
  68748. /**
  68749. * Strength of the light.
  68750. * Note: By default it is define in the framework own unit.
  68751. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  68752. */
  68753. intensity: number;
  68754. private _range;
  68755. protected _inverseSquaredRange: number;
  68756. /**
  68757. * Defines how far from the source the light is impacting in scene units.
  68758. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68759. */
  68760. /**
  68761. * Defines how far from the source the light is impacting in scene units.
  68762. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68763. */
  68764. range: number;
  68765. /**
  68766. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  68767. * of light.
  68768. */
  68769. private _photometricScale;
  68770. private _intensityMode;
  68771. /**
  68772. * Gets the photometric scale used to interpret the intensity.
  68773. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68774. */
  68775. /**
  68776. * Sets the photometric scale used to interpret the intensity.
  68777. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68778. */
  68779. intensityMode: number;
  68780. private _radius;
  68781. /**
  68782. * Gets the light radius used by PBR Materials to simulate soft area lights.
  68783. */
  68784. /**
  68785. * sets the light radius used by PBR Materials to simulate soft area lights.
  68786. */
  68787. radius: number;
  68788. private _renderPriority;
  68789. /**
  68790. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  68791. * exceeding the number allowed of the materials.
  68792. */
  68793. renderPriority: number;
  68794. private _shadowEnabled;
  68795. /**
  68796. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68797. * the current shadow generator.
  68798. */
  68799. /**
  68800. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68801. * the current shadow generator.
  68802. */
  68803. shadowEnabled: boolean;
  68804. private _includedOnlyMeshes;
  68805. /**
  68806. * Gets the only meshes impacted by this light.
  68807. */
  68808. /**
  68809. * Sets the only meshes impacted by this light.
  68810. */
  68811. includedOnlyMeshes: AbstractMesh[];
  68812. private _excludedMeshes;
  68813. /**
  68814. * Gets the meshes not impacted by this light.
  68815. */
  68816. /**
  68817. * Sets the meshes not impacted by this light.
  68818. */
  68819. excludedMeshes: AbstractMesh[];
  68820. private _excludeWithLayerMask;
  68821. /**
  68822. * Gets the layer id use to find what meshes are not impacted by the light.
  68823. * Inactive if 0
  68824. */
  68825. /**
  68826. * Sets the layer id use to find what meshes are not impacted by the light.
  68827. * Inactive if 0
  68828. */
  68829. excludeWithLayerMask: number;
  68830. private _includeOnlyWithLayerMask;
  68831. /**
  68832. * Gets the layer id use to find what meshes are impacted by the light.
  68833. * Inactive if 0
  68834. */
  68835. /**
  68836. * Sets the layer id use to find what meshes are impacted by the light.
  68837. * Inactive if 0
  68838. */
  68839. includeOnlyWithLayerMask: number;
  68840. private _lightmapMode;
  68841. /**
  68842. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68843. */
  68844. /**
  68845. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68846. */
  68847. lightmapMode: number;
  68848. /**
  68849. * Shadow generator associted to the light.
  68850. * @hidden Internal use only.
  68851. */
  68852. _shadowGenerator: Nullable<IShadowGenerator>;
  68853. /**
  68854. * @hidden Internal use only.
  68855. */
  68856. _excludedMeshesIds: string[];
  68857. /**
  68858. * @hidden Internal use only.
  68859. */
  68860. _includedOnlyMeshesIds: string[];
  68861. /**
  68862. * The current light unifom buffer.
  68863. * @hidden Internal use only.
  68864. */
  68865. _uniformBuffer: UniformBuffer;
  68866. /**
  68867. * Creates a Light object in the scene.
  68868. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68869. * @param name The firendly name of the light
  68870. * @param scene The scene the light belongs too
  68871. */
  68872. constructor(name: string, scene: Scene);
  68873. protected abstract _buildUniformLayout(): void;
  68874. /**
  68875. * Sets the passed Effect "effect" with the Light information.
  68876. * @param effect The effect to update
  68877. * @param lightIndex The index of the light in the effect to update
  68878. * @returns The light
  68879. */
  68880. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68881. /**
  68882. * Returns the string "Light".
  68883. * @returns the class name
  68884. */
  68885. getClassName(): string;
  68886. /** @hidden */
  68887. readonly _isLight: boolean;
  68888. /**
  68889. * Converts the light information to a readable string for debug purpose.
  68890. * @param fullDetails Supports for multiple levels of logging within scene loading
  68891. * @returns the human readable light info
  68892. */
  68893. toString(fullDetails?: boolean): string;
  68894. /** @hidden */
  68895. protected _syncParentEnabledState(): void;
  68896. /**
  68897. * Set the enabled state of this node.
  68898. * @param value - the new enabled state
  68899. */
  68900. setEnabled(value: boolean): void;
  68901. /**
  68902. * Returns the Light associated shadow generator if any.
  68903. * @return the associated shadow generator.
  68904. */
  68905. getShadowGenerator(): Nullable<IShadowGenerator>;
  68906. /**
  68907. * Returns a Vector3, the absolute light position in the World.
  68908. * @returns the world space position of the light
  68909. */
  68910. getAbsolutePosition(): Vector3;
  68911. /**
  68912. * Specifies if the light will affect the passed mesh.
  68913. * @param mesh The mesh to test against the light
  68914. * @return true the mesh is affected otherwise, false.
  68915. */
  68916. canAffectMesh(mesh: AbstractMesh): boolean;
  68917. /**
  68918. * Sort function to order lights for rendering.
  68919. * @param a First Light object to compare to second.
  68920. * @param b Second Light object to compare first.
  68921. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68922. */
  68923. static CompareLightsPriority(a: Light, b: Light): number;
  68924. /**
  68925. * Releases resources associated with this node.
  68926. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68927. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68928. */
  68929. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68930. /**
  68931. * Returns the light type ID (integer).
  68932. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68933. */
  68934. getTypeID(): number;
  68935. /**
  68936. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68937. * @returns the scaled intensity in intensity mode unit
  68938. */
  68939. getScaledIntensity(): number;
  68940. /**
  68941. * Returns a new Light object, named "name", from the current one.
  68942. * @param name The name of the cloned light
  68943. * @returns the new created light
  68944. */
  68945. clone(name: string): Nullable<Light>;
  68946. /**
  68947. * Serializes the current light into a Serialization object.
  68948. * @returns the serialized object.
  68949. */
  68950. serialize(): any;
  68951. /**
  68952. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68953. * This new light is named "name" and added to the passed scene.
  68954. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68955. * @param name The friendly name of the light
  68956. * @param scene The scene the new light will belong to
  68957. * @returns the constructor function
  68958. */
  68959. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68960. /**
  68961. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68962. * @param parsedLight The JSON representation of the light
  68963. * @param scene The scene to create the parsed light in
  68964. * @returns the created light after parsing
  68965. */
  68966. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68967. private _hookArrayForExcluded;
  68968. private _hookArrayForIncludedOnly;
  68969. private _resyncMeshes;
  68970. /**
  68971. * Forces the meshes to update their light related information in their rendering used effects
  68972. * @hidden Internal Use Only
  68973. */
  68974. _markMeshesAsLightDirty(): void;
  68975. /**
  68976. * Recomputes the cached photometric scale if needed.
  68977. */
  68978. private _computePhotometricScale;
  68979. /**
  68980. * Returns the Photometric Scale according to the light type and intensity mode.
  68981. */
  68982. private _getPhotometricScale;
  68983. /**
  68984. * Reorder the light in the scene according to their defined priority.
  68985. * @hidden Internal Use Only
  68986. */
  68987. _reorderLightsInScene(): void;
  68988. /**
  68989. * Prepares the list of defines specific to the light type.
  68990. * @param defines the list of defines
  68991. * @param lightIndex defines the index of the light for the effect
  68992. */
  68993. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68994. }
  68995. }
  68996. declare module BABYLON {
  68997. /**
  68998. * Interface used to define Action
  68999. */
  69000. export interface IAction {
  69001. /**
  69002. * Trigger for the action
  69003. */
  69004. trigger: number;
  69005. /** Options of the trigger */
  69006. triggerOptions: any;
  69007. /**
  69008. * Gets the trigger parameters
  69009. * @returns the trigger parameters
  69010. */
  69011. getTriggerParameter(): any;
  69012. /**
  69013. * Internal only - executes current action event
  69014. * @hidden
  69015. */
  69016. _executeCurrent(evt?: ActionEvent): void;
  69017. /**
  69018. * Serialize placeholder for child classes
  69019. * @param parent of child
  69020. * @returns the serialized object
  69021. */
  69022. serialize(parent: any): any;
  69023. /**
  69024. * Internal only
  69025. * @hidden
  69026. */
  69027. _prepare(): void;
  69028. /**
  69029. * Internal only - manager for action
  69030. * @hidden
  69031. */
  69032. _actionManager: AbstractActionManager;
  69033. }
  69034. /**
  69035. * The action to be carried out following a trigger
  69036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69037. */
  69038. export class Action implements IAction {
  69039. /** the trigger, with or without parameters, for the action */
  69040. triggerOptions: any;
  69041. /**
  69042. * Trigger for the action
  69043. */
  69044. trigger: number;
  69045. /**
  69046. * Internal only - manager for action
  69047. * @hidden
  69048. */
  69049. _actionManager: ActionManager;
  69050. private _nextActiveAction;
  69051. private _child;
  69052. private _condition?;
  69053. private _triggerParameter;
  69054. /**
  69055. * An event triggered prior to action being executed.
  69056. */
  69057. onBeforeExecuteObservable: Observable<Action>;
  69058. /**
  69059. * Creates a new Action
  69060. * @param triggerOptions the trigger, with or without parameters, for the action
  69061. * @param condition an optional determinant of action
  69062. */
  69063. constructor(
  69064. /** the trigger, with or without parameters, for the action */
  69065. triggerOptions: any, condition?: Condition);
  69066. /**
  69067. * Internal only
  69068. * @hidden
  69069. */
  69070. _prepare(): void;
  69071. /**
  69072. * Gets the trigger parameters
  69073. * @returns the trigger parameters
  69074. */
  69075. getTriggerParameter(): any;
  69076. /**
  69077. * Internal only - executes current action event
  69078. * @hidden
  69079. */
  69080. _executeCurrent(evt?: ActionEvent): void;
  69081. /**
  69082. * Execute placeholder for child classes
  69083. * @param evt optional action event
  69084. */
  69085. execute(evt?: ActionEvent): void;
  69086. /**
  69087. * Skips to next active action
  69088. */
  69089. skipToNextActiveAction(): void;
  69090. /**
  69091. * Adds action to chain of actions, may be a DoNothingAction
  69092. * @param action defines the next action to execute
  69093. * @returns The action passed in
  69094. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69095. */
  69096. then(action: Action): Action;
  69097. /**
  69098. * Internal only
  69099. * @hidden
  69100. */
  69101. _getProperty(propertyPath: string): string;
  69102. /**
  69103. * Internal only
  69104. * @hidden
  69105. */
  69106. _getEffectiveTarget(target: any, propertyPath: string): any;
  69107. /**
  69108. * Serialize placeholder for child classes
  69109. * @param parent of child
  69110. * @returns the serialized object
  69111. */
  69112. serialize(parent: any): any;
  69113. /**
  69114. * Internal only called by serialize
  69115. * @hidden
  69116. */
  69117. protected _serialize(serializedAction: any, parent?: any): any;
  69118. /**
  69119. * Internal only
  69120. * @hidden
  69121. */
  69122. static _SerializeValueAsString: (value: any) => string;
  69123. /**
  69124. * Internal only
  69125. * @hidden
  69126. */
  69127. static _GetTargetProperty: (target: Scene | Node) => {
  69128. name: string;
  69129. targetType: string;
  69130. value: string;
  69131. };
  69132. }
  69133. }
  69134. declare module BABYLON {
  69135. /**
  69136. * A Condition applied to an Action
  69137. */
  69138. export class Condition {
  69139. /**
  69140. * Internal only - manager for action
  69141. * @hidden
  69142. */
  69143. _actionManager: ActionManager;
  69144. /**
  69145. * Internal only
  69146. * @hidden
  69147. */
  69148. _evaluationId: number;
  69149. /**
  69150. * Internal only
  69151. * @hidden
  69152. */
  69153. _currentResult: boolean;
  69154. /**
  69155. * Creates a new Condition
  69156. * @param actionManager the manager of the action the condition is applied to
  69157. */
  69158. constructor(actionManager: ActionManager);
  69159. /**
  69160. * Check if the current condition is valid
  69161. * @returns a boolean
  69162. */
  69163. isValid(): boolean;
  69164. /**
  69165. * Internal only
  69166. * @hidden
  69167. */
  69168. _getProperty(propertyPath: string): string;
  69169. /**
  69170. * Internal only
  69171. * @hidden
  69172. */
  69173. _getEffectiveTarget(target: any, propertyPath: string): any;
  69174. /**
  69175. * Serialize placeholder for child classes
  69176. * @returns the serialized object
  69177. */
  69178. serialize(): any;
  69179. /**
  69180. * Internal only
  69181. * @hidden
  69182. */
  69183. protected _serialize(serializedCondition: any): any;
  69184. }
  69185. /**
  69186. * Defines specific conditional operators as extensions of Condition
  69187. */
  69188. export class ValueCondition extends Condition {
  69189. /** path to specify the property of the target the conditional operator uses */
  69190. propertyPath: string;
  69191. /** the value compared by the conditional operator against the current value of the property */
  69192. value: any;
  69193. /** the conditional operator, default ValueCondition.IsEqual */
  69194. operator: number;
  69195. /**
  69196. * Internal only
  69197. * @hidden
  69198. */
  69199. private static _IsEqual;
  69200. /**
  69201. * Internal only
  69202. * @hidden
  69203. */
  69204. private static _IsDifferent;
  69205. /**
  69206. * Internal only
  69207. * @hidden
  69208. */
  69209. private static _IsGreater;
  69210. /**
  69211. * Internal only
  69212. * @hidden
  69213. */
  69214. private static _IsLesser;
  69215. /**
  69216. * returns the number for IsEqual
  69217. */
  69218. static readonly IsEqual: number;
  69219. /**
  69220. * Returns the number for IsDifferent
  69221. */
  69222. static readonly IsDifferent: number;
  69223. /**
  69224. * Returns the number for IsGreater
  69225. */
  69226. static readonly IsGreater: number;
  69227. /**
  69228. * Returns the number for IsLesser
  69229. */
  69230. static readonly IsLesser: number;
  69231. /**
  69232. * Internal only The action manager for the condition
  69233. * @hidden
  69234. */
  69235. _actionManager: ActionManager;
  69236. /**
  69237. * Internal only
  69238. * @hidden
  69239. */
  69240. private _target;
  69241. /**
  69242. * Internal only
  69243. * @hidden
  69244. */
  69245. private _effectiveTarget;
  69246. /**
  69247. * Internal only
  69248. * @hidden
  69249. */
  69250. private _property;
  69251. /**
  69252. * Creates a new ValueCondition
  69253. * @param actionManager manager for the action the condition applies to
  69254. * @param target for the action
  69255. * @param propertyPath path to specify the property of the target the conditional operator uses
  69256. * @param value the value compared by the conditional operator against the current value of the property
  69257. * @param operator the conditional operator, default ValueCondition.IsEqual
  69258. */
  69259. constructor(actionManager: ActionManager, target: any,
  69260. /** path to specify the property of the target the conditional operator uses */
  69261. propertyPath: string,
  69262. /** the value compared by the conditional operator against the current value of the property */
  69263. value: any,
  69264. /** the conditional operator, default ValueCondition.IsEqual */
  69265. operator?: number);
  69266. /**
  69267. * Compares the given value with the property value for the specified conditional operator
  69268. * @returns the result of the comparison
  69269. */
  69270. isValid(): boolean;
  69271. /**
  69272. * Serialize the ValueCondition into a JSON compatible object
  69273. * @returns serialization object
  69274. */
  69275. serialize(): any;
  69276. /**
  69277. * Gets the name of the conditional operator for the ValueCondition
  69278. * @param operator the conditional operator
  69279. * @returns the name
  69280. */
  69281. static GetOperatorName(operator: number): string;
  69282. }
  69283. /**
  69284. * Defines a predicate condition as an extension of Condition
  69285. */
  69286. export class PredicateCondition extends Condition {
  69287. /** defines the predicate function used to validate the condition */
  69288. predicate: () => boolean;
  69289. /**
  69290. * Internal only - manager for action
  69291. * @hidden
  69292. */
  69293. _actionManager: ActionManager;
  69294. /**
  69295. * Creates a new PredicateCondition
  69296. * @param actionManager manager for the action the condition applies to
  69297. * @param predicate defines the predicate function used to validate the condition
  69298. */
  69299. constructor(actionManager: ActionManager,
  69300. /** defines the predicate function used to validate the condition */
  69301. predicate: () => boolean);
  69302. /**
  69303. * @returns the validity of the predicate condition
  69304. */
  69305. isValid(): boolean;
  69306. }
  69307. /**
  69308. * Defines a state condition as an extension of Condition
  69309. */
  69310. export class StateCondition extends Condition {
  69311. /** Value to compare with target state */
  69312. value: string;
  69313. /**
  69314. * Internal only - manager for action
  69315. * @hidden
  69316. */
  69317. _actionManager: ActionManager;
  69318. /**
  69319. * Internal only
  69320. * @hidden
  69321. */
  69322. private _target;
  69323. /**
  69324. * Creates a new StateCondition
  69325. * @param actionManager manager for the action the condition applies to
  69326. * @param target of the condition
  69327. * @param value to compare with target state
  69328. */
  69329. constructor(actionManager: ActionManager, target: any,
  69330. /** Value to compare with target state */
  69331. value: string);
  69332. /**
  69333. * Gets a boolean indicating if the current condition is met
  69334. * @returns the validity of the state
  69335. */
  69336. isValid(): boolean;
  69337. /**
  69338. * Serialize the StateCondition into a JSON compatible object
  69339. * @returns serialization object
  69340. */
  69341. serialize(): any;
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /**
  69346. * This defines an action responsible to toggle a boolean once triggered.
  69347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69348. */
  69349. export class SwitchBooleanAction extends Action {
  69350. /**
  69351. * The path to the boolean property in the target object
  69352. */
  69353. propertyPath: string;
  69354. private _target;
  69355. private _effectiveTarget;
  69356. private _property;
  69357. /**
  69358. * Instantiate the action
  69359. * @param triggerOptions defines the trigger options
  69360. * @param target defines the object containing the boolean
  69361. * @param propertyPath defines the path to the boolean property in the target object
  69362. * @param condition defines the trigger related conditions
  69363. */
  69364. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69365. /** @hidden */
  69366. _prepare(): void;
  69367. /**
  69368. * Execute the action toggle the boolean value.
  69369. */
  69370. execute(): void;
  69371. /**
  69372. * Serializes the actions and its related information.
  69373. * @param parent defines the object to serialize in
  69374. * @returns the serialized object
  69375. */
  69376. serialize(parent: any): any;
  69377. }
  69378. /**
  69379. * This defines an action responsible to set a the state field of the target
  69380. * to a desired value once triggered.
  69381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69382. */
  69383. export class SetStateAction extends Action {
  69384. /**
  69385. * The value to store in the state field.
  69386. */
  69387. value: string;
  69388. private _target;
  69389. /**
  69390. * Instantiate the action
  69391. * @param triggerOptions defines the trigger options
  69392. * @param target defines the object containing the state property
  69393. * @param value defines the value to store in the state field
  69394. * @param condition defines the trigger related conditions
  69395. */
  69396. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69397. /**
  69398. * Execute the action and store the value on the target state property.
  69399. */
  69400. execute(): void;
  69401. /**
  69402. * Serializes the actions and its related information.
  69403. * @param parent defines the object to serialize in
  69404. * @returns the serialized object
  69405. */
  69406. serialize(parent: any): any;
  69407. }
  69408. /**
  69409. * This defines an action responsible to set a property of the target
  69410. * to a desired value once triggered.
  69411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69412. */
  69413. export class SetValueAction extends Action {
  69414. /**
  69415. * The path of the property to set in the target.
  69416. */
  69417. propertyPath: string;
  69418. /**
  69419. * The value to set in the property
  69420. */
  69421. value: any;
  69422. private _target;
  69423. private _effectiveTarget;
  69424. private _property;
  69425. /**
  69426. * Instantiate the action
  69427. * @param triggerOptions defines the trigger options
  69428. * @param target defines the object containing the property
  69429. * @param propertyPath defines the path of the property to set in the target
  69430. * @param value defines the value to set in the property
  69431. * @param condition defines the trigger related conditions
  69432. */
  69433. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69434. /** @hidden */
  69435. _prepare(): void;
  69436. /**
  69437. * Execute the action and set the targetted property to the desired value.
  69438. */
  69439. execute(): void;
  69440. /**
  69441. * Serializes the actions and its related information.
  69442. * @param parent defines the object to serialize in
  69443. * @returns the serialized object
  69444. */
  69445. serialize(parent: any): any;
  69446. }
  69447. /**
  69448. * This defines an action responsible to increment the target value
  69449. * to a desired value once triggered.
  69450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69451. */
  69452. export class IncrementValueAction extends Action {
  69453. /**
  69454. * The path of the property to increment in the target.
  69455. */
  69456. propertyPath: string;
  69457. /**
  69458. * The value we should increment the property by.
  69459. */
  69460. value: any;
  69461. private _target;
  69462. private _effectiveTarget;
  69463. private _property;
  69464. /**
  69465. * Instantiate the action
  69466. * @param triggerOptions defines the trigger options
  69467. * @param target defines the object containing the property
  69468. * @param propertyPath defines the path of the property to increment in the target
  69469. * @param value defines the value value we should increment the property by
  69470. * @param condition defines the trigger related conditions
  69471. */
  69472. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69473. /** @hidden */
  69474. _prepare(): void;
  69475. /**
  69476. * Execute the action and increment the target of the value amount.
  69477. */
  69478. execute(): void;
  69479. /**
  69480. * Serializes the actions and its related information.
  69481. * @param parent defines the object to serialize in
  69482. * @returns the serialized object
  69483. */
  69484. serialize(parent: any): any;
  69485. }
  69486. /**
  69487. * This defines an action responsible to start an animation once triggered.
  69488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69489. */
  69490. export class PlayAnimationAction extends Action {
  69491. /**
  69492. * Where the animation should start (animation frame)
  69493. */
  69494. from: number;
  69495. /**
  69496. * Where the animation should stop (animation frame)
  69497. */
  69498. to: number;
  69499. /**
  69500. * Define if the animation should loop or stop after the first play.
  69501. */
  69502. loop?: boolean;
  69503. private _target;
  69504. /**
  69505. * Instantiate the action
  69506. * @param triggerOptions defines the trigger options
  69507. * @param target defines the target animation or animation name
  69508. * @param from defines from where the animation should start (animation frame)
  69509. * @param end defines where the animation should stop (animation frame)
  69510. * @param loop defines if the animation should loop or stop after the first play
  69511. * @param condition defines the trigger related conditions
  69512. */
  69513. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69514. /** @hidden */
  69515. _prepare(): void;
  69516. /**
  69517. * Execute the action and play the animation.
  69518. */
  69519. execute(): void;
  69520. /**
  69521. * Serializes the actions and its related information.
  69522. * @param parent defines the object to serialize in
  69523. * @returns the serialized object
  69524. */
  69525. serialize(parent: any): any;
  69526. }
  69527. /**
  69528. * This defines an action responsible to stop an animation once triggered.
  69529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69530. */
  69531. export class StopAnimationAction extends Action {
  69532. private _target;
  69533. /**
  69534. * Instantiate the action
  69535. * @param triggerOptions defines the trigger options
  69536. * @param target defines the target animation or animation name
  69537. * @param condition defines the trigger related conditions
  69538. */
  69539. constructor(triggerOptions: any, target: any, condition?: Condition);
  69540. /** @hidden */
  69541. _prepare(): void;
  69542. /**
  69543. * Execute the action and stop the animation.
  69544. */
  69545. execute(): void;
  69546. /**
  69547. * Serializes the actions and its related information.
  69548. * @param parent defines the object to serialize in
  69549. * @returns the serialized object
  69550. */
  69551. serialize(parent: any): any;
  69552. }
  69553. /**
  69554. * This defines an action responsible that does nothing once triggered.
  69555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69556. */
  69557. export class DoNothingAction extends Action {
  69558. /**
  69559. * Instantiate the action
  69560. * @param triggerOptions defines the trigger options
  69561. * @param condition defines the trigger related conditions
  69562. */
  69563. constructor(triggerOptions?: any, condition?: Condition);
  69564. /**
  69565. * Execute the action and do nothing.
  69566. */
  69567. execute(): void;
  69568. /**
  69569. * Serializes the actions and its related information.
  69570. * @param parent defines the object to serialize in
  69571. * @returns the serialized object
  69572. */
  69573. serialize(parent: any): any;
  69574. }
  69575. /**
  69576. * This defines an action responsible to trigger several actions once triggered.
  69577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69578. */
  69579. export class CombineAction extends Action {
  69580. /**
  69581. * The list of aggregated animations to run.
  69582. */
  69583. children: Action[];
  69584. /**
  69585. * Instantiate the action
  69586. * @param triggerOptions defines the trigger options
  69587. * @param children defines the list of aggregated animations to run
  69588. * @param condition defines the trigger related conditions
  69589. */
  69590. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  69591. /** @hidden */
  69592. _prepare(): void;
  69593. /**
  69594. * Execute the action and executes all the aggregated actions.
  69595. */
  69596. execute(evt: ActionEvent): void;
  69597. /**
  69598. * Serializes the actions and its related information.
  69599. * @param parent defines the object to serialize in
  69600. * @returns the serialized object
  69601. */
  69602. serialize(parent: any): any;
  69603. }
  69604. /**
  69605. * This defines an action responsible to run code (external event) once triggered.
  69606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69607. */
  69608. export class ExecuteCodeAction extends Action {
  69609. /**
  69610. * The callback function to run.
  69611. */
  69612. func: (evt: ActionEvent) => void;
  69613. /**
  69614. * Instantiate the action
  69615. * @param triggerOptions defines the trigger options
  69616. * @param func defines the callback function to run
  69617. * @param condition defines the trigger related conditions
  69618. */
  69619. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  69620. /**
  69621. * Execute the action and run the attached code.
  69622. */
  69623. execute(evt: ActionEvent): void;
  69624. }
  69625. /**
  69626. * This defines an action responsible to set the parent property of the target once triggered.
  69627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69628. */
  69629. export class SetParentAction extends Action {
  69630. private _parent;
  69631. private _target;
  69632. /**
  69633. * Instantiate the action
  69634. * @param triggerOptions defines the trigger options
  69635. * @param target defines the target containing the parent property
  69636. * @param parent defines from where the animation should start (animation frame)
  69637. * @param condition defines the trigger related conditions
  69638. */
  69639. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  69640. /** @hidden */
  69641. _prepare(): void;
  69642. /**
  69643. * Execute the action and set the parent property.
  69644. */
  69645. execute(): void;
  69646. /**
  69647. * Serializes the actions and its related information.
  69648. * @param parent defines the object to serialize in
  69649. * @returns the serialized object
  69650. */
  69651. serialize(parent: any): any;
  69652. }
  69653. }
  69654. declare module BABYLON {
  69655. /**
  69656. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  69657. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  69658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69659. */
  69660. export class ActionManager extends AbstractActionManager {
  69661. /**
  69662. * Nothing
  69663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69664. */
  69665. static readonly NothingTrigger: number;
  69666. /**
  69667. * On pick
  69668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69669. */
  69670. static readonly OnPickTrigger: number;
  69671. /**
  69672. * On left pick
  69673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69674. */
  69675. static readonly OnLeftPickTrigger: number;
  69676. /**
  69677. * On right pick
  69678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69679. */
  69680. static readonly OnRightPickTrigger: number;
  69681. /**
  69682. * On center pick
  69683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69684. */
  69685. static readonly OnCenterPickTrigger: number;
  69686. /**
  69687. * On pick down
  69688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69689. */
  69690. static readonly OnPickDownTrigger: number;
  69691. /**
  69692. * On double pick
  69693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69694. */
  69695. static readonly OnDoublePickTrigger: number;
  69696. /**
  69697. * On pick up
  69698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69699. */
  69700. static readonly OnPickUpTrigger: number;
  69701. /**
  69702. * On pick out.
  69703. * This trigger will only be raised if you also declared a OnPickDown
  69704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69705. */
  69706. static readonly OnPickOutTrigger: number;
  69707. /**
  69708. * On long press
  69709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69710. */
  69711. static readonly OnLongPressTrigger: number;
  69712. /**
  69713. * On pointer over
  69714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69715. */
  69716. static readonly OnPointerOverTrigger: number;
  69717. /**
  69718. * On pointer out
  69719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69720. */
  69721. static readonly OnPointerOutTrigger: number;
  69722. /**
  69723. * On every frame
  69724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69725. */
  69726. static readonly OnEveryFrameTrigger: number;
  69727. /**
  69728. * On intersection enter
  69729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69730. */
  69731. static readonly OnIntersectionEnterTrigger: number;
  69732. /**
  69733. * On intersection exit
  69734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69735. */
  69736. static readonly OnIntersectionExitTrigger: number;
  69737. /**
  69738. * On key down
  69739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69740. */
  69741. static readonly OnKeyDownTrigger: number;
  69742. /**
  69743. * On key up
  69744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69745. */
  69746. static readonly OnKeyUpTrigger: number;
  69747. private _scene;
  69748. /**
  69749. * Creates a new action manager
  69750. * @param scene defines the hosting scene
  69751. */
  69752. constructor(scene: Scene);
  69753. /**
  69754. * Releases all associated resources
  69755. */
  69756. dispose(): void;
  69757. /**
  69758. * Gets hosting scene
  69759. * @returns the hosting scene
  69760. */
  69761. getScene(): Scene;
  69762. /**
  69763. * Does this action manager handles actions of any of the given triggers
  69764. * @param triggers defines the triggers to be tested
  69765. * @return a boolean indicating whether one (or more) of the triggers is handled
  69766. */
  69767. hasSpecificTriggers(triggers: number[]): boolean;
  69768. /**
  69769. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  69770. * speed.
  69771. * @param triggerA defines the trigger to be tested
  69772. * @param triggerB defines the trigger to be tested
  69773. * @return a boolean indicating whether one (or more) of the triggers is handled
  69774. */
  69775. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  69776. /**
  69777. * Does this action manager handles actions of a given trigger
  69778. * @param trigger defines the trigger to be tested
  69779. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  69780. * @return whether the trigger is handled
  69781. */
  69782. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  69783. /**
  69784. * Does this action manager has pointer triggers
  69785. */
  69786. readonly hasPointerTriggers: boolean;
  69787. /**
  69788. * Does this action manager has pick triggers
  69789. */
  69790. readonly hasPickTriggers: boolean;
  69791. /**
  69792. * Registers an action to this action manager
  69793. * @param action defines the action to be registered
  69794. * @return the action amended (prepared) after registration
  69795. */
  69796. registerAction(action: IAction): Nullable<IAction>;
  69797. /**
  69798. * Unregisters an action to this action manager
  69799. * @param action defines the action to be unregistered
  69800. * @return a boolean indicating whether the action has been unregistered
  69801. */
  69802. unregisterAction(action: IAction): Boolean;
  69803. /**
  69804. * Process a specific trigger
  69805. * @param trigger defines the trigger to process
  69806. * @param evt defines the event details to be processed
  69807. */
  69808. processTrigger(trigger: number, evt?: IActionEvent): void;
  69809. /** @hidden */
  69810. _getEffectiveTarget(target: any, propertyPath: string): any;
  69811. /** @hidden */
  69812. _getProperty(propertyPath: string): string;
  69813. /**
  69814. * Serialize this manager to a JSON object
  69815. * @param name defines the property name to store this manager
  69816. * @returns a JSON representation of this manager
  69817. */
  69818. serialize(name: string): any;
  69819. /**
  69820. * Creates a new ActionManager from a JSON data
  69821. * @param parsedActions defines the JSON data to read from
  69822. * @param object defines the hosting mesh
  69823. * @param scene defines the hosting scene
  69824. */
  69825. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69826. /**
  69827. * Get a trigger name by index
  69828. * @param trigger defines the trigger index
  69829. * @returns a trigger name
  69830. */
  69831. static GetTriggerName(trigger: number): string;
  69832. }
  69833. }
  69834. declare module BABYLON {
  69835. /**
  69836. * Class representing a ray with position and direction
  69837. */
  69838. export class Ray {
  69839. /** origin point */
  69840. origin: Vector3;
  69841. /** direction */
  69842. direction: Vector3;
  69843. /** length of the ray */
  69844. length: number;
  69845. private static readonly TmpVector3;
  69846. private _tmpRay;
  69847. /**
  69848. * Creates a new ray
  69849. * @param origin origin point
  69850. * @param direction direction
  69851. * @param length length of the ray
  69852. */
  69853. constructor(
  69854. /** origin point */
  69855. origin: Vector3,
  69856. /** direction */
  69857. direction: Vector3,
  69858. /** length of the ray */
  69859. length?: number);
  69860. /**
  69861. * Checks if the ray intersects a box
  69862. * @param minimum bound of the box
  69863. * @param maximum bound of the box
  69864. * @param intersectionTreshold extra extend to be added to the box in all direction
  69865. * @returns if the box was hit
  69866. */
  69867. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69868. /**
  69869. * Checks if the ray intersects a box
  69870. * @param box the bounding box to check
  69871. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69872. * @returns if the box was hit
  69873. */
  69874. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69875. /**
  69876. * If the ray hits a sphere
  69877. * @param sphere the bounding sphere to check
  69878. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69879. * @returns true if it hits the sphere
  69880. */
  69881. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69882. /**
  69883. * If the ray hits a triange
  69884. * @param vertex0 triangle vertex
  69885. * @param vertex1 triangle vertex
  69886. * @param vertex2 triangle vertex
  69887. * @returns intersection information if hit
  69888. */
  69889. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69890. /**
  69891. * Checks if ray intersects a plane
  69892. * @param plane the plane to check
  69893. * @returns the distance away it was hit
  69894. */
  69895. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69896. /**
  69897. * Checks if ray intersects a mesh
  69898. * @param mesh the mesh to check
  69899. * @param fastCheck if only the bounding box should checked
  69900. * @returns picking info of the intersecton
  69901. */
  69902. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69903. /**
  69904. * Checks if ray intersects a mesh
  69905. * @param meshes the meshes to check
  69906. * @param fastCheck if only the bounding box should checked
  69907. * @param results array to store result in
  69908. * @returns Array of picking infos
  69909. */
  69910. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69911. private _comparePickingInfo;
  69912. private static smallnum;
  69913. private static rayl;
  69914. /**
  69915. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69916. * @param sega the first point of the segment to test the intersection against
  69917. * @param segb the second point of the segment to test the intersection against
  69918. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69919. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69920. */
  69921. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69922. /**
  69923. * Update the ray from viewport position
  69924. * @param x position
  69925. * @param y y position
  69926. * @param viewportWidth viewport width
  69927. * @param viewportHeight viewport height
  69928. * @param world world matrix
  69929. * @param view view matrix
  69930. * @param projection projection matrix
  69931. * @returns this ray updated
  69932. */
  69933. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69934. /**
  69935. * Creates a ray with origin and direction of 0,0,0
  69936. * @returns the new ray
  69937. */
  69938. static Zero(): Ray;
  69939. /**
  69940. * Creates a new ray from screen space and viewport
  69941. * @param x position
  69942. * @param y y position
  69943. * @param viewportWidth viewport width
  69944. * @param viewportHeight viewport height
  69945. * @param world world matrix
  69946. * @param view view matrix
  69947. * @param projection projection matrix
  69948. * @returns new ray
  69949. */
  69950. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69951. /**
  69952. * 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
  69953. * transformed to the given world matrix.
  69954. * @param origin The origin point
  69955. * @param end The end point
  69956. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69957. * @returns the new ray
  69958. */
  69959. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69960. /**
  69961. * Transforms a ray by a matrix
  69962. * @param ray ray to transform
  69963. * @param matrix matrix to apply
  69964. * @returns the resulting new ray
  69965. */
  69966. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69967. /**
  69968. * Transforms a ray by a matrix
  69969. * @param ray ray to transform
  69970. * @param matrix matrix to apply
  69971. * @param result ray to store result in
  69972. */
  69973. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69974. /**
  69975. * Unproject a ray from screen space to object space
  69976. * @param sourceX defines the screen space x coordinate to use
  69977. * @param sourceY defines the screen space y coordinate to use
  69978. * @param viewportWidth defines the current width of the viewport
  69979. * @param viewportHeight defines the current height of the viewport
  69980. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69981. * @param view defines the view matrix to use
  69982. * @param projection defines the projection matrix to use
  69983. */
  69984. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69985. }
  69986. /**
  69987. * Type used to define predicate used to select faces when a mesh intersection is detected
  69988. */
  69989. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69990. interface Scene {
  69991. /** @hidden */
  69992. _tempPickingRay: Nullable<Ray>;
  69993. /** @hidden */
  69994. _cachedRayForTransform: Ray;
  69995. /** @hidden */
  69996. _pickWithRayInverseMatrix: Matrix;
  69997. /** @hidden */
  69998. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69999. /** @hidden */
  70000. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70001. }
  70002. }
  70003. declare module BABYLON {
  70004. /**
  70005. * Groups all the scene component constants in one place to ease maintenance.
  70006. * @hidden
  70007. */
  70008. export class SceneComponentConstants {
  70009. static readonly NAME_EFFECTLAYER: string;
  70010. static readonly NAME_LAYER: string;
  70011. static readonly NAME_LENSFLARESYSTEM: string;
  70012. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70013. static readonly NAME_PARTICLESYSTEM: string;
  70014. static readonly NAME_GAMEPAD: string;
  70015. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70016. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70017. static readonly NAME_DEPTHRENDERER: string;
  70018. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70019. static readonly NAME_SPRITE: string;
  70020. static readonly NAME_OUTLINERENDERER: string;
  70021. static readonly NAME_PROCEDURALTEXTURE: string;
  70022. static readonly NAME_SHADOWGENERATOR: string;
  70023. static readonly NAME_OCTREE: string;
  70024. static readonly NAME_PHYSICSENGINE: string;
  70025. static readonly NAME_AUDIO: string;
  70026. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70027. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70028. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70029. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70030. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70031. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70032. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70033. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70034. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70035. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70036. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70037. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70038. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70039. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70040. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70041. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70042. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70043. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70044. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70045. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70046. static readonly STEP_AFTERRENDER_AUDIO: number;
  70047. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70048. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70049. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70050. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70051. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70052. static readonly STEP_POINTERMOVE_SPRITE: number;
  70053. static readonly STEP_POINTERDOWN_SPRITE: number;
  70054. static readonly STEP_POINTERUP_SPRITE: number;
  70055. }
  70056. /**
  70057. * This represents a scene component.
  70058. *
  70059. * This is used to decouple the dependency the scene is having on the different workloads like
  70060. * layers, post processes...
  70061. */
  70062. export interface ISceneComponent {
  70063. /**
  70064. * The name of the component. Each component must have a unique name.
  70065. */
  70066. name: string;
  70067. /**
  70068. * The scene the component belongs to.
  70069. */
  70070. scene: Scene;
  70071. /**
  70072. * Register the component to one instance of a scene.
  70073. */
  70074. register(): void;
  70075. /**
  70076. * Rebuilds the elements related to this component in case of
  70077. * context lost for instance.
  70078. */
  70079. rebuild(): void;
  70080. /**
  70081. * Disposes the component and the associated ressources.
  70082. */
  70083. dispose(): void;
  70084. }
  70085. /**
  70086. * This represents a SERIALIZABLE scene component.
  70087. *
  70088. * This extends Scene Component to add Serialization methods on top.
  70089. */
  70090. export interface ISceneSerializableComponent extends ISceneComponent {
  70091. /**
  70092. * Adds all the element from the container to the scene
  70093. * @param container the container holding the elements
  70094. */
  70095. addFromContainer(container: AbstractScene): void;
  70096. /**
  70097. * Removes all the elements in the container from the scene
  70098. * @param container contains the elements to remove
  70099. * @param dispose if the removed element should be disposed (default: false)
  70100. */
  70101. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70102. /**
  70103. * Serializes the component data to the specified json object
  70104. * @param serializationObject The object to serialize to
  70105. */
  70106. serialize(serializationObject: any): void;
  70107. }
  70108. /**
  70109. * Strong typing of a Mesh related stage step action
  70110. */
  70111. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70112. /**
  70113. * Strong typing of a Evaluate Sub Mesh related stage step action
  70114. */
  70115. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70116. /**
  70117. * Strong typing of a Active Mesh related stage step action
  70118. */
  70119. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70120. /**
  70121. * Strong typing of a Camera related stage step action
  70122. */
  70123. export type CameraStageAction = (camera: Camera) => void;
  70124. /**
  70125. * Strong typing of a Render Target related stage step action
  70126. */
  70127. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70128. /**
  70129. * Strong typing of a RenderingGroup related stage step action
  70130. */
  70131. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70132. /**
  70133. * Strong typing of a Mesh Render related stage step action
  70134. */
  70135. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70136. /**
  70137. * Strong typing of a simple stage step action
  70138. */
  70139. export type SimpleStageAction = () => void;
  70140. /**
  70141. * Strong typing of a render target action.
  70142. */
  70143. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70144. /**
  70145. * Strong typing of a pointer move action.
  70146. */
  70147. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70148. /**
  70149. * Strong typing of a pointer up/down action.
  70150. */
  70151. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70152. /**
  70153. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70154. * @hidden
  70155. */
  70156. export class Stage<T extends Function> extends Array<{
  70157. index: number;
  70158. component: ISceneComponent;
  70159. action: T;
  70160. }> {
  70161. /**
  70162. * Hide ctor from the rest of the world.
  70163. * @param items The items to add.
  70164. */
  70165. private constructor();
  70166. /**
  70167. * Creates a new Stage.
  70168. * @returns A new instance of a Stage
  70169. */
  70170. static Create<T extends Function>(): Stage<T>;
  70171. /**
  70172. * Registers a step in an ordered way in the targeted stage.
  70173. * @param index Defines the position to register the step in
  70174. * @param component Defines the component attached to the step
  70175. * @param action Defines the action to launch during the step
  70176. */
  70177. registerStep(index: number, component: ISceneComponent, action: T): void;
  70178. /**
  70179. * Clears all the steps from the stage.
  70180. */
  70181. clear(): void;
  70182. }
  70183. }
  70184. declare module BABYLON {
  70185. interface Scene {
  70186. /** @hidden */
  70187. _pointerOverSprite: Nullable<Sprite>;
  70188. /** @hidden */
  70189. _pickedDownSprite: Nullable<Sprite>;
  70190. /** @hidden */
  70191. _tempSpritePickingRay: Nullable<Ray>;
  70192. /**
  70193. * All of the sprite managers added to this scene
  70194. * @see http://doc.babylonjs.com/babylon101/sprites
  70195. */
  70196. spriteManagers: Array<ISpriteManager>;
  70197. /**
  70198. * An event triggered when sprites rendering is about to start
  70199. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70200. */
  70201. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70202. /**
  70203. * An event triggered when sprites rendering is done
  70204. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70205. */
  70206. onAfterSpritesRenderingObservable: Observable<Scene>;
  70207. /** @hidden */
  70208. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70209. /** Launch a ray to try to pick a sprite in the scene
  70210. * @param x position on screen
  70211. * @param y position on screen
  70212. * @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
  70213. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70214. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70215. * @returns a PickingInfo
  70216. */
  70217. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70218. /** Use the given ray to pick a sprite in the scene
  70219. * @param ray The ray (in world space) to use to pick meshes
  70220. * @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
  70221. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70222. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70223. * @returns a PickingInfo
  70224. */
  70225. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70226. /**
  70227. * Force the sprite under the pointer
  70228. * @param sprite defines the sprite to use
  70229. */
  70230. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70231. /**
  70232. * Gets the sprite under the pointer
  70233. * @returns a Sprite or null if no sprite is under the pointer
  70234. */
  70235. getPointerOverSprite(): Nullable<Sprite>;
  70236. }
  70237. /**
  70238. * Defines the sprite scene component responsible to manage sprites
  70239. * in a given scene.
  70240. */
  70241. export class SpriteSceneComponent implements ISceneComponent {
  70242. /**
  70243. * The component name helpfull to identify the component in the list of scene components.
  70244. */
  70245. readonly name: string;
  70246. /**
  70247. * The scene the component belongs to.
  70248. */
  70249. scene: Scene;
  70250. /** @hidden */
  70251. private _spritePredicate;
  70252. /**
  70253. * Creates a new instance of the component for the given scene
  70254. * @param scene Defines the scene to register the component in
  70255. */
  70256. constructor(scene: Scene);
  70257. /**
  70258. * Registers the component in a given scene
  70259. */
  70260. register(): void;
  70261. /**
  70262. * Rebuilds the elements related to this component in case of
  70263. * context lost for instance.
  70264. */
  70265. rebuild(): void;
  70266. /**
  70267. * Disposes the component and the associated ressources.
  70268. */
  70269. dispose(): void;
  70270. private _pickSpriteButKeepRay;
  70271. private _pointerMove;
  70272. private _pointerDown;
  70273. private _pointerUp;
  70274. }
  70275. }
  70276. declare module BABYLON {
  70277. /** @hidden */
  70278. export var fogFragmentDeclaration: {
  70279. name: string;
  70280. shader: string;
  70281. };
  70282. }
  70283. declare module BABYLON {
  70284. /** @hidden */
  70285. export var fogFragment: {
  70286. name: string;
  70287. shader: string;
  70288. };
  70289. }
  70290. declare module BABYLON {
  70291. /** @hidden */
  70292. export var spritesPixelShader: {
  70293. name: string;
  70294. shader: string;
  70295. };
  70296. }
  70297. declare module BABYLON {
  70298. /** @hidden */
  70299. export var fogVertexDeclaration: {
  70300. name: string;
  70301. shader: string;
  70302. };
  70303. }
  70304. declare module BABYLON {
  70305. /** @hidden */
  70306. export var spritesVertexShader: {
  70307. name: string;
  70308. shader: string;
  70309. };
  70310. }
  70311. declare module BABYLON {
  70312. /**
  70313. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70314. */
  70315. export interface ISpriteManager extends IDisposable {
  70316. /**
  70317. * Restricts the camera to viewing objects with the same layerMask.
  70318. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70319. */
  70320. layerMask: number;
  70321. /**
  70322. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70323. */
  70324. isPickable: boolean;
  70325. /**
  70326. * Specifies the rendering group id for this mesh (0 by default)
  70327. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70328. */
  70329. renderingGroupId: number;
  70330. /**
  70331. * Defines the list of sprites managed by the manager.
  70332. */
  70333. sprites: Array<Sprite>;
  70334. /**
  70335. * Tests the intersection of a sprite with a specific ray.
  70336. * @param ray The ray we are sending to test the collision
  70337. * @param camera The camera space we are sending rays in
  70338. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70339. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70340. * @returns picking info or null.
  70341. */
  70342. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70343. /**
  70344. * Renders the list of sprites on screen.
  70345. */
  70346. render(): void;
  70347. }
  70348. /**
  70349. * Class used to manage multiple sprites on the same spritesheet
  70350. * @see http://doc.babylonjs.com/babylon101/sprites
  70351. */
  70352. export class SpriteManager implements ISpriteManager {
  70353. /** defines the manager's name */
  70354. name: string;
  70355. /** Gets the list of sprites */
  70356. sprites: Sprite[];
  70357. /** Gets or sets the rendering group id (0 by default) */
  70358. renderingGroupId: number;
  70359. /** Gets or sets camera layer mask */
  70360. layerMask: number;
  70361. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70362. fogEnabled: boolean;
  70363. /** Gets or sets a boolean indicating if the sprites are pickable */
  70364. isPickable: boolean;
  70365. /** Defines the default width of a cell in the spritesheet */
  70366. cellWidth: number;
  70367. /** Defines the default height of a cell in the spritesheet */
  70368. cellHeight: number;
  70369. /**
  70370. * An event triggered when the manager is disposed.
  70371. */
  70372. onDisposeObservable: Observable<SpriteManager>;
  70373. private _onDisposeObserver;
  70374. /**
  70375. * Callback called when the manager is disposed
  70376. */
  70377. onDispose: () => void;
  70378. private _capacity;
  70379. private _spriteTexture;
  70380. private _epsilon;
  70381. private _scene;
  70382. private _vertexData;
  70383. private _buffer;
  70384. private _vertexBuffers;
  70385. private _indexBuffer;
  70386. private _effectBase;
  70387. private _effectFog;
  70388. /**
  70389. * Gets or sets the spritesheet texture
  70390. */
  70391. texture: Texture;
  70392. /**
  70393. * Creates a new sprite manager
  70394. * @param name defines the manager's name
  70395. * @param imgUrl defines the sprite sheet url
  70396. * @param capacity defines the maximum allowed number of sprites
  70397. * @param cellSize defines the size of a sprite cell
  70398. * @param scene defines the hosting scene
  70399. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70400. * @param samplingMode defines the smapling mode to use with spritesheet
  70401. */
  70402. constructor(
  70403. /** defines the manager's name */
  70404. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70405. private _appendSpriteVertex;
  70406. /**
  70407. * Intersects the sprites with a ray
  70408. * @param ray defines the ray to intersect with
  70409. * @param camera defines the current active camera
  70410. * @param predicate defines a predicate used to select candidate sprites
  70411. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70412. * @returns null if no hit or a PickingInfo
  70413. */
  70414. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70415. /**
  70416. * Render all child sprites
  70417. */
  70418. render(): void;
  70419. /**
  70420. * Release associated resources
  70421. */
  70422. dispose(): void;
  70423. }
  70424. }
  70425. declare module BABYLON {
  70426. /**
  70427. * Class used to represent a sprite
  70428. * @see http://doc.babylonjs.com/babylon101/sprites
  70429. */
  70430. export class Sprite {
  70431. /** defines the name */
  70432. name: string;
  70433. /** Gets or sets the current world position */
  70434. position: Vector3;
  70435. /** Gets or sets the main color */
  70436. color: Color4;
  70437. /** Gets or sets the width */
  70438. width: number;
  70439. /** Gets or sets the height */
  70440. height: number;
  70441. /** Gets or sets rotation angle */
  70442. angle: number;
  70443. /** Gets or sets the cell index in the sprite sheet */
  70444. cellIndex: number;
  70445. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70446. invertU: number;
  70447. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70448. invertV: number;
  70449. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70450. disposeWhenFinishedAnimating: boolean;
  70451. /** Gets the list of attached animations */
  70452. animations: Animation[];
  70453. /** Gets or sets a boolean indicating if the sprite can be picked */
  70454. isPickable: boolean;
  70455. /**
  70456. * Gets or sets the associated action manager
  70457. */
  70458. actionManager: Nullable<ActionManager>;
  70459. private _animationStarted;
  70460. private _loopAnimation;
  70461. private _fromIndex;
  70462. private _toIndex;
  70463. private _delay;
  70464. private _direction;
  70465. private _manager;
  70466. private _time;
  70467. private _onAnimationEnd;
  70468. /**
  70469. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70470. */
  70471. isVisible: boolean;
  70472. /**
  70473. * Gets or sets the sprite size
  70474. */
  70475. size: number;
  70476. /**
  70477. * Creates a new Sprite
  70478. * @param name defines the name
  70479. * @param manager defines the manager
  70480. */
  70481. constructor(
  70482. /** defines the name */
  70483. name: string, manager: ISpriteManager);
  70484. /**
  70485. * Starts an animation
  70486. * @param from defines the initial key
  70487. * @param to defines the end key
  70488. * @param loop defines if the animation must loop
  70489. * @param delay defines the start delay (in ms)
  70490. * @param onAnimationEnd defines a callback to call when animation ends
  70491. */
  70492. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70493. /** Stops current animation (if any) */
  70494. stopAnimation(): void;
  70495. /** @hidden */
  70496. _animate(deltaTime: number): void;
  70497. /** Release associated resources */
  70498. dispose(): void;
  70499. }
  70500. }
  70501. declare module BABYLON {
  70502. /**
  70503. * Information about the result of picking within a scene
  70504. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70505. */
  70506. export class PickingInfo {
  70507. /** @hidden */
  70508. _pickingUnavailable: boolean;
  70509. /**
  70510. * If the pick collided with an object
  70511. */
  70512. hit: boolean;
  70513. /**
  70514. * Distance away where the pick collided
  70515. */
  70516. distance: number;
  70517. /**
  70518. * The location of pick collision
  70519. */
  70520. pickedPoint: Nullable<Vector3>;
  70521. /**
  70522. * The mesh corresponding the the pick collision
  70523. */
  70524. pickedMesh: Nullable<AbstractMesh>;
  70525. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70526. bu: number;
  70527. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70528. bv: number;
  70529. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70530. faceId: number;
  70531. /** Id of the the submesh that was picked */
  70532. subMeshId: number;
  70533. /** If a sprite was picked, this will be the sprite the pick collided with */
  70534. pickedSprite: Nullable<Sprite>;
  70535. /**
  70536. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  70537. */
  70538. originMesh: Nullable<AbstractMesh>;
  70539. /**
  70540. * The ray that was used to perform the picking.
  70541. */
  70542. ray: Nullable<Ray>;
  70543. /**
  70544. * Gets the normal correspodning to the face the pick collided with
  70545. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  70546. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  70547. * @returns The normal correspodning to the face the pick collided with
  70548. */
  70549. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  70550. /**
  70551. * Gets the texture coordinates of where the pick occured
  70552. * @returns the vector containing the coordnates of the texture
  70553. */
  70554. getTextureCoordinates(): Nullable<Vector2>;
  70555. }
  70556. }
  70557. declare module BABYLON {
  70558. /**
  70559. * Gather the list of pointer event types as constants.
  70560. */
  70561. export class PointerEventTypes {
  70562. /**
  70563. * 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.
  70564. */
  70565. static readonly POINTERDOWN: number;
  70566. /**
  70567. * The pointerup event is fired when a pointer is no longer active.
  70568. */
  70569. static readonly POINTERUP: number;
  70570. /**
  70571. * The pointermove event is fired when a pointer changes coordinates.
  70572. */
  70573. static readonly POINTERMOVE: number;
  70574. /**
  70575. * The pointerwheel event is fired when a mouse wheel has been rotated.
  70576. */
  70577. static readonly POINTERWHEEL: number;
  70578. /**
  70579. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  70580. */
  70581. static readonly POINTERPICK: number;
  70582. /**
  70583. * The pointertap event is fired when a the object has been touched and released without drag.
  70584. */
  70585. static readonly POINTERTAP: number;
  70586. /**
  70587. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  70588. */
  70589. static readonly POINTERDOUBLETAP: number;
  70590. }
  70591. /**
  70592. * Base class of pointer info types.
  70593. */
  70594. export class PointerInfoBase {
  70595. /**
  70596. * Defines the type of event (PointerEventTypes)
  70597. */
  70598. type: number;
  70599. /**
  70600. * Defines the related dom event
  70601. */
  70602. event: PointerEvent | MouseWheelEvent;
  70603. /**
  70604. * Instantiates the base class of pointers info.
  70605. * @param type Defines the type of event (PointerEventTypes)
  70606. * @param event Defines the related dom event
  70607. */
  70608. constructor(
  70609. /**
  70610. * Defines the type of event (PointerEventTypes)
  70611. */
  70612. type: number,
  70613. /**
  70614. * Defines the related dom event
  70615. */
  70616. event: PointerEvent | MouseWheelEvent);
  70617. }
  70618. /**
  70619. * This class is used to store pointer related info for the onPrePointerObservable event.
  70620. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  70621. */
  70622. export class PointerInfoPre extends PointerInfoBase {
  70623. /**
  70624. * Ray from a pointer if availible (eg. 6dof controller)
  70625. */
  70626. ray: Nullable<Ray>;
  70627. /**
  70628. * Defines the local position of the pointer on the canvas.
  70629. */
  70630. localPosition: Vector2;
  70631. /**
  70632. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  70633. */
  70634. skipOnPointerObservable: boolean;
  70635. /**
  70636. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  70637. * @param type Defines the type of event (PointerEventTypes)
  70638. * @param event Defines the related dom event
  70639. * @param localX Defines the local x coordinates of the pointer when the event occured
  70640. * @param localY Defines the local y coordinates of the pointer when the event occured
  70641. */
  70642. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  70643. }
  70644. /**
  70645. * This type contains all the data related to a pointer event in Babylon.js.
  70646. * 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.
  70647. */
  70648. export class PointerInfo extends PointerInfoBase {
  70649. /**
  70650. * Defines the picking info associated to the info (if any)\
  70651. */
  70652. pickInfo: Nullable<PickingInfo>;
  70653. /**
  70654. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  70655. * @param type Defines the type of event (PointerEventTypes)
  70656. * @param event Defines the related dom event
  70657. * @param pickInfo Defines the picking info associated to the info (if any)\
  70658. */
  70659. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  70660. /**
  70661. * Defines the picking info associated to the info (if any)\
  70662. */
  70663. pickInfo: Nullable<PickingInfo>);
  70664. }
  70665. /**
  70666. * Data relating to a touch event on the screen.
  70667. */
  70668. export interface PointerTouch {
  70669. /**
  70670. * X coordinate of touch.
  70671. */
  70672. x: number;
  70673. /**
  70674. * Y coordinate of touch.
  70675. */
  70676. y: number;
  70677. /**
  70678. * Id of touch. Unique for each finger.
  70679. */
  70680. pointerId: number;
  70681. /**
  70682. * Event type passed from DOM.
  70683. */
  70684. type: any;
  70685. }
  70686. }
  70687. declare module BABYLON {
  70688. /**
  70689. * Manage the mouse inputs to control the movement of a free camera.
  70690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70691. */
  70692. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  70693. /**
  70694. * Define if touch is enabled in the mouse input
  70695. */
  70696. touchEnabled: boolean;
  70697. /**
  70698. * Defines the camera the input is attached to.
  70699. */
  70700. camera: FreeCamera;
  70701. /**
  70702. * Defines the buttons associated with the input to handle camera move.
  70703. */
  70704. buttons: number[];
  70705. /**
  70706. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  70707. */
  70708. angularSensibility: number;
  70709. private _pointerInput;
  70710. private _onMouseMove;
  70711. private _observer;
  70712. private previousPosition;
  70713. /**
  70714. * Manage the mouse inputs to control the movement of a free camera.
  70715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70716. * @param touchEnabled Defines if touch is enabled or not
  70717. */
  70718. constructor(
  70719. /**
  70720. * Define if touch is enabled in the mouse input
  70721. */
  70722. touchEnabled?: boolean);
  70723. /**
  70724. * Attach the input controls to a specific dom element to get the input from.
  70725. * @param element Defines the element the controls should be listened from
  70726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70727. */
  70728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70729. /**
  70730. * Called on JS contextmenu event.
  70731. * Override this method to provide functionality.
  70732. */
  70733. protected onContextMenu(evt: PointerEvent): void;
  70734. /**
  70735. * Detach the current controls from the specified dom element.
  70736. * @param element Defines the element to stop listening the inputs from
  70737. */
  70738. detachControl(element: Nullable<HTMLElement>): void;
  70739. /**
  70740. * Gets the class name of the current intput.
  70741. * @returns the class name
  70742. */
  70743. getClassName(): string;
  70744. /**
  70745. * Get the friendly name associated with the input class.
  70746. * @returns the input friendly name
  70747. */
  70748. getSimpleName(): string;
  70749. }
  70750. }
  70751. declare module BABYLON {
  70752. /**
  70753. * Manage the touch inputs to control the movement of a free camera.
  70754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70755. */
  70756. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  70757. /**
  70758. * Defines the camera the input is attached to.
  70759. */
  70760. camera: FreeCamera;
  70761. /**
  70762. * Defines the touch sensibility for rotation.
  70763. * The higher the faster.
  70764. */
  70765. touchAngularSensibility: number;
  70766. /**
  70767. * Defines the touch sensibility for move.
  70768. * The higher the faster.
  70769. */
  70770. touchMoveSensibility: number;
  70771. private _offsetX;
  70772. private _offsetY;
  70773. private _pointerPressed;
  70774. private _pointerInput;
  70775. private _observer;
  70776. private _onLostFocus;
  70777. /**
  70778. * Attach the input controls to a specific dom element to get the input from.
  70779. * @param element Defines the element the controls should be listened from
  70780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70781. */
  70782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70783. /**
  70784. * Detach the current controls from the specified dom element.
  70785. * @param element Defines the element to stop listening the inputs from
  70786. */
  70787. detachControl(element: Nullable<HTMLElement>): void;
  70788. /**
  70789. * Update the current camera state depending on the inputs that have been used this frame.
  70790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70791. */
  70792. checkInputs(): void;
  70793. /**
  70794. * Gets the class name of the current intput.
  70795. * @returns the class name
  70796. */
  70797. getClassName(): string;
  70798. /**
  70799. * Get the friendly name associated with the input class.
  70800. * @returns the input friendly name
  70801. */
  70802. getSimpleName(): string;
  70803. }
  70804. }
  70805. declare module BABYLON {
  70806. /**
  70807. * Default Inputs manager for the FreeCamera.
  70808. * It groups all the default supported inputs for ease of use.
  70809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70810. */
  70811. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70812. /**
  70813. * Instantiates a new FreeCameraInputsManager.
  70814. * @param camera Defines the camera the inputs belong to
  70815. */
  70816. constructor(camera: FreeCamera);
  70817. /**
  70818. * Add keyboard input support to the input manager.
  70819. * @returns the current input manager
  70820. */
  70821. addKeyboard(): FreeCameraInputsManager;
  70822. /**
  70823. * Add mouse input support to the input manager.
  70824. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70825. * @returns the current input manager
  70826. */
  70827. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70828. /**
  70829. * Add touch input support to the input manager.
  70830. * @returns the current input manager
  70831. */
  70832. addTouch(): FreeCameraInputsManager;
  70833. }
  70834. }
  70835. declare module BABYLON {
  70836. /**
  70837. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70838. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70839. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70840. */
  70841. export class FreeCamera extends TargetCamera {
  70842. /**
  70843. * Define the collision ellipsoid of the camera.
  70844. * This is helpful to simulate a camera body like the player body around the camera
  70845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70846. */
  70847. ellipsoid: Vector3;
  70848. /**
  70849. * Define an offset for the position of the ellipsoid around the camera.
  70850. * This can be helpful to determine the center of the body near the gravity center of the body
  70851. * instead of its head.
  70852. */
  70853. ellipsoidOffset: Vector3;
  70854. /**
  70855. * Enable or disable collisions of the camera with the rest of the scene objects.
  70856. */
  70857. checkCollisions: boolean;
  70858. /**
  70859. * Enable or disable gravity on the camera.
  70860. */
  70861. applyGravity: boolean;
  70862. /**
  70863. * Define the input manager associated to the camera.
  70864. */
  70865. inputs: FreeCameraInputsManager;
  70866. /**
  70867. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70868. * Higher values reduce sensitivity.
  70869. */
  70870. /**
  70871. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70872. * Higher values reduce sensitivity.
  70873. */
  70874. angularSensibility: number;
  70875. /**
  70876. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70877. */
  70878. keysUp: number[];
  70879. /**
  70880. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70881. */
  70882. keysDown: number[];
  70883. /**
  70884. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70885. */
  70886. keysLeft: number[];
  70887. /**
  70888. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70889. */
  70890. keysRight: number[];
  70891. /**
  70892. * Event raised when the camera collide with a mesh in the scene.
  70893. */
  70894. onCollide: (collidedMesh: AbstractMesh) => void;
  70895. private _collider;
  70896. private _needMoveForGravity;
  70897. private _oldPosition;
  70898. private _diffPosition;
  70899. private _newPosition;
  70900. /** @hidden */
  70901. _localDirection: Vector3;
  70902. /** @hidden */
  70903. _transformedDirection: Vector3;
  70904. /**
  70905. * Instantiates a Free Camera.
  70906. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70907. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70908. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70909. * @param name Define the name of the camera in the scene
  70910. * @param position Define the start position of the camera in the scene
  70911. * @param scene Define the scene the camera belongs to
  70912. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70913. */
  70914. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70915. /**
  70916. * Attached controls to the current camera.
  70917. * @param element Defines the element the controls should be listened from
  70918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70919. */
  70920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70921. /**
  70922. * Detach the current controls from the camera.
  70923. * The camera will stop reacting to inputs.
  70924. * @param element Defines the element to stop listening the inputs from
  70925. */
  70926. detachControl(element: HTMLElement): void;
  70927. private _collisionMask;
  70928. /**
  70929. * Define a collision mask to limit the list of object the camera can collide with
  70930. */
  70931. collisionMask: number;
  70932. /** @hidden */
  70933. _collideWithWorld(displacement: Vector3): void;
  70934. private _onCollisionPositionChange;
  70935. /** @hidden */
  70936. _checkInputs(): void;
  70937. /** @hidden */
  70938. _decideIfNeedsToMove(): boolean;
  70939. /** @hidden */
  70940. _updatePosition(): void;
  70941. /**
  70942. * Destroy the camera and release the current resources hold by it.
  70943. */
  70944. dispose(): void;
  70945. /**
  70946. * Gets the current object class name.
  70947. * @return the class name
  70948. */
  70949. getClassName(): string;
  70950. }
  70951. }
  70952. declare module BABYLON {
  70953. /**
  70954. * Represents a gamepad control stick position
  70955. */
  70956. export class StickValues {
  70957. /**
  70958. * The x component of the control stick
  70959. */
  70960. x: number;
  70961. /**
  70962. * The y component of the control stick
  70963. */
  70964. y: number;
  70965. /**
  70966. * Initializes the gamepad x and y control stick values
  70967. * @param x The x component of the gamepad control stick value
  70968. * @param y The y component of the gamepad control stick value
  70969. */
  70970. constructor(
  70971. /**
  70972. * The x component of the control stick
  70973. */
  70974. x: number,
  70975. /**
  70976. * The y component of the control stick
  70977. */
  70978. y: number);
  70979. }
  70980. /**
  70981. * An interface which manages callbacks for gamepad button changes
  70982. */
  70983. export interface GamepadButtonChanges {
  70984. /**
  70985. * Called when a gamepad has been changed
  70986. */
  70987. changed: boolean;
  70988. /**
  70989. * Called when a gamepad press event has been triggered
  70990. */
  70991. pressChanged: boolean;
  70992. /**
  70993. * Called when a touch event has been triggered
  70994. */
  70995. touchChanged: boolean;
  70996. /**
  70997. * Called when a value has changed
  70998. */
  70999. valueChanged: boolean;
  71000. }
  71001. /**
  71002. * Represents a gamepad
  71003. */
  71004. export class Gamepad {
  71005. /**
  71006. * The id of the gamepad
  71007. */
  71008. id: string;
  71009. /**
  71010. * The index of the gamepad
  71011. */
  71012. index: number;
  71013. /**
  71014. * The browser gamepad
  71015. */
  71016. browserGamepad: any;
  71017. /**
  71018. * Specifies what type of gamepad this represents
  71019. */
  71020. type: number;
  71021. private _leftStick;
  71022. private _rightStick;
  71023. /** @hidden */
  71024. _isConnected: boolean;
  71025. private _leftStickAxisX;
  71026. private _leftStickAxisY;
  71027. private _rightStickAxisX;
  71028. private _rightStickAxisY;
  71029. /**
  71030. * Triggered when the left control stick has been changed
  71031. */
  71032. private _onleftstickchanged;
  71033. /**
  71034. * Triggered when the right control stick has been changed
  71035. */
  71036. private _onrightstickchanged;
  71037. /**
  71038. * Represents a gamepad controller
  71039. */
  71040. static GAMEPAD: number;
  71041. /**
  71042. * Represents a generic controller
  71043. */
  71044. static GENERIC: number;
  71045. /**
  71046. * Represents an XBox controller
  71047. */
  71048. static XBOX: number;
  71049. /**
  71050. * Represents a pose-enabled controller
  71051. */
  71052. static POSE_ENABLED: number;
  71053. /**
  71054. * Specifies whether the left control stick should be Y-inverted
  71055. */
  71056. protected _invertLeftStickY: boolean;
  71057. /**
  71058. * Specifies if the gamepad has been connected
  71059. */
  71060. readonly isConnected: boolean;
  71061. /**
  71062. * Initializes the gamepad
  71063. * @param id The id of the gamepad
  71064. * @param index The index of the gamepad
  71065. * @param browserGamepad The browser gamepad
  71066. * @param leftStickX The x component of the left joystick
  71067. * @param leftStickY The y component of the left joystick
  71068. * @param rightStickX The x component of the right joystick
  71069. * @param rightStickY The y component of the right joystick
  71070. */
  71071. constructor(
  71072. /**
  71073. * The id of the gamepad
  71074. */
  71075. id: string,
  71076. /**
  71077. * The index of the gamepad
  71078. */
  71079. index: number,
  71080. /**
  71081. * The browser gamepad
  71082. */
  71083. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71084. /**
  71085. * Callback triggered when the left joystick has changed
  71086. * @param callback
  71087. */
  71088. onleftstickchanged(callback: (values: StickValues) => void): void;
  71089. /**
  71090. * Callback triggered when the right joystick has changed
  71091. * @param callback
  71092. */
  71093. onrightstickchanged(callback: (values: StickValues) => void): void;
  71094. /**
  71095. * Gets the left joystick
  71096. */
  71097. /**
  71098. * Sets the left joystick values
  71099. */
  71100. leftStick: StickValues;
  71101. /**
  71102. * Gets the right joystick
  71103. */
  71104. /**
  71105. * Sets the right joystick value
  71106. */
  71107. rightStick: StickValues;
  71108. /**
  71109. * Updates the gamepad joystick positions
  71110. */
  71111. update(): void;
  71112. /**
  71113. * Disposes the gamepad
  71114. */
  71115. dispose(): void;
  71116. }
  71117. /**
  71118. * Represents a generic gamepad
  71119. */
  71120. export class GenericPad extends Gamepad {
  71121. private _buttons;
  71122. private _onbuttondown;
  71123. private _onbuttonup;
  71124. /**
  71125. * Observable triggered when a button has been pressed
  71126. */
  71127. onButtonDownObservable: Observable<number>;
  71128. /**
  71129. * Observable triggered when a button has been released
  71130. */
  71131. onButtonUpObservable: Observable<number>;
  71132. /**
  71133. * Callback triggered when a button has been pressed
  71134. * @param callback Called when a button has been pressed
  71135. */
  71136. onbuttondown(callback: (buttonPressed: number) => void): void;
  71137. /**
  71138. * Callback triggered when a button has been released
  71139. * @param callback Called when a button has been released
  71140. */
  71141. onbuttonup(callback: (buttonReleased: number) => void): void;
  71142. /**
  71143. * Initializes the generic gamepad
  71144. * @param id The id of the generic gamepad
  71145. * @param index The index of the generic gamepad
  71146. * @param browserGamepad The browser gamepad
  71147. */
  71148. constructor(id: string, index: number, browserGamepad: any);
  71149. private _setButtonValue;
  71150. /**
  71151. * Updates the generic gamepad
  71152. */
  71153. update(): void;
  71154. /**
  71155. * Disposes the generic gamepad
  71156. */
  71157. dispose(): void;
  71158. }
  71159. }
  71160. declare module BABYLON {
  71161. /**
  71162. * Defines the types of pose enabled controllers that are supported
  71163. */
  71164. export enum PoseEnabledControllerType {
  71165. /**
  71166. * HTC Vive
  71167. */
  71168. VIVE = 0,
  71169. /**
  71170. * Oculus Rift
  71171. */
  71172. OCULUS = 1,
  71173. /**
  71174. * Windows mixed reality
  71175. */
  71176. WINDOWS = 2,
  71177. /**
  71178. * Samsung gear VR
  71179. */
  71180. GEAR_VR = 3,
  71181. /**
  71182. * Google Daydream
  71183. */
  71184. DAYDREAM = 4,
  71185. /**
  71186. * Generic
  71187. */
  71188. GENERIC = 5
  71189. }
  71190. /**
  71191. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71192. */
  71193. export interface MutableGamepadButton {
  71194. /**
  71195. * Value of the button/trigger
  71196. */
  71197. value: number;
  71198. /**
  71199. * If the button/trigger is currently touched
  71200. */
  71201. touched: boolean;
  71202. /**
  71203. * If the button/trigger is currently pressed
  71204. */
  71205. pressed: boolean;
  71206. }
  71207. /**
  71208. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71209. * @hidden
  71210. */
  71211. export interface ExtendedGamepadButton extends GamepadButton {
  71212. /**
  71213. * If the button/trigger is currently pressed
  71214. */
  71215. readonly pressed: boolean;
  71216. /**
  71217. * If the button/trigger is currently touched
  71218. */
  71219. readonly touched: boolean;
  71220. /**
  71221. * Value of the button/trigger
  71222. */
  71223. readonly value: number;
  71224. }
  71225. /** @hidden */
  71226. export interface _GamePadFactory {
  71227. /**
  71228. * Returns wether or not the current gamepad can be created for this type of controller.
  71229. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71230. * @returns true if it can be created, otherwise false
  71231. */
  71232. canCreate(gamepadInfo: any): boolean;
  71233. /**
  71234. * Creates a new instance of the Gamepad.
  71235. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71236. * @returns the new gamepad instance
  71237. */
  71238. create(gamepadInfo: any): Gamepad;
  71239. }
  71240. /**
  71241. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71242. */
  71243. export class PoseEnabledControllerHelper {
  71244. /** @hidden */
  71245. static _ControllerFactories: _GamePadFactory[];
  71246. /** @hidden */
  71247. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71248. /**
  71249. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71250. * @param vrGamepad the gamepad to initialized
  71251. * @returns a vr controller of the type the gamepad identified as
  71252. */
  71253. static InitiateController(vrGamepad: any): Gamepad;
  71254. }
  71255. /**
  71256. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71257. */
  71258. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71259. private _deviceRoomPosition;
  71260. private _deviceRoomRotationQuaternion;
  71261. /**
  71262. * The device position in babylon space
  71263. */
  71264. devicePosition: Vector3;
  71265. /**
  71266. * The device rotation in babylon space
  71267. */
  71268. deviceRotationQuaternion: Quaternion;
  71269. /**
  71270. * The scale factor of the device in babylon space
  71271. */
  71272. deviceScaleFactor: number;
  71273. /**
  71274. * (Likely devicePosition should be used instead) The device position in its room space
  71275. */
  71276. position: Vector3;
  71277. /**
  71278. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71279. */
  71280. rotationQuaternion: Quaternion;
  71281. /**
  71282. * The type of controller (Eg. Windows mixed reality)
  71283. */
  71284. controllerType: PoseEnabledControllerType;
  71285. protected _calculatedPosition: Vector3;
  71286. private _calculatedRotation;
  71287. /**
  71288. * The raw pose from the device
  71289. */
  71290. rawPose: DevicePose;
  71291. private _trackPosition;
  71292. private _maxRotationDistFromHeadset;
  71293. private _draggedRoomRotation;
  71294. /**
  71295. * @hidden
  71296. */
  71297. _disableTrackPosition(fixedPosition: Vector3): void;
  71298. /**
  71299. * Internal, the mesh attached to the controller
  71300. * @hidden
  71301. */
  71302. _mesh: Nullable<AbstractMesh>;
  71303. private _poseControlledCamera;
  71304. private _leftHandSystemQuaternion;
  71305. /**
  71306. * Internal, matrix used to convert room space to babylon space
  71307. * @hidden
  71308. */
  71309. _deviceToWorld: Matrix;
  71310. /**
  71311. * Node to be used when casting a ray from the controller
  71312. * @hidden
  71313. */
  71314. _pointingPoseNode: Nullable<TransformNode>;
  71315. /**
  71316. * Name of the child mesh that can be used to cast a ray from the controller
  71317. */
  71318. static readonly POINTING_POSE: string;
  71319. /**
  71320. * Creates a new PoseEnabledController from a gamepad
  71321. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71322. */
  71323. constructor(browserGamepad: any);
  71324. private _workingMatrix;
  71325. /**
  71326. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71327. */
  71328. update(): void;
  71329. /**
  71330. * Updates only the pose device and mesh without doing any button event checking
  71331. */
  71332. protected _updatePoseAndMesh(): void;
  71333. /**
  71334. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71335. * @param poseData raw pose fromthe device
  71336. */
  71337. updateFromDevice(poseData: DevicePose): void;
  71338. /**
  71339. * @hidden
  71340. */
  71341. _meshAttachedObservable: Observable<AbstractMesh>;
  71342. /**
  71343. * Attaches a mesh to the controller
  71344. * @param mesh the mesh to be attached
  71345. */
  71346. attachToMesh(mesh: AbstractMesh): void;
  71347. /**
  71348. * Attaches the controllers mesh to a camera
  71349. * @param camera the camera the mesh should be attached to
  71350. */
  71351. attachToPoseControlledCamera(camera: TargetCamera): void;
  71352. /**
  71353. * Disposes of the controller
  71354. */
  71355. dispose(): void;
  71356. /**
  71357. * The mesh that is attached to the controller
  71358. */
  71359. readonly mesh: Nullable<AbstractMesh>;
  71360. /**
  71361. * Gets the ray of the controller in the direction the controller is pointing
  71362. * @param length the length the resulting ray should be
  71363. * @returns a ray in the direction the controller is pointing
  71364. */
  71365. getForwardRay(length?: number): Ray;
  71366. }
  71367. }
  71368. declare module BABYLON {
  71369. /**
  71370. * Defines the WebVRController object that represents controllers tracked in 3D space
  71371. */
  71372. export abstract class WebVRController extends PoseEnabledController {
  71373. /**
  71374. * Internal, the default controller model for the controller
  71375. */
  71376. protected _defaultModel: AbstractMesh;
  71377. /**
  71378. * Fired when the trigger state has changed
  71379. */
  71380. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71381. /**
  71382. * Fired when the main button state has changed
  71383. */
  71384. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71385. /**
  71386. * Fired when the secondary button state has changed
  71387. */
  71388. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71389. /**
  71390. * Fired when the pad state has changed
  71391. */
  71392. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71393. /**
  71394. * Fired when controllers stick values have changed
  71395. */
  71396. onPadValuesChangedObservable: Observable<StickValues>;
  71397. /**
  71398. * Array of button availible on the controller
  71399. */
  71400. protected _buttons: Array<MutableGamepadButton>;
  71401. private _onButtonStateChange;
  71402. /**
  71403. * Fired when a controller button's state has changed
  71404. * @param callback the callback containing the button that was modified
  71405. */
  71406. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71407. /**
  71408. * X and Y axis corrisponding to the controllers joystick
  71409. */
  71410. pad: StickValues;
  71411. /**
  71412. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71413. */
  71414. hand: string;
  71415. /**
  71416. * The default controller model for the controller
  71417. */
  71418. readonly defaultModel: AbstractMesh;
  71419. /**
  71420. * Creates a new WebVRController from a gamepad
  71421. * @param vrGamepad the gamepad that the WebVRController should be created from
  71422. */
  71423. constructor(vrGamepad: any);
  71424. /**
  71425. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71426. */
  71427. update(): void;
  71428. /**
  71429. * Function to be called when a button is modified
  71430. */
  71431. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71432. /**
  71433. * Loads a mesh and attaches it to the controller
  71434. * @param scene the scene the mesh should be added to
  71435. * @param meshLoaded callback for when the mesh has been loaded
  71436. */
  71437. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71438. private _setButtonValue;
  71439. private _changes;
  71440. private _checkChanges;
  71441. /**
  71442. * Disposes of th webVRCOntroller
  71443. */
  71444. dispose(): void;
  71445. }
  71446. }
  71447. declare module BABYLON {
  71448. /**
  71449. * The HemisphericLight simulates the ambient environment light,
  71450. * so the passed direction is the light reflection direction, not the incoming direction.
  71451. */
  71452. export class HemisphericLight extends Light {
  71453. /**
  71454. * The groundColor is the light in the opposite direction to the one specified during creation.
  71455. * 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.
  71456. */
  71457. groundColor: Color3;
  71458. /**
  71459. * The light reflection direction, not the incoming direction.
  71460. */
  71461. direction: Vector3;
  71462. /**
  71463. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71464. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71465. * The HemisphericLight can't cast shadows.
  71466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71467. * @param name The friendly name of the light
  71468. * @param direction The direction of the light reflection
  71469. * @param scene The scene the light belongs to
  71470. */
  71471. constructor(name: string, direction: Vector3, scene: Scene);
  71472. protected _buildUniformLayout(): void;
  71473. /**
  71474. * Returns the string "HemisphericLight".
  71475. * @return The class name
  71476. */
  71477. getClassName(): string;
  71478. /**
  71479. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71480. * Returns the updated direction.
  71481. * @param target The target the direction should point to
  71482. * @return The computed direction
  71483. */
  71484. setDirectionToTarget(target: Vector3): Vector3;
  71485. /**
  71486. * Returns the shadow generator associated to the light.
  71487. * @returns Always null for hemispheric lights because it does not support shadows.
  71488. */
  71489. getShadowGenerator(): Nullable<IShadowGenerator>;
  71490. /**
  71491. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71492. * @param effect The effect to update
  71493. * @param lightIndex The index of the light in the effect to update
  71494. * @returns The hemispheric light
  71495. */
  71496. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71497. /**
  71498. * Computes the world matrix of the node
  71499. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71500. * @param useWasUpdatedFlag defines a reserved property
  71501. * @returns the world matrix
  71502. */
  71503. computeWorldMatrix(): Matrix;
  71504. /**
  71505. * Returns the integer 3.
  71506. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71507. */
  71508. getTypeID(): number;
  71509. /**
  71510. * Prepares the list of defines specific to the light type.
  71511. * @param defines the list of defines
  71512. * @param lightIndex defines the index of the light for the effect
  71513. */
  71514. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  71515. }
  71516. }
  71517. declare module BABYLON {
  71518. /**
  71519. * This represents all the required metrics to create a VR camera.
  71520. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  71521. */
  71522. export class VRCameraMetrics {
  71523. /**
  71524. * Define the horizontal resolution off the screen.
  71525. */
  71526. hResolution: number;
  71527. /**
  71528. * Define the vertical resolution off the screen.
  71529. */
  71530. vResolution: number;
  71531. /**
  71532. * Define the horizontal screen size.
  71533. */
  71534. hScreenSize: number;
  71535. /**
  71536. * Define the vertical screen size.
  71537. */
  71538. vScreenSize: number;
  71539. /**
  71540. * Define the vertical screen center position.
  71541. */
  71542. vScreenCenter: number;
  71543. /**
  71544. * Define the distance of the eyes to the screen.
  71545. */
  71546. eyeToScreenDistance: number;
  71547. /**
  71548. * Define the distance between both lenses
  71549. */
  71550. lensSeparationDistance: number;
  71551. /**
  71552. * Define the distance between both viewer's eyes.
  71553. */
  71554. interpupillaryDistance: number;
  71555. /**
  71556. * Define the distortion factor of the VR postprocess.
  71557. * Please, touch with care.
  71558. */
  71559. distortionK: number[];
  71560. /**
  71561. * Define the chromatic aberration correction factors for the VR post process.
  71562. */
  71563. chromaAbCorrection: number[];
  71564. /**
  71565. * Define the scale factor of the post process.
  71566. * The smaller the better but the slower.
  71567. */
  71568. postProcessScaleFactor: number;
  71569. /**
  71570. * Define an offset for the lens center.
  71571. */
  71572. lensCenterOffset: number;
  71573. /**
  71574. * Define if the current vr camera should compensate the distortion of the lense or not.
  71575. */
  71576. compensateDistortion: boolean;
  71577. /**
  71578. * Defines if multiview should be enabled when rendering (Default: false)
  71579. */
  71580. multiviewEnabled: boolean;
  71581. /**
  71582. * Gets the rendering aspect ratio based on the provided resolutions.
  71583. */
  71584. readonly aspectRatio: number;
  71585. /**
  71586. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  71587. */
  71588. readonly aspectRatioFov: number;
  71589. /**
  71590. * @hidden
  71591. */
  71592. readonly leftHMatrix: Matrix;
  71593. /**
  71594. * @hidden
  71595. */
  71596. readonly rightHMatrix: Matrix;
  71597. /**
  71598. * @hidden
  71599. */
  71600. readonly leftPreViewMatrix: Matrix;
  71601. /**
  71602. * @hidden
  71603. */
  71604. readonly rightPreViewMatrix: Matrix;
  71605. /**
  71606. * Get the default VRMetrics based on the most generic setup.
  71607. * @returns the default vr metrics
  71608. */
  71609. static GetDefault(): VRCameraMetrics;
  71610. }
  71611. }
  71612. declare module BABYLON {
  71613. /** @hidden */
  71614. export var vrDistortionCorrectionPixelShader: {
  71615. name: string;
  71616. shader: string;
  71617. };
  71618. }
  71619. declare module BABYLON {
  71620. /**
  71621. * VRDistortionCorrectionPostProcess used for mobile VR
  71622. */
  71623. export class VRDistortionCorrectionPostProcess extends PostProcess {
  71624. private _isRightEye;
  71625. private _distortionFactors;
  71626. private _postProcessScaleFactor;
  71627. private _lensCenterOffset;
  71628. private _scaleIn;
  71629. private _scaleFactor;
  71630. private _lensCenter;
  71631. /**
  71632. * Initializes the VRDistortionCorrectionPostProcess
  71633. * @param name The name of the effect.
  71634. * @param camera The camera to apply the render pass to.
  71635. * @param isRightEye If this is for the right eye distortion
  71636. * @param vrMetrics All the required metrics for the VR camera
  71637. */
  71638. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  71639. }
  71640. /**
  71641. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  71642. * This will not be used for webXR as it supports displaying texture arrays directly
  71643. */
  71644. export class VRMultiviewToSingleview extends PostProcess {
  71645. /**
  71646. * Initializes a VRMultiviewToSingleview
  71647. * @param name name of the post process
  71648. * @param camera camera to be applied to
  71649. * @param scaleFactor scaling factor to the size of the output texture
  71650. */
  71651. constructor(name: string, camera: Camera, scaleFactor: number);
  71652. }
  71653. }
  71654. declare module BABYLON {
  71655. /**
  71656. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  71657. * IMPORTANT!! The data is right-hand data.
  71658. * @export
  71659. * @interface DevicePose
  71660. */
  71661. export interface DevicePose {
  71662. /**
  71663. * The position of the device, values in array are [x,y,z].
  71664. */
  71665. readonly position: Nullable<Float32Array>;
  71666. /**
  71667. * The linearVelocity of the device, values in array are [x,y,z].
  71668. */
  71669. readonly linearVelocity: Nullable<Float32Array>;
  71670. /**
  71671. * The linearAcceleration of the device, values in array are [x,y,z].
  71672. */
  71673. readonly linearAcceleration: Nullable<Float32Array>;
  71674. /**
  71675. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  71676. */
  71677. readonly orientation: Nullable<Float32Array>;
  71678. /**
  71679. * The angularVelocity of the device, values in array are [x,y,z].
  71680. */
  71681. readonly angularVelocity: Nullable<Float32Array>;
  71682. /**
  71683. * The angularAcceleration of the device, values in array are [x,y,z].
  71684. */
  71685. readonly angularAcceleration: Nullable<Float32Array>;
  71686. }
  71687. /**
  71688. * Interface representing a pose controlled object in Babylon.
  71689. * A pose controlled object has both regular pose values as well as pose values
  71690. * from an external device such as a VR head mounted display
  71691. */
  71692. export interface PoseControlled {
  71693. /**
  71694. * The position of the object in babylon space.
  71695. */
  71696. position: Vector3;
  71697. /**
  71698. * The rotation quaternion of the object in babylon space.
  71699. */
  71700. rotationQuaternion: Quaternion;
  71701. /**
  71702. * The position of the device in babylon space.
  71703. */
  71704. devicePosition?: Vector3;
  71705. /**
  71706. * The rotation quaternion of the device in babylon space.
  71707. */
  71708. deviceRotationQuaternion: Quaternion;
  71709. /**
  71710. * The raw pose coming from the device.
  71711. */
  71712. rawPose: Nullable<DevicePose>;
  71713. /**
  71714. * The scale of the device to be used when translating from device space to babylon space.
  71715. */
  71716. deviceScaleFactor: number;
  71717. /**
  71718. * Updates the poseControlled values based on the input device pose.
  71719. * @param poseData the pose data to update the object with
  71720. */
  71721. updateFromDevice(poseData: DevicePose): void;
  71722. }
  71723. /**
  71724. * Set of options to customize the webVRCamera
  71725. */
  71726. export interface WebVROptions {
  71727. /**
  71728. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  71729. */
  71730. trackPosition?: boolean;
  71731. /**
  71732. * Sets the scale of the vrDevice in babylon space. (default: 1)
  71733. */
  71734. positionScale?: number;
  71735. /**
  71736. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  71737. */
  71738. displayName?: string;
  71739. /**
  71740. * Should the native controller meshes be initialized. (default: true)
  71741. */
  71742. controllerMeshes?: boolean;
  71743. /**
  71744. * Creating a default HemiLight only on controllers. (default: true)
  71745. */
  71746. defaultLightingOnControllers?: boolean;
  71747. /**
  71748. * If you don't want to use the default VR button of the helper. (default: false)
  71749. */
  71750. useCustomVRButton?: boolean;
  71751. /**
  71752. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  71753. */
  71754. customVRButton?: HTMLButtonElement;
  71755. /**
  71756. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  71757. */
  71758. rayLength?: number;
  71759. /**
  71760. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  71761. */
  71762. defaultHeight?: number;
  71763. /**
  71764. * If multiview should be used if availible (default: false)
  71765. */
  71766. useMultiview?: boolean;
  71767. }
  71768. /**
  71769. * This represents a WebVR camera.
  71770. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  71771. * @example http://doc.babylonjs.com/how_to/webvr_camera
  71772. */
  71773. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  71774. private webVROptions;
  71775. /**
  71776. * @hidden
  71777. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  71778. */
  71779. _vrDevice: any;
  71780. /**
  71781. * The rawPose of the vrDevice.
  71782. */
  71783. rawPose: Nullable<DevicePose>;
  71784. private _onVREnabled;
  71785. private _specsVersion;
  71786. private _attached;
  71787. private _frameData;
  71788. protected _descendants: Array<Node>;
  71789. private _deviceRoomPosition;
  71790. /** @hidden */
  71791. _deviceRoomRotationQuaternion: Quaternion;
  71792. private _standingMatrix;
  71793. /**
  71794. * Represents device position in babylon space.
  71795. */
  71796. devicePosition: Vector3;
  71797. /**
  71798. * Represents device rotation in babylon space.
  71799. */
  71800. deviceRotationQuaternion: Quaternion;
  71801. /**
  71802. * The scale of the device to be used when translating from device space to babylon space.
  71803. */
  71804. deviceScaleFactor: number;
  71805. private _deviceToWorld;
  71806. private _worldToDevice;
  71807. /**
  71808. * References to the webVR controllers for the vrDevice.
  71809. */
  71810. controllers: Array<WebVRController>;
  71811. /**
  71812. * Emits an event when a controller is attached.
  71813. */
  71814. onControllersAttachedObservable: Observable<WebVRController[]>;
  71815. /**
  71816. * Emits an event when a controller's mesh has been loaded;
  71817. */
  71818. onControllerMeshLoadedObservable: Observable<WebVRController>;
  71819. /**
  71820. * Emits an event when the HMD's pose has been updated.
  71821. */
  71822. onPoseUpdatedFromDeviceObservable: Observable<any>;
  71823. private _poseSet;
  71824. /**
  71825. * If the rig cameras be used as parent instead of this camera.
  71826. */
  71827. rigParenting: boolean;
  71828. private _lightOnControllers;
  71829. private _defaultHeight?;
  71830. /**
  71831. * Instantiates a WebVRFreeCamera.
  71832. * @param name The name of the WebVRFreeCamera
  71833. * @param position The starting anchor position for the camera
  71834. * @param scene The scene the camera belongs to
  71835. * @param webVROptions a set of customizable options for the webVRCamera
  71836. */
  71837. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  71838. /**
  71839. * Gets the device distance from the ground in meters.
  71840. * @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.
  71841. */
  71842. deviceDistanceToRoomGround(): number;
  71843. /**
  71844. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71845. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  71846. */
  71847. useStandingMatrix(callback?: (bool: boolean) => void): void;
  71848. /**
  71849. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71850. * @returns A promise with a boolean set to if the standing matrix is supported.
  71851. */
  71852. useStandingMatrixAsync(): Promise<boolean>;
  71853. /**
  71854. * Disposes the camera
  71855. */
  71856. dispose(): void;
  71857. /**
  71858. * Gets a vrController by name.
  71859. * @param name The name of the controller to retreive
  71860. * @returns the controller matching the name specified or null if not found
  71861. */
  71862. getControllerByName(name: string): Nullable<WebVRController>;
  71863. private _leftController;
  71864. /**
  71865. * The controller corrisponding to the users left hand.
  71866. */
  71867. readonly leftController: Nullable<WebVRController>;
  71868. private _rightController;
  71869. /**
  71870. * The controller corrisponding to the users right hand.
  71871. */
  71872. readonly rightController: Nullable<WebVRController>;
  71873. /**
  71874. * Casts a ray forward from the vrCamera's gaze.
  71875. * @param length Length of the ray (default: 100)
  71876. * @returns the ray corrisponding to the gaze
  71877. */
  71878. getForwardRay(length?: number): Ray;
  71879. /**
  71880. * @hidden
  71881. * Updates the camera based on device's frame data
  71882. */
  71883. _checkInputs(): void;
  71884. /**
  71885. * Updates the poseControlled values based on the input device pose.
  71886. * @param poseData Pose coming from the device
  71887. */
  71888. updateFromDevice(poseData: DevicePose): void;
  71889. private _htmlElementAttached;
  71890. private _detachIfAttached;
  71891. /**
  71892. * WebVR's attach control will start broadcasting frames to the device.
  71893. * Note that in certain browsers (chrome for example) this function must be called
  71894. * within a user-interaction callback. Example:
  71895. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  71896. *
  71897. * @param element html element to attach the vrDevice to
  71898. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  71899. */
  71900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71901. /**
  71902. * Detaches the camera from the html element and disables VR
  71903. *
  71904. * @param element html element to detach from
  71905. */
  71906. detachControl(element: HTMLElement): void;
  71907. /**
  71908. * @returns the name of this class
  71909. */
  71910. getClassName(): string;
  71911. /**
  71912. * Calls resetPose on the vrDisplay
  71913. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  71914. */
  71915. resetToCurrentRotation(): void;
  71916. /**
  71917. * @hidden
  71918. * Updates the rig cameras (left and right eye)
  71919. */
  71920. _updateRigCameras(): void;
  71921. private _workingVector;
  71922. private _oneVector;
  71923. private _workingMatrix;
  71924. private updateCacheCalled;
  71925. private _correctPositionIfNotTrackPosition;
  71926. /**
  71927. * @hidden
  71928. * Updates the cached values of the camera
  71929. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  71930. */
  71931. _updateCache(ignoreParentClass?: boolean): void;
  71932. /**
  71933. * @hidden
  71934. * Get current device position in babylon world
  71935. */
  71936. _computeDevicePosition(): void;
  71937. /**
  71938. * Updates the current device position and rotation in the babylon world
  71939. */
  71940. update(): void;
  71941. /**
  71942. * @hidden
  71943. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  71944. * @returns an identity matrix
  71945. */
  71946. _getViewMatrix(): Matrix;
  71947. private _tmpMatrix;
  71948. /**
  71949. * This function is called by the two RIG cameras.
  71950. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71951. * @hidden
  71952. */
  71953. _getWebVRViewMatrix(): Matrix;
  71954. /** @hidden */
  71955. _getWebVRProjectionMatrix(): Matrix;
  71956. private _onGamepadConnectedObserver;
  71957. private _onGamepadDisconnectedObserver;
  71958. private _updateCacheWhenTrackingDisabledObserver;
  71959. /**
  71960. * Initializes the controllers and their meshes
  71961. */
  71962. initControllers(): void;
  71963. }
  71964. }
  71965. declare module BABYLON {
  71966. /**
  71967. * Size options for a post process
  71968. */
  71969. export type PostProcessOptions = {
  71970. width: number;
  71971. height: number;
  71972. };
  71973. /**
  71974. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71975. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71976. */
  71977. export class PostProcess {
  71978. /** Name of the PostProcess. */
  71979. name: string;
  71980. /**
  71981. * Gets or sets the unique id of the post process
  71982. */
  71983. uniqueId: number;
  71984. /**
  71985. * Width of the texture to apply the post process on
  71986. */
  71987. width: number;
  71988. /**
  71989. * Height of the texture to apply the post process on
  71990. */
  71991. height: number;
  71992. /**
  71993. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71994. * @hidden
  71995. */
  71996. _outputTexture: Nullable<InternalTexture>;
  71997. /**
  71998. * Sampling mode used by the shader
  71999. * See https://doc.babylonjs.com/classes/3.1/texture
  72000. */
  72001. renderTargetSamplingMode: number;
  72002. /**
  72003. * Clear color to use when screen clearing
  72004. */
  72005. clearColor: Color4;
  72006. /**
  72007. * If the buffer needs to be cleared before applying the post process. (default: true)
  72008. * Should be set to false if shader will overwrite all previous pixels.
  72009. */
  72010. autoClear: boolean;
  72011. /**
  72012. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72013. */
  72014. alphaMode: number;
  72015. /**
  72016. * Sets the setAlphaBlendConstants of the babylon engine
  72017. */
  72018. alphaConstants: Color4;
  72019. /**
  72020. * Animations to be used for the post processing
  72021. */
  72022. animations: Animation[];
  72023. /**
  72024. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72025. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72026. */
  72027. enablePixelPerfectMode: boolean;
  72028. /**
  72029. * Force the postprocess to be applied without taking in account viewport
  72030. */
  72031. forceFullscreenViewport: boolean;
  72032. /**
  72033. * List of inspectable custom properties (used by the Inspector)
  72034. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72035. */
  72036. inspectableCustomProperties: IInspectable[];
  72037. /**
  72038. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72039. *
  72040. * | Value | Type | Description |
  72041. * | ----- | ----------------------------------- | ----------- |
  72042. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72043. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72044. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72045. *
  72046. */
  72047. scaleMode: number;
  72048. /**
  72049. * Force textures to be a power of two (default: false)
  72050. */
  72051. alwaysForcePOT: boolean;
  72052. private _samples;
  72053. /**
  72054. * Number of sample textures (default: 1)
  72055. */
  72056. samples: number;
  72057. /**
  72058. * Modify the scale of the post process to be the same as the viewport (default: false)
  72059. */
  72060. adaptScaleToCurrentViewport: boolean;
  72061. private _camera;
  72062. private _scene;
  72063. private _engine;
  72064. private _options;
  72065. private _reusable;
  72066. private _textureType;
  72067. /**
  72068. * Smart array of input and output textures for the post process.
  72069. * @hidden
  72070. */
  72071. _textures: SmartArray<InternalTexture>;
  72072. /**
  72073. * The index in _textures that corresponds to the output texture.
  72074. * @hidden
  72075. */
  72076. _currentRenderTextureInd: number;
  72077. private _effect;
  72078. private _samplers;
  72079. private _fragmentUrl;
  72080. private _vertexUrl;
  72081. private _parameters;
  72082. private _scaleRatio;
  72083. protected _indexParameters: any;
  72084. private _shareOutputWithPostProcess;
  72085. private _texelSize;
  72086. private _forcedOutputTexture;
  72087. /**
  72088. * Returns the fragment url or shader name used in the post process.
  72089. * @returns the fragment url or name in the shader store.
  72090. */
  72091. getEffectName(): string;
  72092. /**
  72093. * An event triggered when the postprocess is activated.
  72094. */
  72095. onActivateObservable: Observable<Camera>;
  72096. private _onActivateObserver;
  72097. /**
  72098. * A function that is added to the onActivateObservable
  72099. */
  72100. onActivate: Nullable<(camera: Camera) => void>;
  72101. /**
  72102. * An event triggered when the postprocess changes its size.
  72103. */
  72104. onSizeChangedObservable: Observable<PostProcess>;
  72105. private _onSizeChangedObserver;
  72106. /**
  72107. * A function that is added to the onSizeChangedObservable
  72108. */
  72109. onSizeChanged: (postProcess: PostProcess) => void;
  72110. /**
  72111. * An event triggered when the postprocess applies its effect.
  72112. */
  72113. onApplyObservable: Observable<Effect>;
  72114. private _onApplyObserver;
  72115. /**
  72116. * A function that is added to the onApplyObservable
  72117. */
  72118. onApply: (effect: Effect) => void;
  72119. /**
  72120. * An event triggered before rendering the postprocess
  72121. */
  72122. onBeforeRenderObservable: Observable<Effect>;
  72123. private _onBeforeRenderObserver;
  72124. /**
  72125. * A function that is added to the onBeforeRenderObservable
  72126. */
  72127. onBeforeRender: (effect: Effect) => void;
  72128. /**
  72129. * An event triggered after rendering the postprocess
  72130. */
  72131. onAfterRenderObservable: Observable<Effect>;
  72132. private _onAfterRenderObserver;
  72133. /**
  72134. * A function that is added to the onAfterRenderObservable
  72135. */
  72136. onAfterRender: (efect: Effect) => void;
  72137. /**
  72138. * 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
  72139. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72140. */
  72141. inputTexture: InternalTexture;
  72142. /**
  72143. * Gets the camera which post process is applied to.
  72144. * @returns The camera the post process is applied to.
  72145. */
  72146. getCamera(): Camera;
  72147. /**
  72148. * Gets the texel size of the postprocess.
  72149. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72150. */
  72151. readonly texelSize: Vector2;
  72152. /**
  72153. * Creates a new instance PostProcess
  72154. * @param name The name of the PostProcess.
  72155. * @param fragmentUrl The url of the fragment shader to be used.
  72156. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72157. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72158. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72159. * @param camera The camera to apply the render pass to.
  72160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72161. * @param engine The engine which the post process will be applied. (default: current engine)
  72162. * @param reusable If the post process can be reused on the same frame. (default: false)
  72163. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72164. * @param textureType Type of textures used when performing the post process. (default: 0)
  72165. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72166. * @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
  72167. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72168. */
  72169. constructor(
  72170. /** Name of the PostProcess. */
  72171. 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);
  72172. /**
  72173. * Gets a string idenfifying the name of the class
  72174. * @returns "PostProcess" string
  72175. */
  72176. getClassName(): string;
  72177. /**
  72178. * Gets the engine which this post process belongs to.
  72179. * @returns The engine the post process was enabled with.
  72180. */
  72181. getEngine(): Engine;
  72182. /**
  72183. * The effect that is created when initializing the post process.
  72184. * @returns The created effect corrisponding the the postprocess.
  72185. */
  72186. getEffect(): Effect;
  72187. /**
  72188. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72189. * @param postProcess The post process to share the output with.
  72190. * @returns This post process.
  72191. */
  72192. shareOutputWith(postProcess: PostProcess): PostProcess;
  72193. /**
  72194. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72195. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72196. */
  72197. useOwnOutput(): void;
  72198. /**
  72199. * Updates the effect with the current post process compile time values and recompiles the shader.
  72200. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72201. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72202. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72203. * @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
  72204. * @param onCompiled Called when the shader has been compiled.
  72205. * @param onError Called if there is an error when compiling a shader.
  72206. */
  72207. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72208. /**
  72209. * The post process is reusable if it can be used multiple times within one frame.
  72210. * @returns If the post process is reusable
  72211. */
  72212. isReusable(): boolean;
  72213. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72214. markTextureDirty(): void;
  72215. /**
  72216. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72217. * 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.
  72218. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72219. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72220. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72221. * @returns The target texture that was bound to be written to.
  72222. */
  72223. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72224. /**
  72225. * If the post process is supported.
  72226. */
  72227. readonly isSupported: boolean;
  72228. /**
  72229. * The aspect ratio of the output texture.
  72230. */
  72231. readonly aspectRatio: number;
  72232. /**
  72233. * Get a value indicating if the post-process is ready to be used
  72234. * @returns true if the post-process is ready (shader is compiled)
  72235. */
  72236. isReady(): boolean;
  72237. /**
  72238. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72239. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72240. */
  72241. apply(): Nullable<Effect>;
  72242. private _disposeTextures;
  72243. /**
  72244. * Disposes the post process.
  72245. * @param camera The camera to dispose the post process on.
  72246. */
  72247. dispose(camera?: Camera): void;
  72248. }
  72249. }
  72250. declare module BABYLON {
  72251. /**
  72252. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72253. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72254. */
  72255. export class PostProcessManager {
  72256. private _scene;
  72257. private _indexBuffer;
  72258. private _vertexBuffers;
  72259. /**
  72260. * Creates a new instance PostProcess
  72261. * @param scene The scene that the post process is associated with.
  72262. */
  72263. constructor(scene: Scene);
  72264. private _prepareBuffers;
  72265. private _buildIndexBuffer;
  72266. /**
  72267. * Rebuilds the vertex buffers of the manager.
  72268. * @hidden
  72269. */
  72270. _rebuild(): void;
  72271. /**
  72272. * Prepares a frame to be run through a post process.
  72273. * @param sourceTexture The input texture to the post procesess. (default: null)
  72274. * @param postProcesses An array of post processes to be run. (default: null)
  72275. * @returns True if the post processes were able to be run.
  72276. * @hidden
  72277. */
  72278. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72279. /**
  72280. * Manually render a set of post processes to a texture.
  72281. * @param postProcesses An array of post processes to be run.
  72282. * @param targetTexture The target texture to render to.
  72283. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72284. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72285. * @param lodLevel defines which lod of the texture to render to
  72286. */
  72287. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72288. /**
  72289. * Finalize the result of the output of the postprocesses.
  72290. * @param doNotPresent If true the result will not be displayed to the screen.
  72291. * @param targetTexture The target texture to render to.
  72292. * @param faceIndex The index of the face to bind the target texture to.
  72293. * @param postProcesses The array of post processes to render.
  72294. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  72295. * @hidden
  72296. */
  72297. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  72298. /**
  72299. * Disposes of the post process manager.
  72300. */
  72301. dispose(): void;
  72302. }
  72303. }
  72304. declare module BABYLON {
  72305. interface AbstractScene {
  72306. /**
  72307. * The list of layers (background and foreground) of the scene
  72308. */
  72309. layers: Array<Layer>;
  72310. }
  72311. /**
  72312. * Defines the layer scene component responsible to manage any layers
  72313. * in a given scene.
  72314. */
  72315. export class LayerSceneComponent implements ISceneComponent {
  72316. /**
  72317. * The component name helpfull to identify the component in the list of scene components.
  72318. */
  72319. readonly name: string;
  72320. /**
  72321. * The scene the component belongs to.
  72322. */
  72323. scene: Scene;
  72324. private _engine;
  72325. /**
  72326. * Creates a new instance of the component for the given scene
  72327. * @param scene Defines the scene to register the component in
  72328. */
  72329. constructor(scene: Scene);
  72330. /**
  72331. * Registers the component in a given scene
  72332. */
  72333. register(): void;
  72334. /**
  72335. * Rebuilds the elements related to this component in case of
  72336. * context lost for instance.
  72337. */
  72338. rebuild(): void;
  72339. /**
  72340. * Disposes the component and the associated ressources.
  72341. */
  72342. dispose(): void;
  72343. private _draw;
  72344. private _drawCameraPredicate;
  72345. private _drawCameraBackground;
  72346. private _drawCameraForeground;
  72347. private _drawRenderTargetPredicate;
  72348. private _drawRenderTargetBackground;
  72349. private _drawRenderTargetForeground;
  72350. }
  72351. }
  72352. declare module BABYLON {
  72353. /** @hidden */
  72354. export var layerPixelShader: {
  72355. name: string;
  72356. shader: string;
  72357. };
  72358. }
  72359. declare module BABYLON {
  72360. /** @hidden */
  72361. export var layerVertexShader: {
  72362. name: string;
  72363. shader: string;
  72364. };
  72365. }
  72366. declare module BABYLON {
  72367. /**
  72368. * This represents a full screen 2d layer.
  72369. * This can be useful to display a picture in the background of your scene for instance.
  72370. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72371. */
  72372. export class Layer {
  72373. /**
  72374. * Define the name of the layer.
  72375. */
  72376. name: string;
  72377. /**
  72378. * Define the texture the layer should display.
  72379. */
  72380. texture: Nullable<Texture>;
  72381. /**
  72382. * Is the layer in background or foreground.
  72383. */
  72384. isBackground: boolean;
  72385. /**
  72386. * Define the color of the layer (instead of texture).
  72387. */
  72388. color: Color4;
  72389. /**
  72390. * Define the scale of the layer in order to zoom in out of the texture.
  72391. */
  72392. scale: Vector2;
  72393. /**
  72394. * Define an offset for the layer in order to shift the texture.
  72395. */
  72396. offset: Vector2;
  72397. /**
  72398. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72399. */
  72400. alphaBlendingMode: number;
  72401. /**
  72402. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72403. * Alpha test will not mix with the background color in case of transparency.
  72404. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72405. */
  72406. alphaTest: boolean;
  72407. /**
  72408. * Define a mask to restrict the layer to only some of the scene cameras.
  72409. */
  72410. layerMask: number;
  72411. /**
  72412. * Define the list of render target the layer is visible into.
  72413. */
  72414. renderTargetTextures: RenderTargetTexture[];
  72415. /**
  72416. * Define if the layer is only used in renderTarget or if it also
  72417. * renders in the main frame buffer of the canvas.
  72418. */
  72419. renderOnlyInRenderTargetTextures: boolean;
  72420. private _scene;
  72421. private _vertexBuffers;
  72422. private _indexBuffer;
  72423. private _effect;
  72424. private _alphaTestEffect;
  72425. /**
  72426. * An event triggered when the layer is disposed.
  72427. */
  72428. onDisposeObservable: Observable<Layer>;
  72429. private _onDisposeObserver;
  72430. /**
  72431. * Back compatibility with callback before the onDisposeObservable existed.
  72432. * The set callback will be triggered when the layer has been disposed.
  72433. */
  72434. onDispose: () => void;
  72435. /**
  72436. * An event triggered before rendering the scene
  72437. */
  72438. onBeforeRenderObservable: Observable<Layer>;
  72439. private _onBeforeRenderObserver;
  72440. /**
  72441. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72442. * The set callback will be triggered just before rendering the layer.
  72443. */
  72444. onBeforeRender: () => void;
  72445. /**
  72446. * An event triggered after rendering the scene
  72447. */
  72448. onAfterRenderObservable: Observable<Layer>;
  72449. private _onAfterRenderObserver;
  72450. /**
  72451. * Back compatibility with callback before the onAfterRenderObservable existed.
  72452. * The set callback will be triggered just after rendering the layer.
  72453. */
  72454. onAfterRender: () => void;
  72455. /**
  72456. * Instantiates a new layer.
  72457. * This represents a full screen 2d layer.
  72458. * This can be useful to display a picture in the background of your scene for instance.
  72459. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72460. * @param name Define the name of the layer in the scene
  72461. * @param imgUrl Define the url of the texture to display in the layer
  72462. * @param scene Define the scene the layer belongs to
  72463. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72464. * @param color Defines a color for the layer
  72465. */
  72466. constructor(
  72467. /**
  72468. * Define the name of the layer.
  72469. */
  72470. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72471. private _createIndexBuffer;
  72472. /** @hidden */
  72473. _rebuild(): void;
  72474. /**
  72475. * Renders the layer in the scene.
  72476. */
  72477. render(): void;
  72478. /**
  72479. * Disposes and releases the associated ressources.
  72480. */
  72481. dispose(): void;
  72482. }
  72483. }
  72484. declare module BABYLON {
  72485. interface AbstractScene {
  72486. /**
  72487. * The list of procedural textures added to the scene
  72488. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72489. */
  72490. proceduralTextures: Array<ProceduralTexture>;
  72491. }
  72492. /**
  72493. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72494. * in a given scene.
  72495. */
  72496. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72497. /**
  72498. * The component name helpfull to identify the component in the list of scene components.
  72499. */
  72500. readonly name: string;
  72501. /**
  72502. * The scene the component belongs to.
  72503. */
  72504. scene: Scene;
  72505. /**
  72506. * Creates a new instance of the component for the given scene
  72507. * @param scene Defines the scene to register the component in
  72508. */
  72509. constructor(scene: Scene);
  72510. /**
  72511. * Registers the component in a given scene
  72512. */
  72513. register(): void;
  72514. /**
  72515. * Rebuilds the elements related to this component in case of
  72516. * context lost for instance.
  72517. */
  72518. rebuild(): void;
  72519. /**
  72520. * Disposes the component and the associated ressources.
  72521. */
  72522. dispose(): void;
  72523. private _beforeClear;
  72524. }
  72525. }
  72526. declare module BABYLON {
  72527. /** @hidden */
  72528. export var proceduralVertexShader: {
  72529. name: string;
  72530. shader: string;
  72531. };
  72532. }
  72533. declare module BABYLON {
  72534. /**
  72535. * 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.
  72536. * This is the base class of any Procedural texture and contains most of the shareable code.
  72537. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72538. */
  72539. export class ProceduralTexture extends Texture {
  72540. isCube: boolean;
  72541. /**
  72542. * Define if the texture is enabled or not (disabled texture will not render)
  72543. */
  72544. isEnabled: boolean;
  72545. /**
  72546. * Define if the texture must be cleared before rendering (default is true)
  72547. */
  72548. autoClear: boolean;
  72549. /**
  72550. * Callback called when the texture is generated
  72551. */
  72552. onGenerated: () => void;
  72553. /**
  72554. * Event raised when the texture is generated
  72555. */
  72556. onGeneratedObservable: Observable<ProceduralTexture>;
  72557. /** @hidden */
  72558. _generateMipMaps: boolean;
  72559. /** @hidden **/
  72560. _effect: Effect;
  72561. /** @hidden */
  72562. _textures: {
  72563. [key: string]: Texture;
  72564. };
  72565. private _size;
  72566. private _currentRefreshId;
  72567. private _refreshRate;
  72568. private _vertexBuffers;
  72569. private _indexBuffer;
  72570. private _uniforms;
  72571. private _samplers;
  72572. private _fragment;
  72573. private _floats;
  72574. private _ints;
  72575. private _floatsArrays;
  72576. private _colors3;
  72577. private _colors4;
  72578. private _vectors2;
  72579. private _vectors3;
  72580. private _matrices;
  72581. private _fallbackTexture;
  72582. private _fallbackTextureUsed;
  72583. private _engine;
  72584. private _cachedDefines;
  72585. private _contentUpdateId;
  72586. private _contentData;
  72587. /**
  72588. * Instantiates a new procedural texture.
  72589. * 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.
  72590. * This is the base class of any Procedural texture and contains most of the shareable code.
  72591. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72592. * @param name Define the name of the texture
  72593. * @param size Define the size of the texture to create
  72594. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  72595. * @param scene Define the scene the texture belongs to
  72596. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  72597. * @param generateMipMaps Define if the texture should creates mip maps or not
  72598. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  72599. */
  72600. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  72601. /**
  72602. * The effect that is created when initializing the post process.
  72603. * @returns The created effect corrisponding the the postprocess.
  72604. */
  72605. getEffect(): Effect;
  72606. /**
  72607. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  72608. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  72609. */
  72610. getContent(): Nullable<ArrayBufferView>;
  72611. private _createIndexBuffer;
  72612. /** @hidden */
  72613. _rebuild(): void;
  72614. /**
  72615. * Resets the texture in order to recreate its associated resources.
  72616. * This can be called in case of context loss
  72617. */
  72618. reset(): void;
  72619. protected _getDefines(): string;
  72620. /**
  72621. * Is the texture ready to be used ? (rendered at least once)
  72622. * @returns true if ready, otherwise, false.
  72623. */
  72624. isReady(): boolean;
  72625. /**
  72626. * Resets the refresh counter of the texture and start bak from scratch.
  72627. * Could be useful to regenerate the texture if it is setup to render only once.
  72628. */
  72629. resetRefreshCounter(): void;
  72630. /**
  72631. * Set the fragment shader to use in order to render the texture.
  72632. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  72633. */
  72634. setFragment(fragment: any): void;
  72635. /**
  72636. * Define the refresh rate of the texture or the rendering frequency.
  72637. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72638. */
  72639. refreshRate: number;
  72640. /** @hidden */
  72641. _shouldRender(): boolean;
  72642. /**
  72643. * Get the size the texture is rendering at.
  72644. * @returns the size (texture is always squared)
  72645. */
  72646. getRenderSize(): number;
  72647. /**
  72648. * Resize the texture to new value.
  72649. * @param size Define the new size the texture should have
  72650. * @param generateMipMaps Define whether the new texture should create mip maps
  72651. */
  72652. resize(size: number, generateMipMaps: boolean): void;
  72653. private _checkUniform;
  72654. /**
  72655. * Set a texture in the shader program used to render.
  72656. * @param name Define the name of the uniform samplers as defined in the shader
  72657. * @param texture Define the texture to bind to this sampler
  72658. * @return the texture itself allowing "fluent" like uniform updates
  72659. */
  72660. setTexture(name: string, texture: Texture): ProceduralTexture;
  72661. /**
  72662. * Set a float in the shader.
  72663. * @param name Define the name of the uniform as defined in the shader
  72664. * @param value Define the value to give to the uniform
  72665. * @return the texture itself allowing "fluent" like uniform updates
  72666. */
  72667. setFloat(name: string, value: number): ProceduralTexture;
  72668. /**
  72669. * Set a int in the shader.
  72670. * @param name Define the name of the uniform as defined in the shader
  72671. * @param value Define the value to give to the uniform
  72672. * @return the texture itself allowing "fluent" like uniform updates
  72673. */
  72674. setInt(name: string, value: number): ProceduralTexture;
  72675. /**
  72676. * Set an array of floats in the shader.
  72677. * @param name Define the name of the uniform as defined in the shader
  72678. * @param value Define the value to give to the uniform
  72679. * @return the texture itself allowing "fluent" like uniform updates
  72680. */
  72681. setFloats(name: string, value: number[]): ProceduralTexture;
  72682. /**
  72683. * Set a vec3 in the shader from a Color3.
  72684. * @param name Define the name of the uniform as defined in the shader
  72685. * @param value Define the value to give to the uniform
  72686. * @return the texture itself allowing "fluent" like uniform updates
  72687. */
  72688. setColor3(name: string, value: Color3): ProceduralTexture;
  72689. /**
  72690. * Set a vec4 in the shader from a Color4.
  72691. * @param name Define the name of the uniform as defined in the shader
  72692. * @param value Define the value to give to the uniform
  72693. * @return the texture itself allowing "fluent" like uniform updates
  72694. */
  72695. setColor4(name: string, value: Color4): ProceduralTexture;
  72696. /**
  72697. * Set a vec2 in the shader from a Vector2.
  72698. * @param name Define the name of the uniform as defined in the shader
  72699. * @param value Define the value to give to the uniform
  72700. * @return the texture itself allowing "fluent" like uniform updates
  72701. */
  72702. setVector2(name: string, value: Vector2): ProceduralTexture;
  72703. /**
  72704. * Set a vec3 in the shader from a Vector3.
  72705. * @param name Define the name of the uniform as defined in the shader
  72706. * @param value Define the value to give to the uniform
  72707. * @return the texture itself allowing "fluent" like uniform updates
  72708. */
  72709. setVector3(name: string, value: Vector3): ProceduralTexture;
  72710. /**
  72711. * Set a mat4 in the shader from a MAtrix.
  72712. * @param name Define the name of the uniform as defined in the shader
  72713. * @param value Define the value to give to the uniform
  72714. * @return the texture itself allowing "fluent" like uniform updates
  72715. */
  72716. setMatrix(name: string, value: Matrix): ProceduralTexture;
  72717. /**
  72718. * Render the texture to its associated render target.
  72719. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  72720. */
  72721. render(useCameraPostProcess?: boolean): void;
  72722. /**
  72723. * Clone the texture.
  72724. * @returns the cloned texture
  72725. */
  72726. clone(): ProceduralTexture;
  72727. /**
  72728. * Dispose the texture and release its asoociated resources.
  72729. */
  72730. dispose(): void;
  72731. }
  72732. }
  72733. declare module BABYLON {
  72734. /**
  72735. * This represents the base class for particle system in Babylon.
  72736. * 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.
  72737. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72738. * @example https://doc.babylonjs.com/babylon101/particles
  72739. */
  72740. export class BaseParticleSystem {
  72741. /**
  72742. * Source color is added to the destination color without alpha affecting the result
  72743. */
  72744. static BLENDMODE_ONEONE: number;
  72745. /**
  72746. * Blend current color and particle color using particle’s alpha
  72747. */
  72748. static BLENDMODE_STANDARD: number;
  72749. /**
  72750. * Add current color and particle color multiplied by particle’s alpha
  72751. */
  72752. static BLENDMODE_ADD: number;
  72753. /**
  72754. * Multiply current color with particle color
  72755. */
  72756. static BLENDMODE_MULTIPLY: number;
  72757. /**
  72758. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  72759. */
  72760. static BLENDMODE_MULTIPLYADD: number;
  72761. /**
  72762. * List of animations used by the particle system.
  72763. */
  72764. animations: Animation[];
  72765. /**
  72766. * The id of the Particle system.
  72767. */
  72768. id: string;
  72769. /**
  72770. * The friendly name of the Particle system.
  72771. */
  72772. name: string;
  72773. /**
  72774. * The rendering group used by the Particle system to chose when to render.
  72775. */
  72776. renderingGroupId: number;
  72777. /**
  72778. * The emitter represents the Mesh or position we are attaching the particle system to.
  72779. */
  72780. emitter: Nullable<AbstractMesh | Vector3>;
  72781. /**
  72782. * The maximum number of particles to emit per frame
  72783. */
  72784. emitRate: number;
  72785. /**
  72786. * If you want to launch only a few particles at once, that can be done, as well.
  72787. */
  72788. manualEmitCount: number;
  72789. /**
  72790. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72791. */
  72792. updateSpeed: number;
  72793. /**
  72794. * The amount of time the particle system is running (depends of the overall update speed).
  72795. */
  72796. targetStopDuration: number;
  72797. /**
  72798. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72799. */
  72800. disposeOnStop: boolean;
  72801. /**
  72802. * Minimum power of emitting particles.
  72803. */
  72804. minEmitPower: number;
  72805. /**
  72806. * Maximum power of emitting particles.
  72807. */
  72808. maxEmitPower: number;
  72809. /**
  72810. * Minimum life time of emitting particles.
  72811. */
  72812. minLifeTime: number;
  72813. /**
  72814. * Maximum life time of emitting particles.
  72815. */
  72816. maxLifeTime: number;
  72817. /**
  72818. * Minimum Size of emitting particles.
  72819. */
  72820. minSize: number;
  72821. /**
  72822. * Maximum Size of emitting particles.
  72823. */
  72824. maxSize: number;
  72825. /**
  72826. * Minimum scale of emitting particles on X axis.
  72827. */
  72828. minScaleX: number;
  72829. /**
  72830. * Maximum scale of emitting particles on X axis.
  72831. */
  72832. maxScaleX: number;
  72833. /**
  72834. * Minimum scale of emitting particles on Y axis.
  72835. */
  72836. minScaleY: number;
  72837. /**
  72838. * Maximum scale of emitting particles on Y axis.
  72839. */
  72840. maxScaleY: number;
  72841. /**
  72842. * Gets or sets the minimal initial rotation in radians.
  72843. */
  72844. minInitialRotation: number;
  72845. /**
  72846. * Gets or sets the maximal initial rotation in radians.
  72847. */
  72848. maxInitialRotation: number;
  72849. /**
  72850. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72851. */
  72852. minAngularSpeed: number;
  72853. /**
  72854. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72855. */
  72856. maxAngularSpeed: number;
  72857. /**
  72858. * The texture used to render each particle. (this can be a spritesheet)
  72859. */
  72860. particleTexture: Nullable<Texture>;
  72861. /**
  72862. * The layer mask we are rendering the particles through.
  72863. */
  72864. layerMask: number;
  72865. /**
  72866. * This can help using your own shader to render the particle system.
  72867. * The according effect will be created
  72868. */
  72869. customShader: any;
  72870. /**
  72871. * By default particle system starts as soon as they are created. This prevents the
  72872. * automatic start to happen and let you decide when to start emitting particles.
  72873. */
  72874. preventAutoStart: boolean;
  72875. private _noiseTexture;
  72876. /**
  72877. * Gets or sets a texture used to add random noise to particle positions
  72878. */
  72879. noiseTexture: Nullable<ProceduralTexture>;
  72880. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72881. noiseStrength: Vector3;
  72882. /**
  72883. * Callback triggered when the particle animation is ending.
  72884. */
  72885. onAnimationEnd: Nullable<() => void>;
  72886. /**
  72887. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  72888. */
  72889. blendMode: number;
  72890. /**
  72891. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72892. * to override the particles.
  72893. */
  72894. forceDepthWrite: boolean;
  72895. /** 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 */
  72896. preWarmCycles: number;
  72897. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  72898. preWarmStepOffset: number;
  72899. /**
  72900. * 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)
  72901. */
  72902. spriteCellChangeSpeed: number;
  72903. /**
  72904. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72905. */
  72906. startSpriteCellID: number;
  72907. /**
  72908. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72909. */
  72910. endSpriteCellID: number;
  72911. /**
  72912. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72913. */
  72914. spriteCellWidth: number;
  72915. /**
  72916. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72917. */
  72918. spriteCellHeight: number;
  72919. /**
  72920. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72921. */
  72922. spriteRandomStartCell: boolean;
  72923. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72924. translationPivot: Vector2;
  72925. /** @hidden */
  72926. protected _isAnimationSheetEnabled: boolean;
  72927. /**
  72928. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72929. */
  72930. beginAnimationOnStart: boolean;
  72931. /**
  72932. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72933. */
  72934. beginAnimationFrom: number;
  72935. /**
  72936. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72937. */
  72938. beginAnimationTo: number;
  72939. /**
  72940. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72941. */
  72942. beginAnimationLoop: boolean;
  72943. /**
  72944. * Gets or sets a world offset applied to all particles
  72945. */
  72946. worldOffset: Vector3;
  72947. /**
  72948. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  72949. */
  72950. isAnimationSheetEnabled: boolean;
  72951. /**
  72952. * Get hosting scene
  72953. * @returns the scene
  72954. */
  72955. getScene(): Scene;
  72956. /**
  72957. * You can use gravity if you want to give an orientation to your particles.
  72958. */
  72959. gravity: Vector3;
  72960. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72961. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72962. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72963. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72964. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72965. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72966. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72967. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72968. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72969. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72970. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72971. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72972. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72973. /**
  72974. * Defines the delay in milliseconds before starting the system (0 by default)
  72975. */
  72976. startDelay: number;
  72977. /**
  72978. * Gets the current list of drag gradients.
  72979. * You must use addDragGradient and removeDragGradient to udpate this list
  72980. * @returns the list of drag gradients
  72981. */
  72982. getDragGradients(): Nullable<Array<FactorGradient>>;
  72983. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72984. limitVelocityDamping: number;
  72985. /**
  72986. * Gets the current list of limit velocity gradients.
  72987. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72988. * @returns the list of limit velocity gradients
  72989. */
  72990. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72991. /**
  72992. * Gets the current list of color gradients.
  72993. * You must use addColorGradient and removeColorGradient to udpate this list
  72994. * @returns the list of color gradients
  72995. */
  72996. getColorGradients(): Nullable<Array<ColorGradient>>;
  72997. /**
  72998. * Gets the current list of size gradients.
  72999. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73000. * @returns the list of size gradients
  73001. */
  73002. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73003. /**
  73004. * Gets the current list of color remap gradients.
  73005. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73006. * @returns the list of color remap gradients
  73007. */
  73008. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73009. /**
  73010. * Gets the current list of alpha remap gradients.
  73011. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73012. * @returns the list of alpha remap gradients
  73013. */
  73014. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73015. /**
  73016. * Gets the current list of life time gradients.
  73017. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73018. * @returns the list of life time gradients
  73019. */
  73020. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73021. /**
  73022. * Gets the current list of angular speed gradients.
  73023. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73024. * @returns the list of angular speed gradients
  73025. */
  73026. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73027. /**
  73028. * Gets the current list of velocity gradients.
  73029. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73030. * @returns the list of velocity gradients
  73031. */
  73032. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73033. /**
  73034. * Gets the current list of start size gradients.
  73035. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73036. * @returns the list of start size gradients
  73037. */
  73038. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73039. /**
  73040. * Gets the current list of emit rate gradients.
  73041. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73042. * @returns the list of emit rate gradients
  73043. */
  73044. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73045. /**
  73046. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73047. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73048. */
  73049. direction1: Vector3;
  73050. /**
  73051. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73052. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73053. */
  73054. direction2: Vector3;
  73055. /**
  73056. * 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.
  73057. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73058. */
  73059. minEmitBox: Vector3;
  73060. /**
  73061. * 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.
  73062. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73063. */
  73064. maxEmitBox: Vector3;
  73065. /**
  73066. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73067. */
  73068. color1: Color4;
  73069. /**
  73070. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73071. */
  73072. color2: Color4;
  73073. /**
  73074. * Color the particle will have at the end of its lifetime
  73075. */
  73076. colorDead: Color4;
  73077. /**
  73078. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73079. */
  73080. textureMask: Color4;
  73081. /**
  73082. * The particle emitter type defines the emitter used by the particle system.
  73083. * It can be for example box, sphere, or cone...
  73084. */
  73085. particleEmitterType: IParticleEmitterType;
  73086. /** @hidden */
  73087. _isSubEmitter: boolean;
  73088. /**
  73089. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73090. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73091. */
  73092. billboardMode: number;
  73093. protected _isBillboardBased: boolean;
  73094. /**
  73095. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73096. */
  73097. isBillboardBased: boolean;
  73098. /**
  73099. * The scene the particle system belongs to.
  73100. */
  73101. protected _scene: Scene;
  73102. /**
  73103. * Local cache of defines for image processing.
  73104. */
  73105. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73106. /**
  73107. * Default configuration related to image processing available in the standard Material.
  73108. */
  73109. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73110. /**
  73111. * Gets the image processing configuration used either in this material.
  73112. */
  73113. /**
  73114. * Sets the Default image processing configuration used either in the this material.
  73115. *
  73116. * If sets to null, the scene one is in use.
  73117. */
  73118. imageProcessingConfiguration: ImageProcessingConfiguration;
  73119. /**
  73120. * Attaches a new image processing configuration to the Standard Material.
  73121. * @param configuration
  73122. */
  73123. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73124. /** @hidden */
  73125. protected _reset(): void;
  73126. /** @hidden */
  73127. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73128. /**
  73129. * Instantiates a particle system.
  73130. * 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.
  73131. * @param name The name of the particle system
  73132. */
  73133. constructor(name: string);
  73134. /**
  73135. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73136. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73137. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73138. * @returns the emitter
  73139. */
  73140. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73141. /**
  73142. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73143. * @param radius The radius of the hemisphere to emit from
  73144. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73145. * @returns the emitter
  73146. */
  73147. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73148. /**
  73149. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73150. * @param radius The radius of the sphere to emit from
  73151. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73152. * @returns the emitter
  73153. */
  73154. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73155. /**
  73156. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73157. * @param radius The radius of the sphere to emit from
  73158. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73159. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73160. * @returns the emitter
  73161. */
  73162. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73163. /**
  73164. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73165. * @param radius The radius of the emission cylinder
  73166. * @param height The height of the emission cylinder
  73167. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73168. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73169. * @returns the emitter
  73170. */
  73171. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73172. /**
  73173. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73174. * @param radius The radius of the cylinder to emit from
  73175. * @param height The height of the emission cylinder
  73176. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73177. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73178. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73179. * @returns the emitter
  73180. */
  73181. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73182. /**
  73183. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73184. * @param radius The radius of the cone to emit from
  73185. * @param angle The base angle of the cone
  73186. * @returns the emitter
  73187. */
  73188. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73189. /**
  73190. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73191. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73192. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73193. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73194. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73195. * @returns the emitter
  73196. */
  73197. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73198. }
  73199. }
  73200. declare module BABYLON {
  73201. /**
  73202. * Type of sub emitter
  73203. */
  73204. export enum SubEmitterType {
  73205. /**
  73206. * Attached to the particle over it's lifetime
  73207. */
  73208. ATTACHED = 0,
  73209. /**
  73210. * Created when the particle dies
  73211. */
  73212. END = 1
  73213. }
  73214. /**
  73215. * Sub emitter class used to emit particles from an existing particle
  73216. */
  73217. export class SubEmitter {
  73218. /**
  73219. * the particle system to be used by the sub emitter
  73220. */
  73221. particleSystem: ParticleSystem;
  73222. /**
  73223. * Type of the submitter (Default: END)
  73224. */
  73225. type: SubEmitterType;
  73226. /**
  73227. * 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)
  73228. * Note: This only is supported when using an emitter of type Mesh
  73229. */
  73230. inheritDirection: boolean;
  73231. /**
  73232. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73233. */
  73234. inheritedVelocityAmount: number;
  73235. /**
  73236. * Creates a sub emitter
  73237. * @param particleSystem the particle system to be used by the sub emitter
  73238. */
  73239. constructor(
  73240. /**
  73241. * the particle system to be used by the sub emitter
  73242. */
  73243. particleSystem: ParticleSystem);
  73244. /**
  73245. * Clones the sub emitter
  73246. * @returns the cloned sub emitter
  73247. */
  73248. clone(): SubEmitter;
  73249. /**
  73250. * Serialize current object to a JSON object
  73251. * @returns the serialized object
  73252. */
  73253. serialize(): any;
  73254. /** @hidden */
  73255. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  73256. /**
  73257. * Creates a new SubEmitter from a serialized JSON version
  73258. * @param serializationObject defines the JSON object to read from
  73259. * @param scene defines the hosting scene
  73260. * @param rootUrl defines the rootUrl for data loading
  73261. * @returns a new SubEmitter
  73262. */
  73263. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  73264. /** Release associated resources */
  73265. dispose(): void;
  73266. }
  73267. }
  73268. declare module BABYLON {
  73269. /** @hidden */
  73270. export var clipPlaneFragmentDeclaration: {
  73271. name: string;
  73272. shader: string;
  73273. };
  73274. }
  73275. declare module BABYLON {
  73276. /** @hidden */
  73277. export var imageProcessingDeclaration: {
  73278. name: string;
  73279. shader: string;
  73280. };
  73281. }
  73282. declare module BABYLON {
  73283. /** @hidden */
  73284. export var imageProcessingFunctions: {
  73285. name: string;
  73286. shader: string;
  73287. };
  73288. }
  73289. declare module BABYLON {
  73290. /** @hidden */
  73291. export var clipPlaneFragment: {
  73292. name: string;
  73293. shader: string;
  73294. };
  73295. }
  73296. declare module BABYLON {
  73297. /** @hidden */
  73298. export var particlesPixelShader: {
  73299. name: string;
  73300. shader: string;
  73301. };
  73302. }
  73303. declare module BABYLON {
  73304. /** @hidden */
  73305. export var clipPlaneVertexDeclaration: {
  73306. name: string;
  73307. shader: string;
  73308. };
  73309. }
  73310. declare module BABYLON {
  73311. /** @hidden */
  73312. export var clipPlaneVertex: {
  73313. name: string;
  73314. shader: string;
  73315. };
  73316. }
  73317. declare module BABYLON {
  73318. /** @hidden */
  73319. export var particlesVertexShader: {
  73320. name: string;
  73321. shader: string;
  73322. };
  73323. }
  73324. declare module BABYLON {
  73325. /**
  73326. * This represents a particle system in Babylon.
  73327. * 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.
  73328. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73329. * @example https://doc.babylonjs.com/babylon101/particles
  73330. */
  73331. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  73332. /**
  73333. * Billboard mode will only apply to Y axis
  73334. */
  73335. static readonly BILLBOARDMODE_Y: number;
  73336. /**
  73337. * Billboard mode will apply to all axes
  73338. */
  73339. static readonly BILLBOARDMODE_ALL: number;
  73340. /**
  73341. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73342. */
  73343. static readonly BILLBOARDMODE_STRETCHED: number;
  73344. /**
  73345. * This function can be defined to provide custom update for active particles.
  73346. * This function will be called instead of regular update (age, position, color, etc.).
  73347. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  73348. */
  73349. updateFunction: (particles: Particle[]) => void;
  73350. private _emitterWorldMatrix;
  73351. /**
  73352. * This function can be defined to specify initial direction for every new particle.
  73353. * It by default use the emitterType defined function
  73354. */
  73355. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  73356. /**
  73357. * This function can be defined to specify initial position for every new particle.
  73358. * It by default use the emitterType defined function
  73359. */
  73360. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  73361. /**
  73362. * @hidden
  73363. */
  73364. _inheritedVelocityOffset: Vector3;
  73365. /**
  73366. * An event triggered when the system is disposed
  73367. */
  73368. onDisposeObservable: Observable<ParticleSystem>;
  73369. private _onDisposeObserver;
  73370. /**
  73371. * Sets a callback that will be triggered when the system is disposed
  73372. */
  73373. onDispose: () => void;
  73374. private _particles;
  73375. private _epsilon;
  73376. private _capacity;
  73377. private _stockParticles;
  73378. private _newPartsExcess;
  73379. private _vertexData;
  73380. private _vertexBuffer;
  73381. private _vertexBuffers;
  73382. private _spriteBuffer;
  73383. private _indexBuffer;
  73384. private _effect;
  73385. private _customEffect;
  73386. private _cachedDefines;
  73387. private _scaledColorStep;
  73388. private _colorDiff;
  73389. private _scaledDirection;
  73390. private _scaledGravity;
  73391. private _currentRenderId;
  73392. private _alive;
  73393. private _useInstancing;
  73394. private _started;
  73395. private _stopped;
  73396. private _actualFrame;
  73397. private _scaledUpdateSpeed;
  73398. private _vertexBufferSize;
  73399. /** @hidden */
  73400. _currentEmitRateGradient: Nullable<FactorGradient>;
  73401. /** @hidden */
  73402. _currentEmitRate1: number;
  73403. /** @hidden */
  73404. _currentEmitRate2: number;
  73405. /** @hidden */
  73406. _currentStartSizeGradient: Nullable<FactorGradient>;
  73407. /** @hidden */
  73408. _currentStartSize1: number;
  73409. /** @hidden */
  73410. _currentStartSize2: number;
  73411. private readonly _rawTextureWidth;
  73412. private _rampGradientsTexture;
  73413. private _useRampGradients;
  73414. /** Gets or sets a boolean indicating that ramp gradients must be used
  73415. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73416. */
  73417. useRampGradients: boolean;
  73418. /**
  73419. * 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.
  73420. * 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: [])
  73421. */
  73422. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73423. private _subEmitters;
  73424. /**
  73425. * @hidden
  73426. * If the particle systems emitter should be disposed when the particle system is disposed
  73427. */
  73428. _disposeEmitterOnDispose: boolean;
  73429. /**
  73430. * The current active Sub-systems, this property is used by the root particle system only.
  73431. */
  73432. activeSubSystems: Array<ParticleSystem>;
  73433. private _rootParticleSystem;
  73434. /**
  73435. * Gets the current list of active particles
  73436. */
  73437. readonly particles: Particle[];
  73438. /**
  73439. * Returns the string "ParticleSystem"
  73440. * @returns a string containing the class name
  73441. */
  73442. getClassName(): string;
  73443. /**
  73444. * Instantiates a particle system.
  73445. * 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.
  73446. * @param name The name of the particle system
  73447. * @param capacity The max number of particles alive at the same time
  73448. * @param scene The scene the particle system belongs to
  73449. * @param customEffect a custom effect used to change the way particles are rendered by default
  73450. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73451. * @param epsilon Offset used to render the particles
  73452. */
  73453. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73454. private _addFactorGradient;
  73455. private _removeFactorGradient;
  73456. /**
  73457. * Adds a new life time gradient
  73458. * @param gradient defines the gradient to use (between 0 and 1)
  73459. * @param factor defines the life time factor to affect to the specified gradient
  73460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73461. * @returns the current particle system
  73462. */
  73463. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73464. /**
  73465. * Remove a specific life time gradient
  73466. * @param gradient defines the gradient to remove
  73467. * @returns the current particle system
  73468. */
  73469. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73470. /**
  73471. * Adds a new size gradient
  73472. * @param gradient defines the gradient to use (between 0 and 1)
  73473. * @param factor defines the size factor to affect to the specified gradient
  73474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73475. * @returns the current particle system
  73476. */
  73477. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73478. /**
  73479. * Remove a specific size gradient
  73480. * @param gradient defines the gradient to remove
  73481. * @returns the current particle system
  73482. */
  73483. removeSizeGradient(gradient: number): IParticleSystem;
  73484. /**
  73485. * Adds a new color remap gradient
  73486. * @param gradient defines the gradient to use (between 0 and 1)
  73487. * @param min defines the color remap minimal range
  73488. * @param max defines the color remap maximal range
  73489. * @returns the current particle system
  73490. */
  73491. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73492. /**
  73493. * Remove a specific color remap gradient
  73494. * @param gradient defines the gradient to remove
  73495. * @returns the current particle system
  73496. */
  73497. removeColorRemapGradient(gradient: number): IParticleSystem;
  73498. /**
  73499. * Adds a new alpha remap gradient
  73500. * @param gradient defines the gradient to use (between 0 and 1)
  73501. * @param min defines the alpha remap minimal range
  73502. * @param max defines the alpha remap maximal range
  73503. * @returns the current particle system
  73504. */
  73505. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73506. /**
  73507. * Remove a specific alpha remap gradient
  73508. * @param gradient defines the gradient to remove
  73509. * @returns the current particle system
  73510. */
  73511. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73512. /**
  73513. * Adds a new angular speed gradient
  73514. * @param gradient defines the gradient to use (between 0 and 1)
  73515. * @param factor defines the angular speed to affect to the specified gradient
  73516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73517. * @returns the current particle system
  73518. */
  73519. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73520. /**
  73521. * Remove a specific angular speed gradient
  73522. * @param gradient defines the gradient to remove
  73523. * @returns the current particle system
  73524. */
  73525. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73526. /**
  73527. * Adds a new velocity gradient
  73528. * @param gradient defines the gradient to use (between 0 and 1)
  73529. * @param factor defines the velocity to affect to the specified gradient
  73530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73531. * @returns the current particle system
  73532. */
  73533. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73534. /**
  73535. * Remove a specific velocity gradient
  73536. * @param gradient defines the gradient to remove
  73537. * @returns the current particle system
  73538. */
  73539. removeVelocityGradient(gradient: number): IParticleSystem;
  73540. /**
  73541. * Adds a new limit velocity gradient
  73542. * @param gradient defines the gradient to use (between 0 and 1)
  73543. * @param factor defines the limit velocity value to affect to the specified gradient
  73544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73545. * @returns the current particle system
  73546. */
  73547. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73548. /**
  73549. * Remove a specific limit velocity gradient
  73550. * @param gradient defines the gradient to remove
  73551. * @returns the current particle system
  73552. */
  73553. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73554. /**
  73555. * Adds a new drag gradient
  73556. * @param gradient defines the gradient to use (between 0 and 1)
  73557. * @param factor defines the drag value to affect to the specified gradient
  73558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73559. * @returns the current particle system
  73560. */
  73561. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73562. /**
  73563. * Remove a specific drag gradient
  73564. * @param gradient defines the gradient to remove
  73565. * @returns the current particle system
  73566. */
  73567. removeDragGradient(gradient: number): IParticleSystem;
  73568. /**
  73569. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73570. * @param gradient defines the gradient to use (between 0 and 1)
  73571. * @param factor defines the emit rate value to affect to the specified gradient
  73572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73573. * @returns the current particle system
  73574. */
  73575. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73576. /**
  73577. * Remove a specific emit rate gradient
  73578. * @param gradient defines the gradient to remove
  73579. * @returns the current particle system
  73580. */
  73581. removeEmitRateGradient(gradient: number): IParticleSystem;
  73582. /**
  73583. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73584. * @param gradient defines the gradient to use (between 0 and 1)
  73585. * @param factor defines the start size value to affect to the specified gradient
  73586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73587. * @returns the current particle system
  73588. */
  73589. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73590. /**
  73591. * Remove a specific start size gradient
  73592. * @param gradient defines the gradient to remove
  73593. * @returns the current particle system
  73594. */
  73595. removeStartSizeGradient(gradient: number): IParticleSystem;
  73596. private _createRampGradientTexture;
  73597. /**
  73598. * Gets the current list of ramp gradients.
  73599. * You must use addRampGradient and removeRampGradient to udpate this list
  73600. * @returns the list of ramp gradients
  73601. */
  73602. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73603. /**
  73604. * Adds a new ramp gradient used to remap particle colors
  73605. * @param gradient defines the gradient to use (between 0 and 1)
  73606. * @param color defines the color to affect to the specified gradient
  73607. * @returns the current particle system
  73608. */
  73609. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  73610. /**
  73611. * Remove a specific ramp gradient
  73612. * @param gradient defines the gradient to remove
  73613. * @returns the current particle system
  73614. */
  73615. removeRampGradient(gradient: number): ParticleSystem;
  73616. /**
  73617. * Adds a new color gradient
  73618. * @param gradient defines the gradient to use (between 0 and 1)
  73619. * @param color1 defines the color to affect to the specified gradient
  73620. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73621. * @returns this particle system
  73622. */
  73623. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73624. /**
  73625. * Remove a specific color gradient
  73626. * @param gradient defines the gradient to remove
  73627. * @returns this particle system
  73628. */
  73629. removeColorGradient(gradient: number): IParticleSystem;
  73630. private _fetchR;
  73631. protected _reset(): void;
  73632. private _resetEffect;
  73633. private _createVertexBuffers;
  73634. private _createIndexBuffer;
  73635. /**
  73636. * Gets the maximum number of particles active at the same time.
  73637. * @returns The max number of active particles.
  73638. */
  73639. getCapacity(): number;
  73640. /**
  73641. * Gets whether there are still active particles in the system.
  73642. * @returns True if it is alive, otherwise false.
  73643. */
  73644. isAlive(): boolean;
  73645. /**
  73646. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73647. * @returns True if it has been started, otherwise false.
  73648. */
  73649. isStarted(): boolean;
  73650. private _prepareSubEmitterInternalArray;
  73651. /**
  73652. * Starts the particle system and begins to emit
  73653. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  73654. */
  73655. start(delay?: number): void;
  73656. /**
  73657. * Stops the particle system.
  73658. * @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.
  73659. */
  73660. stop(stopSubEmitters?: boolean): void;
  73661. /**
  73662. * Remove all active particles
  73663. */
  73664. reset(): void;
  73665. /**
  73666. * @hidden (for internal use only)
  73667. */
  73668. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  73669. /**
  73670. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  73671. * Its lifetime will start back at 0.
  73672. */
  73673. recycleParticle: (particle: Particle) => void;
  73674. private _stopSubEmitters;
  73675. private _createParticle;
  73676. private _removeFromRoot;
  73677. private _emitFromParticle;
  73678. private _update;
  73679. /** @hidden */
  73680. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  73681. /** @hidden */
  73682. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  73683. /** @hidden */
  73684. private _getEffect;
  73685. /**
  73686. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73687. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  73688. */
  73689. animate(preWarmOnly?: boolean): void;
  73690. private _appendParticleVertices;
  73691. /**
  73692. * Rebuilds the particle system.
  73693. */
  73694. rebuild(): void;
  73695. /**
  73696. * Is this system ready to be used/rendered
  73697. * @return true if the system is ready
  73698. */
  73699. isReady(): boolean;
  73700. private _render;
  73701. /**
  73702. * Renders the particle system in its current state.
  73703. * @returns the current number of particles
  73704. */
  73705. render(): number;
  73706. /**
  73707. * Disposes the particle system and free the associated resources
  73708. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73709. */
  73710. dispose(disposeTexture?: boolean): void;
  73711. /**
  73712. * Clones the particle system.
  73713. * @param name The name of the cloned object
  73714. * @param newEmitter The new emitter to use
  73715. * @returns the cloned particle system
  73716. */
  73717. clone(name: string, newEmitter: any): ParticleSystem;
  73718. /**
  73719. * Serializes the particle system to a JSON object.
  73720. * @returns the JSON object
  73721. */
  73722. serialize(): any;
  73723. /** @hidden */
  73724. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  73725. /** @hidden */
  73726. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  73727. /**
  73728. * Parses a JSON object to create a particle system.
  73729. * @param parsedParticleSystem The JSON object to parse
  73730. * @param scene The scene to create the particle system in
  73731. * @param rootUrl The root url to use to load external dependencies like texture
  73732. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73733. * @returns the Parsed particle system
  73734. */
  73735. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  73736. }
  73737. }
  73738. declare module BABYLON {
  73739. /**
  73740. * A particle represents one of the element emitted by a particle system.
  73741. * This is mainly define by its coordinates, direction, velocity and age.
  73742. */
  73743. export class Particle {
  73744. /**
  73745. * The particle system the particle belongs to.
  73746. */
  73747. particleSystem: ParticleSystem;
  73748. private static _Count;
  73749. /**
  73750. * Unique ID of the particle
  73751. */
  73752. id: number;
  73753. /**
  73754. * The world position of the particle in the scene.
  73755. */
  73756. position: Vector3;
  73757. /**
  73758. * The world direction of the particle in the scene.
  73759. */
  73760. direction: Vector3;
  73761. /**
  73762. * The color of the particle.
  73763. */
  73764. color: Color4;
  73765. /**
  73766. * The color change of the particle per step.
  73767. */
  73768. colorStep: Color4;
  73769. /**
  73770. * Defines how long will the life of the particle be.
  73771. */
  73772. lifeTime: number;
  73773. /**
  73774. * The current age of the particle.
  73775. */
  73776. age: number;
  73777. /**
  73778. * The current size of the particle.
  73779. */
  73780. size: number;
  73781. /**
  73782. * The current scale of the particle.
  73783. */
  73784. scale: Vector2;
  73785. /**
  73786. * The current angle of the particle.
  73787. */
  73788. angle: number;
  73789. /**
  73790. * Defines how fast is the angle changing.
  73791. */
  73792. angularSpeed: number;
  73793. /**
  73794. * Defines the cell index used by the particle to be rendered from a sprite.
  73795. */
  73796. cellIndex: number;
  73797. /**
  73798. * The information required to support color remapping
  73799. */
  73800. remapData: Vector4;
  73801. /** @hidden */
  73802. _randomCellOffset?: number;
  73803. /** @hidden */
  73804. _initialDirection: Nullable<Vector3>;
  73805. /** @hidden */
  73806. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  73807. /** @hidden */
  73808. _initialStartSpriteCellID: number;
  73809. /** @hidden */
  73810. _initialEndSpriteCellID: number;
  73811. /** @hidden */
  73812. _currentColorGradient: Nullable<ColorGradient>;
  73813. /** @hidden */
  73814. _currentColor1: Color4;
  73815. /** @hidden */
  73816. _currentColor2: Color4;
  73817. /** @hidden */
  73818. _currentSizeGradient: Nullable<FactorGradient>;
  73819. /** @hidden */
  73820. _currentSize1: number;
  73821. /** @hidden */
  73822. _currentSize2: number;
  73823. /** @hidden */
  73824. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  73825. /** @hidden */
  73826. _currentAngularSpeed1: number;
  73827. /** @hidden */
  73828. _currentAngularSpeed2: number;
  73829. /** @hidden */
  73830. _currentVelocityGradient: Nullable<FactorGradient>;
  73831. /** @hidden */
  73832. _currentVelocity1: number;
  73833. /** @hidden */
  73834. _currentVelocity2: number;
  73835. /** @hidden */
  73836. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  73837. /** @hidden */
  73838. _currentLimitVelocity1: number;
  73839. /** @hidden */
  73840. _currentLimitVelocity2: number;
  73841. /** @hidden */
  73842. _currentDragGradient: Nullable<FactorGradient>;
  73843. /** @hidden */
  73844. _currentDrag1: number;
  73845. /** @hidden */
  73846. _currentDrag2: number;
  73847. /** @hidden */
  73848. _randomNoiseCoordinates1: Vector3;
  73849. /** @hidden */
  73850. _randomNoiseCoordinates2: Vector3;
  73851. /**
  73852. * Creates a new instance Particle
  73853. * @param particleSystem the particle system the particle belongs to
  73854. */
  73855. constructor(
  73856. /**
  73857. * The particle system the particle belongs to.
  73858. */
  73859. particleSystem: ParticleSystem);
  73860. private updateCellInfoFromSystem;
  73861. /**
  73862. * Defines how the sprite cell index is updated for the particle
  73863. */
  73864. updateCellIndex(): void;
  73865. /** @hidden */
  73866. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  73867. /** @hidden */
  73868. _inheritParticleInfoToSubEmitters(): void;
  73869. /** @hidden */
  73870. _reset(): void;
  73871. /**
  73872. * Copy the properties of particle to another one.
  73873. * @param other the particle to copy the information to.
  73874. */
  73875. copyTo(other: Particle): void;
  73876. }
  73877. }
  73878. declare module BABYLON {
  73879. /**
  73880. * Particle emitter represents a volume emitting particles.
  73881. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  73882. */
  73883. export interface IParticleEmitterType {
  73884. /**
  73885. * Called by the particle System when the direction is computed for the created particle.
  73886. * @param worldMatrix is the world matrix of the particle system
  73887. * @param directionToUpdate is the direction vector to update with the result
  73888. * @param particle is the particle we are computed the direction for
  73889. */
  73890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73891. /**
  73892. * Called by the particle System when the position is computed for the created particle.
  73893. * @param worldMatrix is the world matrix of the particle system
  73894. * @param positionToUpdate is the position vector to update with the result
  73895. * @param particle is the particle we are computed the position for
  73896. */
  73897. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73898. /**
  73899. * Clones the current emitter and returns a copy of it
  73900. * @returns the new emitter
  73901. */
  73902. clone(): IParticleEmitterType;
  73903. /**
  73904. * Called by the GPUParticleSystem to setup the update shader
  73905. * @param effect defines the update shader
  73906. */
  73907. applyToShader(effect: Effect): void;
  73908. /**
  73909. * Returns a string to use to update the GPU particles update shader
  73910. * @returns the effect defines string
  73911. */
  73912. getEffectDefines(): string;
  73913. /**
  73914. * Returns a string representing the class name
  73915. * @returns a string containing the class name
  73916. */
  73917. getClassName(): string;
  73918. /**
  73919. * Serializes the particle system to a JSON object.
  73920. * @returns the JSON object
  73921. */
  73922. serialize(): any;
  73923. /**
  73924. * Parse properties from a JSON object
  73925. * @param serializationObject defines the JSON object
  73926. */
  73927. parse(serializationObject: any): void;
  73928. }
  73929. }
  73930. declare module BABYLON {
  73931. /**
  73932. * Particle emitter emitting particles from the inside of a box.
  73933. * It emits the particles randomly between 2 given directions.
  73934. */
  73935. export class BoxParticleEmitter implements IParticleEmitterType {
  73936. /**
  73937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73938. */
  73939. direction1: Vector3;
  73940. /**
  73941. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73942. */
  73943. direction2: Vector3;
  73944. /**
  73945. * 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.
  73946. */
  73947. minEmitBox: Vector3;
  73948. /**
  73949. * 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.
  73950. */
  73951. maxEmitBox: Vector3;
  73952. /**
  73953. * Creates a new instance BoxParticleEmitter
  73954. */
  73955. constructor();
  73956. /**
  73957. * Called by the particle System when the direction is computed for the created particle.
  73958. * @param worldMatrix is the world matrix of the particle system
  73959. * @param directionToUpdate is the direction vector to update with the result
  73960. * @param particle is the particle we are computed the direction for
  73961. */
  73962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73963. /**
  73964. * Called by the particle System when the position is computed for the created particle.
  73965. * @param worldMatrix is the world matrix of the particle system
  73966. * @param positionToUpdate is the position vector to update with the result
  73967. * @param particle is the particle we are computed the position for
  73968. */
  73969. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73970. /**
  73971. * Clones the current emitter and returns a copy of it
  73972. * @returns the new emitter
  73973. */
  73974. clone(): BoxParticleEmitter;
  73975. /**
  73976. * Called by the GPUParticleSystem to setup the update shader
  73977. * @param effect defines the update shader
  73978. */
  73979. applyToShader(effect: Effect): void;
  73980. /**
  73981. * Returns a string to use to update the GPU particles update shader
  73982. * @returns a string containng the defines string
  73983. */
  73984. getEffectDefines(): string;
  73985. /**
  73986. * Returns the string "BoxParticleEmitter"
  73987. * @returns a string containing the class name
  73988. */
  73989. getClassName(): string;
  73990. /**
  73991. * Serializes the particle system to a JSON object.
  73992. * @returns the JSON object
  73993. */
  73994. serialize(): any;
  73995. /**
  73996. * Parse properties from a JSON object
  73997. * @param serializationObject defines the JSON object
  73998. */
  73999. parse(serializationObject: any): void;
  74000. }
  74001. }
  74002. declare module BABYLON {
  74003. /**
  74004. * Particle emitter emitting particles from the inside of a cone.
  74005. * It emits the particles alongside the cone volume from the base to the particle.
  74006. * The emission direction might be randomized.
  74007. */
  74008. export class ConeParticleEmitter implements IParticleEmitterType {
  74009. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74010. directionRandomizer: number;
  74011. private _radius;
  74012. private _angle;
  74013. private _height;
  74014. /**
  74015. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74016. */
  74017. radiusRange: number;
  74018. /**
  74019. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74020. */
  74021. heightRange: number;
  74022. /**
  74023. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74024. */
  74025. emitFromSpawnPointOnly: boolean;
  74026. /**
  74027. * Gets or sets the radius of the emission cone
  74028. */
  74029. radius: number;
  74030. /**
  74031. * Gets or sets the angle of the emission cone
  74032. */
  74033. angle: number;
  74034. private _buildHeight;
  74035. /**
  74036. * Creates a new instance ConeParticleEmitter
  74037. * @param radius the radius of the emission cone (1 by default)
  74038. * @param angle the cone base angle (PI by default)
  74039. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74040. */
  74041. constructor(radius?: number, angle?: number,
  74042. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74043. directionRandomizer?: number);
  74044. /**
  74045. * Called by the particle System when the direction is computed for the created particle.
  74046. * @param worldMatrix is the world matrix of the particle system
  74047. * @param directionToUpdate is the direction vector to update with the result
  74048. * @param particle is the particle we are computed the direction for
  74049. */
  74050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74051. /**
  74052. * Called by the particle System when the position is computed for the created particle.
  74053. * @param worldMatrix is the world matrix of the particle system
  74054. * @param positionToUpdate is the position vector to update with the result
  74055. * @param particle is the particle we are computed the position for
  74056. */
  74057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74058. /**
  74059. * Clones the current emitter and returns a copy of it
  74060. * @returns the new emitter
  74061. */
  74062. clone(): ConeParticleEmitter;
  74063. /**
  74064. * Called by the GPUParticleSystem to setup the update shader
  74065. * @param effect defines the update shader
  74066. */
  74067. applyToShader(effect: Effect): void;
  74068. /**
  74069. * Returns a string to use to update the GPU particles update shader
  74070. * @returns a string containng the defines string
  74071. */
  74072. getEffectDefines(): string;
  74073. /**
  74074. * Returns the string "ConeParticleEmitter"
  74075. * @returns a string containing the class name
  74076. */
  74077. getClassName(): string;
  74078. /**
  74079. * Serializes the particle system to a JSON object.
  74080. * @returns the JSON object
  74081. */
  74082. serialize(): any;
  74083. /**
  74084. * Parse properties from a JSON object
  74085. * @param serializationObject defines the JSON object
  74086. */
  74087. parse(serializationObject: any): void;
  74088. }
  74089. }
  74090. declare module BABYLON {
  74091. /**
  74092. * Particle emitter emitting particles from the inside of a cylinder.
  74093. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74094. */
  74095. export class CylinderParticleEmitter implements IParticleEmitterType {
  74096. /**
  74097. * The radius of the emission cylinder.
  74098. */
  74099. radius: number;
  74100. /**
  74101. * The height of the emission cylinder.
  74102. */
  74103. height: number;
  74104. /**
  74105. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74106. */
  74107. radiusRange: number;
  74108. /**
  74109. * How much to randomize the particle direction [0-1].
  74110. */
  74111. directionRandomizer: number;
  74112. /**
  74113. * Creates a new instance CylinderParticleEmitter
  74114. * @param radius the radius of the emission cylinder (1 by default)
  74115. * @param height the height of the emission cylinder (1 by default)
  74116. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74117. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74118. */
  74119. constructor(
  74120. /**
  74121. * The radius of the emission cylinder.
  74122. */
  74123. radius?: number,
  74124. /**
  74125. * The height of the emission cylinder.
  74126. */
  74127. height?: number,
  74128. /**
  74129. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74130. */
  74131. radiusRange?: number,
  74132. /**
  74133. * How much to randomize the particle direction [0-1].
  74134. */
  74135. directionRandomizer?: number);
  74136. /**
  74137. * Called by the particle System when the direction is computed for the created particle.
  74138. * @param worldMatrix is the world matrix of the particle system
  74139. * @param directionToUpdate is the direction vector to update with the result
  74140. * @param particle is the particle we are computed the direction for
  74141. */
  74142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74143. /**
  74144. * Called by the particle System when the position is computed for the created particle.
  74145. * @param worldMatrix is the world matrix of the particle system
  74146. * @param positionToUpdate is the position vector to update with the result
  74147. * @param particle is the particle we are computed the position for
  74148. */
  74149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74150. /**
  74151. * Clones the current emitter and returns a copy of it
  74152. * @returns the new emitter
  74153. */
  74154. clone(): CylinderParticleEmitter;
  74155. /**
  74156. * Called by the GPUParticleSystem to setup the update shader
  74157. * @param effect defines the update shader
  74158. */
  74159. applyToShader(effect: Effect): void;
  74160. /**
  74161. * Returns a string to use to update the GPU particles update shader
  74162. * @returns a string containng the defines string
  74163. */
  74164. getEffectDefines(): string;
  74165. /**
  74166. * Returns the string "CylinderParticleEmitter"
  74167. * @returns a string containing the class name
  74168. */
  74169. getClassName(): string;
  74170. /**
  74171. * Serializes the particle system to a JSON object.
  74172. * @returns the JSON object
  74173. */
  74174. serialize(): any;
  74175. /**
  74176. * Parse properties from a JSON object
  74177. * @param serializationObject defines the JSON object
  74178. */
  74179. parse(serializationObject: any): void;
  74180. }
  74181. /**
  74182. * Particle emitter emitting particles from the inside of a cylinder.
  74183. * It emits the particles randomly between two vectors.
  74184. */
  74185. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74186. /**
  74187. * The min limit of the emission direction.
  74188. */
  74189. direction1: Vector3;
  74190. /**
  74191. * The max limit of the emission direction.
  74192. */
  74193. direction2: Vector3;
  74194. /**
  74195. * Creates a new instance CylinderDirectedParticleEmitter
  74196. * @param radius the radius of the emission cylinder (1 by default)
  74197. * @param height the height of the emission cylinder (1 by default)
  74198. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74199. * @param direction1 the min limit of the emission direction (up vector by default)
  74200. * @param direction2 the max limit of the emission direction (up vector by default)
  74201. */
  74202. constructor(radius?: number, height?: number, radiusRange?: number,
  74203. /**
  74204. * The min limit of the emission direction.
  74205. */
  74206. direction1?: Vector3,
  74207. /**
  74208. * The max limit of the emission direction.
  74209. */
  74210. direction2?: Vector3);
  74211. /**
  74212. * Called by the particle System when the direction is computed for the created particle.
  74213. * @param worldMatrix is the world matrix of the particle system
  74214. * @param directionToUpdate is the direction vector to update with the result
  74215. * @param particle is the particle we are computed the direction for
  74216. */
  74217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74218. /**
  74219. * Clones the current emitter and returns a copy of it
  74220. * @returns the new emitter
  74221. */
  74222. clone(): CylinderDirectedParticleEmitter;
  74223. /**
  74224. * Called by the GPUParticleSystem to setup the update shader
  74225. * @param effect defines the update shader
  74226. */
  74227. applyToShader(effect: Effect): void;
  74228. /**
  74229. * Returns a string to use to update the GPU particles update shader
  74230. * @returns a string containng the defines string
  74231. */
  74232. getEffectDefines(): string;
  74233. /**
  74234. * Returns the string "CylinderDirectedParticleEmitter"
  74235. * @returns a string containing the class name
  74236. */
  74237. getClassName(): string;
  74238. /**
  74239. * Serializes the particle system to a JSON object.
  74240. * @returns the JSON object
  74241. */
  74242. serialize(): any;
  74243. /**
  74244. * Parse properties from a JSON object
  74245. * @param serializationObject defines the JSON object
  74246. */
  74247. parse(serializationObject: any): void;
  74248. }
  74249. }
  74250. declare module BABYLON {
  74251. /**
  74252. * Particle emitter emitting particles from the inside of a hemisphere.
  74253. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74254. */
  74255. export class HemisphericParticleEmitter implements IParticleEmitterType {
  74256. /**
  74257. * The radius of the emission hemisphere.
  74258. */
  74259. radius: number;
  74260. /**
  74261. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74262. */
  74263. radiusRange: number;
  74264. /**
  74265. * How much to randomize the particle direction [0-1].
  74266. */
  74267. directionRandomizer: number;
  74268. /**
  74269. * Creates a new instance HemisphericParticleEmitter
  74270. * @param radius the radius of the emission hemisphere (1 by default)
  74271. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74272. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74273. */
  74274. constructor(
  74275. /**
  74276. * The radius of the emission hemisphere.
  74277. */
  74278. radius?: number,
  74279. /**
  74280. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74281. */
  74282. radiusRange?: number,
  74283. /**
  74284. * How much to randomize the particle direction [0-1].
  74285. */
  74286. directionRandomizer?: number);
  74287. /**
  74288. * Called by the particle System when the direction is computed for the created particle.
  74289. * @param worldMatrix is the world matrix of the particle system
  74290. * @param directionToUpdate is the direction vector to update with the result
  74291. * @param particle is the particle we are computed the direction for
  74292. */
  74293. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74294. /**
  74295. * Called by the particle System when the position is computed for the created particle.
  74296. * @param worldMatrix is the world matrix of the particle system
  74297. * @param positionToUpdate is the position vector to update with the result
  74298. * @param particle is the particle we are computed the position for
  74299. */
  74300. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74301. /**
  74302. * Clones the current emitter and returns a copy of it
  74303. * @returns the new emitter
  74304. */
  74305. clone(): HemisphericParticleEmitter;
  74306. /**
  74307. * Called by the GPUParticleSystem to setup the update shader
  74308. * @param effect defines the update shader
  74309. */
  74310. applyToShader(effect: Effect): void;
  74311. /**
  74312. * Returns a string to use to update the GPU particles update shader
  74313. * @returns a string containng the defines string
  74314. */
  74315. getEffectDefines(): string;
  74316. /**
  74317. * Returns the string "HemisphericParticleEmitter"
  74318. * @returns a string containing the class name
  74319. */
  74320. getClassName(): string;
  74321. /**
  74322. * Serializes the particle system to a JSON object.
  74323. * @returns the JSON object
  74324. */
  74325. serialize(): any;
  74326. /**
  74327. * Parse properties from a JSON object
  74328. * @param serializationObject defines the JSON object
  74329. */
  74330. parse(serializationObject: any): void;
  74331. }
  74332. }
  74333. declare module BABYLON {
  74334. /**
  74335. * Particle emitter emitting particles from a point.
  74336. * It emits the particles randomly between 2 given directions.
  74337. */
  74338. export class PointParticleEmitter implements IParticleEmitterType {
  74339. /**
  74340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74341. */
  74342. direction1: Vector3;
  74343. /**
  74344. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74345. */
  74346. direction2: Vector3;
  74347. /**
  74348. * Creates a new instance PointParticleEmitter
  74349. */
  74350. constructor();
  74351. /**
  74352. * Called by the particle System when the direction is computed for the created particle.
  74353. * @param worldMatrix is the world matrix of the particle system
  74354. * @param directionToUpdate is the direction vector to update with the result
  74355. * @param particle is the particle we are computed the direction for
  74356. */
  74357. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74358. /**
  74359. * Called by the particle System when the position is computed for the created particle.
  74360. * @param worldMatrix is the world matrix of the particle system
  74361. * @param positionToUpdate is the position vector to update with the result
  74362. * @param particle is the particle we are computed the position for
  74363. */
  74364. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74365. /**
  74366. * Clones the current emitter and returns a copy of it
  74367. * @returns the new emitter
  74368. */
  74369. clone(): PointParticleEmitter;
  74370. /**
  74371. * Called by the GPUParticleSystem to setup the update shader
  74372. * @param effect defines the update shader
  74373. */
  74374. applyToShader(effect: Effect): void;
  74375. /**
  74376. * Returns a string to use to update the GPU particles update shader
  74377. * @returns a string containng the defines string
  74378. */
  74379. getEffectDefines(): string;
  74380. /**
  74381. * Returns the string "PointParticleEmitter"
  74382. * @returns a string containing the class name
  74383. */
  74384. getClassName(): string;
  74385. /**
  74386. * Serializes the particle system to a JSON object.
  74387. * @returns the JSON object
  74388. */
  74389. serialize(): any;
  74390. /**
  74391. * Parse properties from a JSON object
  74392. * @param serializationObject defines the JSON object
  74393. */
  74394. parse(serializationObject: any): void;
  74395. }
  74396. }
  74397. declare module BABYLON {
  74398. /**
  74399. * Particle emitter emitting particles from the inside of a sphere.
  74400. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74401. */
  74402. export class SphereParticleEmitter implements IParticleEmitterType {
  74403. /**
  74404. * The radius of the emission sphere.
  74405. */
  74406. radius: number;
  74407. /**
  74408. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74409. */
  74410. radiusRange: number;
  74411. /**
  74412. * How much to randomize the particle direction [0-1].
  74413. */
  74414. directionRandomizer: number;
  74415. /**
  74416. * Creates a new instance SphereParticleEmitter
  74417. * @param radius the radius of the emission sphere (1 by default)
  74418. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74419. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74420. */
  74421. constructor(
  74422. /**
  74423. * The radius of the emission sphere.
  74424. */
  74425. radius?: number,
  74426. /**
  74427. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74428. */
  74429. radiusRange?: number,
  74430. /**
  74431. * How much to randomize the particle direction [0-1].
  74432. */
  74433. directionRandomizer?: number);
  74434. /**
  74435. * Called by the particle System when the direction is computed for the created particle.
  74436. * @param worldMatrix is the world matrix of the particle system
  74437. * @param directionToUpdate is the direction vector to update with the result
  74438. * @param particle is the particle we are computed the direction for
  74439. */
  74440. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74441. /**
  74442. * Called by the particle System when the position is computed for the created particle.
  74443. * @param worldMatrix is the world matrix of the particle system
  74444. * @param positionToUpdate is the position vector to update with the result
  74445. * @param particle is the particle we are computed the position for
  74446. */
  74447. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74448. /**
  74449. * Clones the current emitter and returns a copy of it
  74450. * @returns the new emitter
  74451. */
  74452. clone(): SphereParticleEmitter;
  74453. /**
  74454. * Called by the GPUParticleSystem to setup the update shader
  74455. * @param effect defines the update shader
  74456. */
  74457. applyToShader(effect: Effect): void;
  74458. /**
  74459. * Returns a string to use to update the GPU particles update shader
  74460. * @returns a string containng the defines string
  74461. */
  74462. getEffectDefines(): string;
  74463. /**
  74464. * Returns the string "SphereParticleEmitter"
  74465. * @returns a string containing the class name
  74466. */
  74467. getClassName(): string;
  74468. /**
  74469. * Serializes the particle system to a JSON object.
  74470. * @returns the JSON object
  74471. */
  74472. serialize(): any;
  74473. /**
  74474. * Parse properties from a JSON object
  74475. * @param serializationObject defines the JSON object
  74476. */
  74477. parse(serializationObject: any): void;
  74478. }
  74479. /**
  74480. * Particle emitter emitting particles from the inside of a sphere.
  74481. * It emits the particles randomly between two vectors.
  74482. */
  74483. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74484. /**
  74485. * The min limit of the emission direction.
  74486. */
  74487. direction1: Vector3;
  74488. /**
  74489. * The max limit of the emission direction.
  74490. */
  74491. direction2: Vector3;
  74492. /**
  74493. * Creates a new instance SphereDirectedParticleEmitter
  74494. * @param radius the radius of the emission sphere (1 by default)
  74495. * @param direction1 the min limit of the emission direction (up vector by default)
  74496. * @param direction2 the max limit of the emission direction (up vector by default)
  74497. */
  74498. constructor(radius?: number,
  74499. /**
  74500. * The min limit of the emission direction.
  74501. */
  74502. direction1?: Vector3,
  74503. /**
  74504. * The max limit of the emission direction.
  74505. */
  74506. direction2?: Vector3);
  74507. /**
  74508. * Called by the particle System when the direction is computed for the created particle.
  74509. * @param worldMatrix is the world matrix of the particle system
  74510. * @param directionToUpdate is the direction vector to update with the result
  74511. * @param particle is the particle we are computed the direction for
  74512. */
  74513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74514. /**
  74515. * Clones the current emitter and returns a copy of it
  74516. * @returns the new emitter
  74517. */
  74518. clone(): SphereDirectedParticleEmitter;
  74519. /**
  74520. * Called by the GPUParticleSystem to setup the update shader
  74521. * @param effect defines the update shader
  74522. */
  74523. applyToShader(effect: Effect): void;
  74524. /**
  74525. * Returns a string to use to update the GPU particles update shader
  74526. * @returns a string containng the defines string
  74527. */
  74528. getEffectDefines(): string;
  74529. /**
  74530. * Returns the string "SphereDirectedParticleEmitter"
  74531. * @returns a string containing the class name
  74532. */
  74533. getClassName(): string;
  74534. /**
  74535. * Serializes the particle system to a JSON object.
  74536. * @returns the JSON object
  74537. */
  74538. serialize(): any;
  74539. /**
  74540. * Parse properties from a JSON object
  74541. * @param serializationObject defines the JSON object
  74542. */
  74543. parse(serializationObject: any): void;
  74544. }
  74545. }
  74546. declare module BABYLON {
  74547. /**
  74548. * Interface representing a particle system in Babylon.js.
  74549. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  74550. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  74551. */
  74552. export interface IParticleSystem {
  74553. /**
  74554. * List of animations used by the particle system.
  74555. */
  74556. animations: Animation[];
  74557. /**
  74558. * The id of the Particle system.
  74559. */
  74560. id: string;
  74561. /**
  74562. * The name of the Particle system.
  74563. */
  74564. name: string;
  74565. /**
  74566. * The emitter represents the Mesh or position we are attaching the particle system to.
  74567. */
  74568. emitter: Nullable<AbstractMesh | Vector3>;
  74569. /**
  74570. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74571. */
  74572. isBillboardBased: boolean;
  74573. /**
  74574. * The rendering group used by the Particle system to chose when to render.
  74575. */
  74576. renderingGroupId: number;
  74577. /**
  74578. * The layer mask we are rendering the particles through.
  74579. */
  74580. layerMask: number;
  74581. /**
  74582. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74583. */
  74584. updateSpeed: number;
  74585. /**
  74586. * The amount of time the particle system is running (depends of the overall update speed).
  74587. */
  74588. targetStopDuration: number;
  74589. /**
  74590. * The texture used to render each particle. (this can be a spritesheet)
  74591. */
  74592. particleTexture: Nullable<Texture>;
  74593. /**
  74594. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  74595. */
  74596. blendMode: number;
  74597. /**
  74598. * Minimum life time of emitting particles.
  74599. */
  74600. minLifeTime: number;
  74601. /**
  74602. * Maximum life time of emitting particles.
  74603. */
  74604. maxLifeTime: number;
  74605. /**
  74606. * Minimum Size of emitting particles.
  74607. */
  74608. minSize: number;
  74609. /**
  74610. * Maximum Size of emitting particles.
  74611. */
  74612. maxSize: number;
  74613. /**
  74614. * Minimum scale of emitting particles on X axis.
  74615. */
  74616. minScaleX: number;
  74617. /**
  74618. * Maximum scale of emitting particles on X axis.
  74619. */
  74620. maxScaleX: number;
  74621. /**
  74622. * Minimum scale of emitting particles on Y axis.
  74623. */
  74624. minScaleY: number;
  74625. /**
  74626. * Maximum scale of emitting particles on Y axis.
  74627. */
  74628. maxScaleY: number;
  74629. /**
  74630. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74631. */
  74632. color1: Color4;
  74633. /**
  74634. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74635. */
  74636. color2: Color4;
  74637. /**
  74638. * Color the particle will have at the end of its lifetime.
  74639. */
  74640. colorDead: Color4;
  74641. /**
  74642. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  74643. */
  74644. emitRate: number;
  74645. /**
  74646. * You can use gravity if you want to give an orientation to your particles.
  74647. */
  74648. gravity: Vector3;
  74649. /**
  74650. * Minimum power of emitting particles.
  74651. */
  74652. minEmitPower: number;
  74653. /**
  74654. * Maximum power of emitting particles.
  74655. */
  74656. maxEmitPower: number;
  74657. /**
  74658. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74659. */
  74660. minAngularSpeed: number;
  74661. /**
  74662. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74663. */
  74664. maxAngularSpeed: number;
  74665. /**
  74666. * Gets or sets the minimal initial rotation in radians.
  74667. */
  74668. minInitialRotation: number;
  74669. /**
  74670. * Gets or sets the maximal initial rotation in radians.
  74671. */
  74672. maxInitialRotation: number;
  74673. /**
  74674. * The particle emitter type defines the emitter used by the particle system.
  74675. * It can be for example box, sphere, or cone...
  74676. */
  74677. particleEmitterType: Nullable<IParticleEmitterType>;
  74678. /**
  74679. * Defines the delay in milliseconds before starting the system (0 by default)
  74680. */
  74681. startDelay: number;
  74682. /**
  74683. * 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
  74684. */
  74685. preWarmCycles: number;
  74686. /**
  74687. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  74688. */
  74689. preWarmStepOffset: number;
  74690. /**
  74691. * 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)
  74692. */
  74693. spriteCellChangeSpeed: number;
  74694. /**
  74695. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74696. */
  74697. startSpriteCellID: number;
  74698. /**
  74699. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74700. */
  74701. endSpriteCellID: number;
  74702. /**
  74703. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74704. */
  74705. spriteCellWidth: number;
  74706. /**
  74707. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74708. */
  74709. spriteCellHeight: number;
  74710. /**
  74711. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74712. */
  74713. spriteRandomStartCell: boolean;
  74714. /**
  74715. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  74716. */
  74717. isAnimationSheetEnabled: boolean;
  74718. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74719. translationPivot: Vector2;
  74720. /**
  74721. * Gets or sets a texture used to add random noise to particle positions
  74722. */
  74723. noiseTexture: Nullable<BaseTexture>;
  74724. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74725. noiseStrength: Vector3;
  74726. /**
  74727. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74728. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74729. */
  74730. billboardMode: number;
  74731. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74732. limitVelocityDamping: number;
  74733. /**
  74734. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74735. */
  74736. beginAnimationOnStart: boolean;
  74737. /**
  74738. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74739. */
  74740. beginAnimationFrom: number;
  74741. /**
  74742. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74743. */
  74744. beginAnimationTo: number;
  74745. /**
  74746. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74747. */
  74748. beginAnimationLoop: boolean;
  74749. /**
  74750. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74751. */
  74752. disposeOnStop: boolean;
  74753. /**
  74754. * Gets the maximum number of particles active at the same time.
  74755. * @returns The max number of active particles.
  74756. */
  74757. getCapacity(): number;
  74758. /**
  74759. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74760. * @returns True if it has been started, otherwise false.
  74761. */
  74762. isStarted(): boolean;
  74763. /**
  74764. * Animates the particle system for this frame.
  74765. */
  74766. animate(): void;
  74767. /**
  74768. * Renders the particle system in its current state.
  74769. * @returns the current number of particles
  74770. */
  74771. render(): number;
  74772. /**
  74773. * Dispose the particle system and frees its associated resources.
  74774. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74775. */
  74776. dispose(disposeTexture?: boolean): void;
  74777. /**
  74778. * Clones the particle system.
  74779. * @param name The name of the cloned object
  74780. * @param newEmitter The new emitter to use
  74781. * @returns the cloned particle system
  74782. */
  74783. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  74784. /**
  74785. * Serializes the particle system to a JSON object.
  74786. * @returns the JSON object
  74787. */
  74788. serialize(): any;
  74789. /**
  74790. * Rebuild the particle system
  74791. */
  74792. rebuild(): void;
  74793. /**
  74794. * Starts the particle system and begins to emit
  74795. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  74796. */
  74797. start(delay?: number): void;
  74798. /**
  74799. * Stops the particle system.
  74800. */
  74801. stop(): void;
  74802. /**
  74803. * Remove all active particles
  74804. */
  74805. reset(): void;
  74806. /**
  74807. * Is this system ready to be used/rendered
  74808. * @return true if the system is ready
  74809. */
  74810. isReady(): boolean;
  74811. /**
  74812. * Adds a new color gradient
  74813. * @param gradient defines the gradient to use (between 0 and 1)
  74814. * @param color1 defines the color to affect to the specified gradient
  74815. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74816. * @returns the current particle system
  74817. */
  74818. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74819. /**
  74820. * Remove a specific color gradient
  74821. * @param gradient defines the gradient to remove
  74822. * @returns the current particle system
  74823. */
  74824. removeColorGradient(gradient: number): IParticleSystem;
  74825. /**
  74826. * Adds a new size gradient
  74827. * @param gradient defines the gradient to use (between 0 and 1)
  74828. * @param factor defines the size factor to affect to the specified gradient
  74829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74830. * @returns the current particle system
  74831. */
  74832. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74833. /**
  74834. * Remove a specific size gradient
  74835. * @param gradient defines the gradient to remove
  74836. * @returns the current particle system
  74837. */
  74838. removeSizeGradient(gradient: number): IParticleSystem;
  74839. /**
  74840. * Gets the current list of color gradients.
  74841. * You must use addColorGradient and removeColorGradient to udpate this list
  74842. * @returns the list of color gradients
  74843. */
  74844. getColorGradients(): Nullable<Array<ColorGradient>>;
  74845. /**
  74846. * Gets the current list of size gradients.
  74847. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74848. * @returns the list of size gradients
  74849. */
  74850. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74851. /**
  74852. * Gets the current list of angular speed gradients.
  74853. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74854. * @returns the list of angular speed gradients
  74855. */
  74856. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74857. /**
  74858. * Adds a new angular speed gradient
  74859. * @param gradient defines the gradient to use (between 0 and 1)
  74860. * @param factor defines the angular speed to affect to the specified gradient
  74861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74862. * @returns the current particle system
  74863. */
  74864. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74865. /**
  74866. * Remove a specific angular speed gradient
  74867. * @param gradient defines the gradient to remove
  74868. * @returns the current particle system
  74869. */
  74870. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74871. /**
  74872. * Gets the current list of velocity gradients.
  74873. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74874. * @returns the list of velocity gradients
  74875. */
  74876. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74877. /**
  74878. * Adds a new velocity gradient
  74879. * @param gradient defines the gradient to use (between 0 and 1)
  74880. * @param factor defines the velocity to affect to the specified gradient
  74881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74882. * @returns the current particle system
  74883. */
  74884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74885. /**
  74886. * Remove a specific velocity gradient
  74887. * @param gradient defines the gradient to remove
  74888. * @returns the current particle system
  74889. */
  74890. removeVelocityGradient(gradient: number): IParticleSystem;
  74891. /**
  74892. * Gets the current list of limit velocity gradients.
  74893. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74894. * @returns the list of limit velocity gradients
  74895. */
  74896. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74897. /**
  74898. * Adds a new limit velocity gradient
  74899. * @param gradient defines the gradient to use (between 0 and 1)
  74900. * @param factor defines the limit velocity to affect to the specified gradient
  74901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74902. * @returns the current particle system
  74903. */
  74904. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74905. /**
  74906. * Remove a specific limit velocity gradient
  74907. * @param gradient defines the gradient to remove
  74908. * @returns the current particle system
  74909. */
  74910. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74911. /**
  74912. * Adds a new drag gradient
  74913. * @param gradient defines the gradient to use (between 0 and 1)
  74914. * @param factor defines the drag to affect to the specified gradient
  74915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74916. * @returns the current particle system
  74917. */
  74918. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74919. /**
  74920. * Remove a specific drag gradient
  74921. * @param gradient defines the gradient to remove
  74922. * @returns the current particle system
  74923. */
  74924. removeDragGradient(gradient: number): IParticleSystem;
  74925. /**
  74926. * Gets the current list of drag gradients.
  74927. * You must use addDragGradient and removeDragGradient to udpate this list
  74928. * @returns the list of drag gradients
  74929. */
  74930. getDragGradients(): Nullable<Array<FactorGradient>>;
  74931. /**
  74932. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74933. * @param gradient defines the gradient to use (between 0 and 1)
  74934. * @param factor defines the emit rate to affect to the specified gradient
  74935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74936. * @returns the current particle system
  74937. */
  74938. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74939. /**
  74940. * Remove a specific emit rate gradient
  74941. * @param gradient defines the gradient to remove
  74942. * @returns the current particle system
  74943. */
  74944. removeEmitRateGradient(gradient: number): IParticleSystem;
  74945. /**
  74946. * Gets the current list of emit rate gradients.
  74947. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74948. * @returns the list of emit rate gradients
  74949. */
  74950. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74951. /**
  74952. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74953. * @param gradient defines the gradient to use (between 0 and 1)
  74954. * @param factor defines the start size to affect to the specified gradient
  74955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74956. * @returns the current particle system
  74957. */
  74958. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74959. /**
  74960. * Remove a specific start size gradient
  74961. * @param gradient defines the gradient to remove
  74962. * @returns the current particle system
  74963. */
  74964. removeStartSizeGradient(gradient: number): IParticleSystem;
  74965. /**
  74966. * Gets the current list of start size gradients.
  74967. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74968. * @returns the list of start size gradients
  74969. */
  74970. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74971. /**
  74972. * Adds a new life time gradient
  74973. * @param gradient defines the gradient to use (between 0 and 1)
  74974. * @param factor defines the life time factor to affect to the specified gradient
  74975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74976. * @returns the current particle system
  74977. */
  74978. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74979. /**
  74980. * Remove a specific life time gradient
  74981. * @param gradient defines the gradient to remove
  74982. * @returns the current particle system
  74983. */
  74984. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74985. /**
  74986. * Gets the current list of life time gradients.
  74987. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74988. * @returns the list of life time gradients
  74989. */
  74990. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74991. /**
  74992. * Gets the current list of color gradients.
  74993. * You must use addColorGradient and removeColorGradient to udpate this list
  74994. * @returns the list of color gradients
  74995. */
  74996. getColorGradients(): Nullable<Array<ColorGradient>>;
  74997. /**
  74998. * Adds a new ramp gradient used to remap particle colors
  74999. * @param gradient defines the gradient to use (between 0 and 1)
  75000. * @param color defines the color to affect to the specified gradient
  75001. * @returns the current particle system
  75002. */
  75003. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75004. /**
  75005. * Gets the current list of ramp gradients.
  75006. * You must use addRampGradient and removeRampGradient to udpate this list
  75007. * @returns the list of ramp gradients
  75008. */
  75009. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75010. /** Gets or sets a boolean indicating that ramp gradients must be used
  75011. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75012. */
  75013. useRampGradients: boolean;
  75014. /**
  75015. * Adds a new color remap gradient
  75016. * @param gradient defines the gradient to use (between 0 and 1)
  75017. * @param min defines the color remap minimal range
  75018. * @param max defines the color remap maximal range
  75019. * @returns the current particle system
  75020. */
  75021. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75022. /**
  75023. * Gets the current list of color remap gradients.
  75024. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75025. * @returns the list of color remap gradients
  75026. */
  75027. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75028. /**
  75029. * Adds a new alpha remap gradient
  75030. * @param gradient defines the gradient to use (between 0 and 1)
  75031. * @param min defines the alpha remap minimal range
  75032. * @param max defines the alpha remap maximal range
  75033. * @returns the current particle system
  75034. */
  75035. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75036. /**
  75037. * Gets the current list of alpha remap gradients.
  75038. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75039. * @returns the list of alpha remap gradients
  75040. */
  75041. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75042. /**
  75043. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75044. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75045. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75046. * @returns the emitter
  75047. */
  75048. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75049. /**
  75050. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75051. * @param radius The radius of the hemisphere to emit from
  75052. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75053. * @returns the emitter
  75054. */
  75055. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75056. /**
  75057. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75058. * @param radius The radius of the sphere to emit from
  75059. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75060. * @returns the emitter
  75061. */
  75062. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75063. /**
  75064. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75065. * @param radius The radius of the sphere to emit from
  75066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75068. * @returns the emitter
  75069. */
  75070. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75071. /**
  75072. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75073. * @param radius The radius of the emission cylinder
  75074. * @param height The height of the emission cylinder
  75075. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75076. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75077. * @returns the emitter
  75078. */
  75079. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75080. /**
  75081. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75082. * @param radius The radius of the cylinder to emit from
  75083. * @param height The height of the emission cylinder
  75084. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75085. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75086. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75087. * @returns the emitter
  75088. */
  75089. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75090. /**
  75091. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75092. * @param radius The radius of the cone to emit from
  75093. * @param angle The base angle of the cone
  75094. * @returns the emitter
  75095. */
  75096. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75097. /**
  75098. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75099. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75100. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75101. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75102. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75103. * @returns the emitter
  75104. */
  75105. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75106. /**
  75107. * Get hosting scene
  75108. * @returns the scene
  75109. */
  75110. getScene(): Scene;
  75111. }
  75112. }
  75113. declare module BABYLON {
  75114. /**
  75115. * Creates an instance based on a source mesh.
  75116. */
  75117. export class InstancedMesh extends AbstractMesh {
  75118. private _sourceMesh;
  75119. private _currentLOD;
  75120. /** @hidden */
  75121. _indexInSourceMeshInstanceArray: number;
  75122. constructor(name: string, source: Mesh);
  75123. /**
  75124. * Returns the string "InstancedMesh".
  75125. */
  75126. getClassName(): string;
  75127. /**
  75128. * If the source mesh receives shadows
  75129. */
  75130. readonly receiveShadows: boolean;
  75131. /**
  75132. * The material of the source mesh
  75133. */
  75134. readonly material: Nullable<Material>;
  75135. /**
  75136. * Visibility of the source mesh
  75137. */
  75138. readonly visibility: number;
  75139. /**
  75140. * Skeleton of the source mesh
  75141. */
  75142. readonly skeleton: Nullable<Skeleton>;
  75143. /**
  75144. * Rendering ground id of the source mesh
  75145. */
  75146. renderingGroupId: number;
  75147. /**
  75148. * Returns the total number of vertices (integer).
  75149. */
  75150. getTotalVertices(): number;
  75151. /**
  75152. * Returns a positive integer : the total number of indices in this mesh geometry.
  75153. * @returns the numner of indices or zero if the mesh has no geometry.
  75154. */
  75155. getTotalIndices(): number;
  75156. /**
  75157. * The source mesh of the instance
  75158. */
  75159. readonly sourceMesh: Mesh;
  75160. /**
  75161. * Is this node ready to be used/rendered
  75162. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75163. * @return {boolean} is it ready
  75164. */
  75165. isReady(completeCheck?: boolean): boolean;
  75166. /**
  75167. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75168. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75169. * @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.
  75170. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75171. */
  75172. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75173. /**
  75174. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75175. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75176. * The `data` are either a numeric array either a Float32Array.
  75177. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75178. * 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).
  75179. * Note that a new underlying VertexBuffer object is created each call.
  75180. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75181. *
  75182. * Possible `kind` values :
  75183. * - VertexBuffer.PositionKind
  75184. * - VertexBuffer.UVKind
  75185. * - VertexBuffer.UV2Kind
  75186. * - VertexBuffer.UV3Kind
  75187. * - VertexBuffer.UV4Kind
  75188. * - VertexBuffer.UV5Kind
  75189. * - VertexBuffer.UV6Kind
  75190. * - VertexBuffer.ColorKind
  75191. * - VertexBuffer.MatricesIndicesKind
  75192. * - VertexBuffer.MatricesIndicesExtraKind
  75193. * - VertexBuffer.MatricesWeightsKind
  75194. * - VertexBuffer.MatricesWeightsExtraKind
  75195. *
  75196. * Returns the Mesh.
  75197. */
  75198. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75199. /**
  75200. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75201. * If the mesh has no geometry, it is simply returned as it is.
  75202. * The `data` are either a numeric array either a Float32Array.
  75203. * No new underlying VertexBuffer object is created.
  75204. * 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.
  75205. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75206. *
  75207. * Possible `kind` values :
  75208. * - VertexBuffer.PositionKind
  75209. * - VertexBuffer.UVKind
  75210. * - VertexBuffer.UV2Kind
  75211. * - VertexBuffer.UV3Kind
  75212. * - VertexBuffer.UV4Kind
  75213. * - VertexBuffer.UV5Kind
  75214. * - VertexBuffer.UV6Kind
  75215. * - VertexBuffer.ColorKind
  75216. * - VertexBuffer.MatricesIndicesKind
  75217. * - VertexBuffer.MatricesIndicesExtraKind
  75218. * - VertexBuffer.MatricesWeightsKind
  75219. * - VertexBuffer.MatricesWeightsExtraKind
  75220. *
  75221. * Returns the Mesh.
  75222. */
  75223. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75224. /**
  75225. * Sets the mesh indices.
  75226. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75227. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75228. * This method creates a new index buffer each call.
  75229. * Returns the Mesh.
  75230. */
  75231. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75232. /**
  75233. * Boolean : True if the mesh owns the requested kind of data.
  75234. */
  75235. isVerticesDataPresent(kind: string): boolean;
  75236. /**
  75237. * Returns an array of indices (IndicesArray).
  75238. */
  75239. getIndices(): Nullable<IndicesArray>;
  75240. readonly _positions: Nullable<Vector3[]>;
  75241. /**
  75242. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75243. * This means the mesh underlying bounding box and sphere are recomputed.
  75244. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75245. * @returns the current mesh
  75246. */
  75247. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75248. /** @hidden */
  75249. _preActivate(): InstancedMesh;
  75250. /** @hidden */
  75251. _activate(renderId: number): InstancedMesh;
  75252. /**
  75253. * Returns the current associated LOD AbstractMesh.
  75254. */
  75255. getLOD(camera: Camera): AbstractMesh;
  75256. /** @hidden */
  75257. _syncSubMeshes(): InstancedMesh;
  75258. /** @hidden */
  75259. _generatePointsArray(): boolean;
  75260. /**
  75261. * Creates a new InstancedMesh from the current mesh.
  75262. * - name (string) : the cloned mesh name
  75263. * - newParent (optional Node) : the optional Node to parent the clone to.
  75264. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75265. *
  75266. * Returns the clone.
  75267. */
  75268. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75269. /**
  75270. * Disposes the InstancedMesh.
  75271. * Returns nothing.
  75272. */
  75273. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75274. }
  75275. }
  75276. declare module BABYLON {
  75277. /**
  75278. * Defines the options associated with the creation of a shader material.
  75279. */
  75280. export interface IShaderMaterialOptions {
  75281. /**
  75282. * Does the material work in alpha blend mode
  75283. */
  75284. needAlphaBlending: boolean;
  75285. /**
  75286. * Does the material work in alpha test mode
  75287. */
  75288. needAlphaTesting: boolean;
  75289. /**
  75290. * The list of attribute names used in the shader
  75291. */
  75292. attributes: string[];
  75293. /**
  75294. * The list of unifrom names used in the shader
  75295. */
  75296. uniforms: string[];
  75297. /**
  75298. * The list of UBO names used in the shader
  75299. */
  75300. uniformBuffers: string[];
  75301. /**
  75302. * The list of sampler names used in the shader
  75303. */
  75304. samplers: string[];
  75305. /**
  75306. * The list of defines used in the shader
  75307. */
  75308. defines: string[];
  75309. }
  75310. /**
  75311. * 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.
  75312. *
  75313. * This returned material effects how the mesh will look based on the code in the shaders.
  75314. *
  75315. * @see http://doc.babylonjs.com/how_to/shader_material
  75316. */
  75317. export class ShaderMaterial extends Material {
  75318. private _shaderPath;
  75319. private _options;
  75320. private _textures;
  75321. private _textureArrays;
  75322. private _floats;
  75323. private _ints;
  75324. private _floatsArrays;
  75325. private _colors3;
  75326. private _colors3Arrays;
  75327. private _colors4;
  75328. private _vectors2;
  75329. private _vectors3;
  75330. private _vectors4;
  75331. private _matrices;
  75332. private _matrices3x3;
  75333. private _matrices2x2;
  75334. private _vectors2Arrays;
  75335. private _vectors3Arrays;
  75336. private _cachedWorldViewMatrix;
  75337. private _renderId;
  75338. /**
  75339. * Instantiate a new shader material.
  75340. * 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.
  75341. * This returned material effects how the mesh will look based on the code in the shaders.
  75342. * @see http://doc.babylonjs.com/how_to/shader_material
  75343. * @param name Define the name of the material in the scene
  75344. * @param scene Define the scene the material belongs to
  75345. * @param shaderPath Defines the route to the shader code in one of three ways:
  75346. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75347. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75348. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75349. * @param options Define the options used to create the shader
  75350. */
  75351. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75352. /**
  75353. * Gets the options used to compile the shader.
  75354. * They can be modified to trigger a new compilation
  75355. */
  75356. readonly options: IShaderMaterialOptions;
  75357. /**
  75358. * Gets the current class name of the material e.g. "ShaderMaterial"
  75359. * Mainly use in serialization.
  75360. * @returns the class name
  75361. */
  75362. getClassName(): string;
  75363. /**
  75364. * Specifies if the material will require alpha blending
  75365. * @returns a boolean specifying if alpha blending is needed
  75366. */
  75367. needAlphaBlending(): boolean;
  75368. /**
  75369. * Specifies if this material should be rendered in alpha test mode
  75370. * @returns a boolean specifying if an alpha test is needed.
  75371. */
  75372. needAlphaTesting(): boolean;
  75373. private _checkUniform;
  75374. /**
  75375. * Set a texture in the shader.
  75376. * @param name Define the name of the uniform samplers as defined in the shader
  75377. * @param texture Define the texture to bind to this sampler
  75378. * @return the material itself allowing "fluent" like uniform updates
  75379. */
  75380. setTexture(name: string, texture: Texture): ShaderMaterial;
  75381. /**
  75382. * Set a texture array in the shader.
  75383. * @param name Define the name of the uniform sampler array as defined in the shader
  75384. * @param textures Define the list of textures to bind to this sampler
  75385. * @return the material itself allowing "fluent" like uniform updates
  75386. */
  75387. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75388. /**
  75389. * Set a float in the shader.
  75390. * @param name Define the name of the uniform as defined in the shader
  75391. * @param value Define the value to give to the uniform
  75392. * @return the material itself allowing "fluent" like uniform updates
  75393. */
  75394. setFloat(name: string, value: number): ShaderMaterial;
  75395. /**
  75396. * Set a int in the shader.
  75397. * @param name Define the name of the uniform as defined in the shader
  75398. * @param value Define the value to give to the uniform
  75399. * @return the material itself allowing "fluent" like uniform updates
  75400. */
  75401. setInt(name: string, value: number): ShaderMaterial;
  75402. /**
  75403. * Set an array of floats in the shader.
  75404. * @param name Define the name of the uniform as defined in the shader
  75405. * @param value Define the value to give to the uniform
  75406. * @return the material itself allowing "fluent" like uniform updates
  75407. */
  75408. setFloats(name: string, value: number[]): ShaderMaterial;
  75409. /**
  75410. * Set a vec3 in the shader from a Color3.
  75411. * @param name Define the name of the uniform as defined in the shader
  75412. * @param value Define the value to give to the uniform
  75413. * @return the material itself allowing "fluent" like uniform updates
  75414. */
  75415. setColor3(name: string, value: Color3): ShaderMaterial;
  75416. /**
  75417. * Set a vec3 array in the shader from a Color3 array.
  75418. * @param name Define the name of the uniform as defined in the shader
  75419. * @param value Define the value to give to the uniform
  75420. * @return the material itself allowing "fluent" like uniform updates
  75421. */
  75422. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75423. /**
  75424. * Set a vec4 in the shader from a Color4.
  75425. * @param name Define the name of the uniform as defined in the shader
  75426. * @param value Define the value to give to the uniform
  75427. * @return the material itself allowing "fluent" like uniform updates
  75428. */
  75429. setColor4(name: string, value: Color4): ShaderMaterial;
  75430. /**
  75431. * Set a vec2 in the shader from a Vector2.
  75432. * @param name Define the name of the uniform as defined in the shader
  75433. * @param value Define the value to give to the uniform
  75434. * @return the material itself allowing "fluent" like uniform updates
  75435. */
  75436. setVector2(name: string, value: Vector2): ShaderMaterial;
  75437. /**
  75438. * Set a vec3 in the shader from a Vector3.
  75439. * @param name Define the name of the uniform as defined in the shader
  75440. * @param value Define the value to give to the uniform
  75441. * @return the material itself allowing "fluent" like uniform updates
  75442. */
  75443. setVector3(name: string, value: Vector3): ShaderMaterial;
  75444. /**
  75445. * Set a vec4 in the shader from a Vector4.
  75446. * @param name Define the name of the uniform as defined in the shader
  75447. * @param value Define the value to give to the uniform
  75448. * @return the material itself allowing "fluent" like uniform updates
  75449. */
  75450. setVector4(name: string, value: Vector4): ShaderMaterial;
  75451. /**
  75452. * Set a mat4 in the shader from a Matrix.
  75453. * @param name Define the name of the uniform as defined in the shader
  75454. * @param value Define the value to give to the uniform
  75455. * @return the material itself allowing "fluent" like uniform updates
  75456. */
  75457. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75458. /**
  75459. * Set a mat3 in the shader from a Float32Array.
  75460. * @param name Define the name of the uniform as defined in the shader
  75461. * @param value Define the value to give to the uniform
  75462. * @return the material itself allowing "fluent" like uniform updates
  75463. */
  75464. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75465. /**
  75466. * Set a mat2 in the shader from a Float32Array.
  75467. * @param name Define the name of the uniform as defined in the shader
  75468. * @param value Define the value to give to the uniform
  75469. * @return the material itself allowing "fluent" like uniform updates
  75470. */
  75471. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75472. /**
  75473. * Set a vec2 array in the shader from a number array.
  75474. * @param name Define the name of the uniform as defined in the shader
  75475. * @param value Define the value to give to the uniform
  75476. * @return the material itself allowing "fluent" like uniform updates
  75477. */
  75478. setArray2(name: string, value: number[]): ShaderMaterial;
  75479. /**
  75480. * Set a vec3 array in the shader from a number array.
  75481. * @param name Define the name of the uniform as defined in the shader
  75482. * @param value Define the value to give to the uniform
  75483. * @return the material itself allowing "fluent" like uniform updates
  75484. */
  75485. setArray3(name: string, value: number[]): ShaderMaterial;
  75486. private _checkCache;
  75487. /**
  75488. * Specifies that the submesh is ready to be used
  75489. * @param mesh defines the mesh to check
  75490. * @param subMesh defines which submesh to check
  75491. * @param useInstances specifies that instances should be used
  75492. * @returns a boolean indicating that the submesh is ready or not
  75493. */
  75494. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75495. /**
  75496. * Checks if the material is ready to render the requested mesh
  75497. * @param mesh Define the mesh to render
  75498. * @param useInstances Define whether or not the material is used with instances
  75499. * @returns true if ready, otherwise false
  75500. */
  75501. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75502. /**
  75503. * Binds the world matrix to the material
  75504. * @param world defines the world transformation matrix
  75505. */
  75506. bindOnlyWorldMatrix(world: Matrix): void;
  75507. /**
  75508. * Binds the material to the mesh
  75509. * @param world defines the world transformation matrix
  75510. * @param mesh defines the mesh to bind the material to
  75511. */
  75512. bind(world: Matrix, mesh?: Mesh): void;
  75513. /**
  75514. * Gets the active textures from the material
  75515. * @returns an array of textures
  75516. */
  75517. getActiveTextures(): BaseTexture[];
  75518. /**
  75519. * Specifies if the material uses a texture
  75520. * @param texture defines the texture to check against the material
  75521. * @returns a boolean specifying if the material uses the texture
  75522. */
  75523. hasTexture(texture: BaseTexture): boolean;
  75524. /**
  75525. * Makes a duplicate of the material, and gives it a new name
  75526. * @param name defines the new name for the duplicated material
  75527. * @returns the cloned material
  75528. */
  75529. clone(name: string): ShaderMaterial;
  75530. /**
  75531. * Disposes the material
  75532. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75533. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75534. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75535. */
  75536. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75537. /**
  75538. * Serializes this material in a JSON representation
  75539. * @returns the serialized material object
  75540. */
  75541. serialize(): any;
  75542. /**
  75543. * Creates a shader material from parsed shader material data
  75544. * @param source defines the JSON represnetation of the material
  75545. * @param scene defines the hosting scene
  75546. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75547. * @returns a new material
  75548. */
  75549. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75550. }
  75551. }
  75552. declare module BABYLON {
  75553. /** @hidden */
  75554. export var colorPixelShader: {
  75555. name: string;
  75556. shader: string;
  75557. };
  75558. }
  75559. declare module BABYLON {
  75560. /** @hidden */
  75561. export var colorVertexShader: {
  75562. name: string;
  75563. shader: string;
  75564. };
  75565. }
  75566. declare module BABYLON {
  75567. /**
  75568. * Line mesh
  75569. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75570. */
  75571. export class LinesMesh extends Mesh {
  75572. /**
  75573. * If vertex color should be applied to the mesh
  75574. */
  75575. useVertexColor?: boolean | undefined;
  75576. /**
  75577. * If vertex alpha should be applied to the mesh
  75578. */
  75579. useVertexAlpha?: boolean | undefined;
  75580. /**
  75581. * Color of the line (Default: White)
  75582. */
  75583. color: Color3;
  75584. /**
  75585. * Alpha of the line (Default: 1)
  75586. */
  75587. alpha: number;
  75588. /**
  75589. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75590. * This margin is expressed in world space coordinates, so its value may vary.
  75591. * Default value is 0.1
  75592. */
  75593. intersectionThreshold: number;
  75594. private _colorShader;
  75595. /**
  75596. * Creates a new LinesMesh
  75597. * @param name defines the name
  75598. * @param scene defines the hosting scene
  75599. * @param parent defines the parent mesh if any
  75600. * @param source defines the optional source LinesMesh used to clone data from
  75601. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75602. * When false, achieved by calling a clone(), also passing False.
  75603. * This will make creation of children, recursive.
  75604. * @param useVertexColor defines if this LinesMesh supports vertex color
  75605. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75606. */
  75607. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75608. /**
  75609. * If vertex color should be applied to the mesh
  75610. */
  75611. useVertexColor?: boolean | undefined,
  75612. /**
  75613. * If vertex alpha should be applied to the mesh
  75614. */
  75615. useVertexAlpha?: boolean | undefined);
  75616. private _addClipPlaneDefine;
  75617. private _removeClipPlaneDefine;
  75618. isReady(): boolean;
  75619. /**
  75620. * Returns the string "LineMesh"
  75621. */
  75622. getClassName(): string;
  75623. /**
  75624. * @hidden
  75625. */
  75626. /**
  75627. * @hidden
  75628. */
  75629. material: Material;
  75630. /**
  75631. * @hidden
  75632. */
  75633. readonly checkCollisions: boolean;
  75634. /** @hidden */
  75635. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75636. /** @hidden */
  75637. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75638. /**
  75639. * Disposes of the line mesh
  75640. * @param doNotRecurse If children should be disposed
  75641. */
  75642. dispose(doNotRecurse?: boolean): void;
  75643. /**
  75644. * Returns a new LineMesh object cloned from the current one.
  75645. */
  75646. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75647. /**
  75648. * Creates a new InstancedLinesMesh object from the mesh model.
  75649. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75650. * @param name defines the name of the new instance
  75651. * @returns a new InstancedLinesMesh
  75652. */
  75653. createInstance(name: string): InstancedLinesMesh;
  75654. }
  75655. /**
  75656. * Creates an instance based on a source LinesMesh
  75657. */
  75658. export class InstancedLinesMesh extends InstancedMesh {
  75659. /**
  75660. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75661. * This margin is expressed in world space coordinates, so its value may vary.
  75662. * Initilized with the intersectionThreshold value of the source LinesMesh
  75663. */
  75664. intersectionThreshold: number;
  75665. constructor(name: string, source: LinesMesh);
  75666. /**
  75667. * Returns the string "InstancedLinesMesh".
  75668. */
  75669. getClassName(): string;
  75670. }
  75671. }
  75672. declare module BABYLON {
  75673. /** @hidden */
  75674. export var linePixelShader: {
  75675. name: string;
  75676. shader: string;
  75677. };
  75678. }
  75679. declare module BABYLON {
  75680. /** @hidden */
  75681. export var lineVertexShader: {
  75682. name: string;
  75683. shader: string;
  75684. };
  75685. }
  75686. declare module BABYLON {
  75687. interface AbstractMesh {
  75688. /**
  75689. * Disables the mesh edge rendering mode
  75690. * @returns the currentAbstractMesh
  75691. */
  75692. disableEdgesRendering(): AbstractMesh;
  75693. /**
  75694. * Enables the edge rendering mode on the mesh.
  75695. * This mode makes the mesh edges visible
  75696. * @param epsilon defines the maximal distance between two angles to detect a face
  75697. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75698. * @returns the currentAbstractMesh
  75699. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75700. */
  75701. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75702. /**
  75703. * Gets the edgesRenderer associated with the mesh
  75704. */
  75705. edgesRenderer: Nullable<EdgesRenderer>;
  75706. }
  75707. interface LinesMesh {
  75708. /**
  75709. * Enables the edge rendering mode on the mesh.
  75710. * This mode makes the mesh edges visible
  75711. * @param epsilon defines the maximal distance between two angles to detect a face
  75712. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75713. * @returns the currentAbstractMesh
  75714. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75715. */
  75716. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75717. }
  75718. interface InstancedLinesMesh {
  75719. /**
  75720. * Enables the edge rendering mode on the mesh.
  75721. * This mode makes the mesh edges visible
  75722. * @param epsilon defines the maximal distance between two angles to detect a face
  75723. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75724. * @returns the current InstancedLinesMesh
  75725. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75726. */
  75727. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  75728. }
  75729. /**
  75730. * Defines the minimum contract an Edges renderer should follow.
  75731. */
  75732. export interface IEdgesRenderer extends IDisposable {
  75733. /**
  75734. * Gets or sets a boolean indicating if the edgesRenderer is active
  75735. */
  75736. isEnabled: boolean;
  75737. /**
  75738. * Renders the edges of the attached mesh,
  75739. */
  75740. render(): void;
  75741. /**
  75742. * Checks wether or not the edges renderer is ready to render.
  75743. * @return true if ready, otherwise false.
  75744. */
  75745. isReady(): boolean;
  75746. }
  75747. /**
  75748. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  75749. */
  75750. export class EdgesRenderer implements IEdgesRenderer {
  75751. /**
  75752. * Define the size of the edges with an orthographic camera
  75753. */
  75754. edgesWidthScalerForOrthographic: number;
  75755. /**
  75756. * Define the size of the edges with a perspective camera
  75757. */
  75758. edgesWidthScalerForPerspective: number;
  75759. protected _source: AbstractMesh;
  75760. protected _linesPositions: number[];
  75761. protected _linesNormals: number[];
  75762. protected _linesIndices: number[];
  75763. protected _epsilon: number;
  75764. protected _indicesCount: number;
  75765. protected _lineShader: ShaderMaterial;
  75766. protected _ib: WebGLBuffer;
  75767. protected _buffers: {
  75768. [key: string]: Nullable<VertexBuffer>;
  75769. };
  75770. protected _checkVerticesInsteadOfIndices: boolean;
  75771. private _meshRebuildObserver;
  75772. private _meshDisposeObserver;
  75773. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  75774. isEnabled: boolean;
  75775. /**
  75776. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  75777. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  75778. * @param source Mesh used to create edges
  75779. * @param epsilon sum of angles in adjacency to check for edge
  75780. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  75781. * @param generateEdgesLines - should generate Lines or only prepare resources.
  75782. */
  75783. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  75784. protected _prepareRessources(): void;
  75785. /** @hidden */
  75786. _rebuild(): void;
  75787. /**
  75788. * Releases the required resources for the edges renderer
  75789. */
  75790. dispose(): void;
  75791. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  75792. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  75793. /**
  75794. * Checks if the pair of p0 and p1 is en edge
  75795. * @param faceIndex
  75796. * @param edge
  75797. * @param faceNormals
  75798. * @param p0
  75799. * @param p1
  75800. * @private
  75801. */
  75802. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  75803. /**
  75804. * push line into the position, normal and index buffer
  75805. * @protected
  75806. */
  75807. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  75808. /**
  75809. * Generates lines edges from adjacencjes
  75810. * @private
  75811. */
  75812. _generateEdgesLines(): void;
  75813. /**
  75814. * Checks wether or not the edges renderer is ready to render.
  75815. * @return true if ready, otherwise false.
  75816. */
  75817. isReady(): boolean;
  75818. /**
  75819. * Renders the edges of the attached mesh,
  75820. */
  75821. render(): void;
  75822. }
  75823. /**
  75824. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  75825. */
  75826. export class LineEdgesRenderer extends EdgesRenderer {
  75827. /**
  75828. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  75829. * @param source LineMesh used to generate edges
  75830. * @param epsilon not important (specified angle for edge detection)
  75831. * @param checkVerticesInsteadOfIndices not important for LineMesh
  75832. */
  75833. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  75834. /**
  75835. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  75836. */
  75837. _generateEdgesLines(): void;
  75838. }
  75839. }
  75840. declare module BABYLON {
  75841. /**
  75842. * This represents the object necessary to create a rendering group.
  75843. * This is exclusively used and created by the rendering manager.
  75844. * To modify the behavior, you use the available helpers in your scene or meshes.
  75845. * @hidden
  75846. */
  75847. export class RenderingGroup {
  75848. index: number;
  75849. private _scene;
  75850. private _opaqueSubMeshes;
  75851. private _transparentSubMeshes;
  75852. private _alphaTestSubMeshes;
  75853. private _depthOnlySubMeshes;
  75854. private _particleSystems;
  75855. private _spriteManagers;
  75856. private _opaqueSortCompareFn;
  75857. private _alphaTestSortCompareFn;
  75858. private _transparentSortCompareFn;
  75859. private _renderOpaque;
  75860. private _renderAlphaTest;
  75861. private _renderTransparent;
  75862. private _edgesRenderers;
  75863. onBeforeTransparentRendering: () => void;
  75864. /**
  75865. * Set the opaque sort comparison function.
  75866. * If null the sub meshes will be render in the order they were created
  75867. */
  75868. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75869. /**
  75870. * Set the alpha test sort comparison function.
  75871. * If null the sub meshes will be render in the order they were created
  75872. */
  75873. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75874. /**
  75875. * Set the transparent sort comparison function.
  75876. * If null the sub meshes will be render in the order they were created
  75877. */
  75878. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75879. /**
  75880. * Creates a new rendering group.
  75881. * @param index The rendering group index
  75882. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  75883. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  75884. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  75885. */
  75886. 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>);
  75887. /**
  75888. * Render all the sub meshes contained in the group.
  75889. * @param customRenderFunction Used to override the default render behaviour of the group.
  75890. * @returns true if rendered some submeshes.
  75891. */
  75892. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  75893. /**
  75894. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  75895. * @param subMeshes The submeshes to render
  75896. */
  75897. private renderOpaqueSorted;
  75898. /**
  75899. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  75900. * @param subMeshes The submeshes to render
  75901. */
  75902. private renderAlphaTestSorted;
  75903. /**
  75904. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  75905. * @param subMeshes The submeshes to render
  75906. */
  75907. private renderTransparentSorted;
  75908. /**
  75909. * Renders the submeshes in a specified order.
  75910. * @param subMeshes The submeshes to sort before render
  75911. * @param sortCompareFn The comparison function use to sort
  75912. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  75913. * @param transparent Specifies to activate blending if true
  75914. */
  75915. private static renderSorted;
  75916. /**
  75917. * Renders the submeshes in the order they were dispatched (no sort applied).
  75918. * @param subMeshes The submeshes to render
  75919. */
  75920. private static renderUnsorted;
  75921. /**
  75922. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75923. * are rendered back to front if in the same alpha index.
  75924. *
  75925. * @param a The first submesh
  75926. * @param b The second submesh
  75927. * @returns The result of the comparison
  75928. */
  75929. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  75930. /**
  75931. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75932. * are rendered back to front.
  75933. *
  75934. * @param a The first submesh
  75935. * @param b The second submesh
  75936. * @returns The result of the comparison
  75937. */
  75938. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  75939. /**
  75940. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75941. * are rendered front to back (prevent overdraw).
  75942. *
  75943. * @param a The first submesh
  75944. * @param b The second submesh
  75945. * @returns The result of the comparison
  75946. */
  75947. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  75948. /**
  75949. * Resets the different lists of submeshes to prepare a new frame.
  75950. */
  75951. prepare(): void;
  75952. dispose(): void;
  75953. /**
  75954. * Inserts the submesh in its correct queue depending on its material.
  75955. * @param subMesh The submesh to dispatch
  75956. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75957. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75958. */
  75959. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75960. dispatchSprites(spriteManager: ISpriteManager): void;
  75961. dispatchParticles(particleSystem: IParticleSystem): void;
  75962. private _renderParticles;
  75963. private _renderSprites;
  75964. }
  75965. }
  75966. declare module BABYLON {
  75967. /**
  75968. * Interface describing the different options available in the rendering manager
  75969. * regarding Auto Clear between groups.
  75970. */
  75971. export interface IRenderingManagerAutoClearSetup {
  75972. /**
  75973. * Defines whether or not autoclear is enable.
  75974. */
  75975. autoClear: boolean;
  75976. /**
  75977. * Defines whether or not to autoclear the depth buffer.
  75978. */
  75979. depth: boolean;
  75980. /**
  75981. * Defines whether or not to autoclear the stencil buffer.
  75982. */
  75983. stencil: boolean;
  75984. }
  75985. /**
  75986. * This class is used by the onRenderingGroupObservable
  75987. */
  75988. export class RenderingGroupInfo {
  75989. /**
  75990. * The Scene that being rendered
  75991. */
  75992. scene: Scene;
  75993. /**
  75994. * The camera currently used for the rendering pass
  75995. */
  75996. camera: Nullable<Camera>;
  75997. /**
  75998. * The ID of the renderingGroup being processed
  75999. */
  76000. renderingGroupId: number;
  76001. }
  76002. /**
  76003. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76004. * It is enable to manage the different groups as well as the different necessary sort functions.
  76005. * This should not be used directly aside of the few static configurations
  76006. */
  76007. export class RenderingManager {
  76008. /**
  76009. * The max id used for rendering groups (not included)
  76010. */
  76011. static MAX_RENDERINGGROUPS: number;
  76012. /**
  76013. * The min id used for rendering groups (included)
  76014. */
  76015. static MIN_RENDERINGGROUPS: number;
  76016. /**
  76017. * Used to globally prevent autoclearing scenes.
  76018. */
  76019. static AUTOCLEAR: boolean;
  76020. /**
  76021. * @hidden
  76022. */
  76023. _useSceneAutoClearSetup: boolean;
  76024. private _scene;
  76025. private _renderingGroups;
  76026. private _depthStencilBufferAlreadyCleaned;
  76027. private _autoClearDepthStencil;
  76028. private _customOpaqueSortCompareFn;
  76029. private _customAlphaTestSortCompareFn;
  76030. private _customTransparentSortCompareFn;
  76031. private _renderingGroupInfo;
  76032. /**
  76033. * Instantiates a new rendering group for a particular scene
  76034. * @param scene Defines the scene the groups belongs to
  76035. */
  76036. constructor(scene: Scene);
  76037. private _clearDepthStencilBuffer;
  76038. /**
  76039. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76040. * @hidden
  76041. */
  76042. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76043. /**
  76044. * Resets the different information of the group to prepare a new frame
  76045. * @hidden
  76046. */
  76047. reset(): void;
  76048. /**
  76049. * Dispose and release the group and its associated resources.
  76050. * @hidden
  76051. */
  76052. dispose(): void;
  76053. /**
  76054. * Clear the info related to rendering groups preventing retention points during dispose.
  76055. */
  76056. freeRenderingGroups(): void;
  76057. private _prepareRenderingGroup;
  76058. /**
  76059. * Add a sprite manager to the rendering manager in order to render it this frame.
  76060. * @param spriteManager Define the sprite manager to render
  76061. */
  76062. dispatchSprites(spriteManager: ISpriteManager): void;
  76063. /**
  76064. * Add a particle system to the rendering manager in order to render it this frame.
  76065. * @param particleSystem Define the particle system to render
  76066. */
  76067. dispatchParticles(particleSystem: IParticleSystem): void;
  76068. /**
  76069. * Add a submesh to the manager in order to render it this frame
  76070. * @param subMesh The submesh to dispatch
  76071. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76072. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76073. */
  76074. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76075. /**
  76076. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76077. * This allowed control for front to back rendering or reversly depending of the special needs.
  76078. *
  76079. * @param renderingGroupId The rendering group id corresponding to its index
  76080. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76081. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76082. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76083. */
  76084. 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;
  76085. /**
  76086. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76087. *
  76088. * @param renderingGroupId The rendering group id corresponding to its index
  76089. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76090. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76091. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76092. */
  76093. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76094. /**
  76095. * Gets the current auto clear configuration for one rendering group of the rendering
  76096. * manager.
  76097. * @param index the rendering group index to get the information for
  76098. * @returns The auto clear setup for the requested rendering group
  76099. */
  76100. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76101. }
  76102. }
  76103. declare module BABYLON {
  76104. /**
  76105. * This Helps creating a texture that will be created from a camera in your scene.
  76106. * It is basically a dynamic texture that could be used to create special effects for instance.
  76107. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76108. */
  76109. export class RenderTargetTexture extends Texture {
  76110. isCube: boolean;
  76111. /**
  76112. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76113. */
  76114. static readonly REFRESHRATE_RENDER_ONCE: number;
  76115. /**
  76116. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76117. */
  76118. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76119. /**
  76120. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76121. * the central point of your effect and can save a lot of performances.
  76122. */
  76123. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76124. /**
  76125. * Use this predicate to dynamically define the list of mesh you want to render.
  76126. * If set, the renderList property will be overwritten.
  76127. */
  76128. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76129. private _renderList;
  76130. /**
  76131. * Use this list to define the list of mesh you want to render.
  76132. */
  76133. renderList: Nullable<Array<AbstractMesh>>;
  76134. private _hookArray;
  76135. /**
  76136. * Define if particles should be rendered in your texture.
  76137. */
  76138. renderParticles: boolean;
  76139. /**
  76140. * Define if sprites should be rendered in your texture.
  76141. */
  76142. renderSprites: boolean;
  76143. /**
  76144. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76145. */
  76146. coordinatesMode: number;
  76147. /**
  76148. * Define the camera used to render the texture.
  76149. */
  76150. activeCamera: Nullable<Camera>;
  76151. /**
  76152. * Override the render function of the texture with your own one.
  76153. */
  76154. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76155. /**
  76156. * Define if camera post processes should be use while rendering the texture.
  76157. */
  76158. useCameraPostProcesses: boolean;
  76159. /**
  76160. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76161. */
  76162. ignoreCameraViewport: boolean;
  76163. private _postProcessManager;
  76164. private _postProcesses;
  76165. private _resizeObserver;
  76166. /**
  76167. * An event triggered when the texture is unbind.
  76168. */
  76169. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76170. /**
  76171. * An event triggered when the texture is unbind.
  76172. */
  76173. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76174. private _onAfterUnbindObserver;
  76175. /**
  76176. * Set a after unbind callback in the texture.
  76177. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76178. */
  76179. onAfterUnbind: () => void;
  76180. /**
  76181. * An event triggered before rendering the texture
  76182. */
  76183. onBeforeRenderObservable: Observable<number>;
  76184. private _onBeforeRenderObserver;
  76185. /**
  76186. * Set a before render callback in the texture.
  76187. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76188. */
  76189. onBeforeRender: (faceIndex: number) => void;
  76190. /**
  76191. * An event triggered after rendering the texture
  76192. */
  76193. onAfterRenderObservable: Observable<number>;
  76194. private _onAfterRenderObserver;
  76195. /**
  76196. * Set a after render callback in the texture.
  76197. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76198. */
  76199. onAfterRender: (faceIndex: number) => void;
  76200. /**
  76201. * An event triggered after the texture clear
  76202. */
  76203. onClearObservable: Observable<Engine>;
  76204. private _onClearObserver;
  76205. /**
  76206. * Set a clear callback in the texture.
  76207. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76208. */
  76209. onClear: (Engine: Engine) => void;
  76210. /**
  76211. * Define the clear color of the Render Target if it should be different from the scene.
  76212. */
  76213. clearColor: Color4;
  76214. protected _size: number | {
  76215. width: number;
  76216. height: number;
  76217. };
  76218. protected _initialSizeParameter: number | {
  76219. width: number;
  76220. height: number;
  76221. } | {
  76222. ratio: number;
  76223. };
  76224. protected _sizeRatio: Nullable<number>;
  76225. /** @hidden */
  76226. _generateMipMaps: boolean;
  76227. protected _renderingManager: RenderingManager;
  76228. /** @hidden */
  76229. _waitingRenderList: string[];
  76230. protected _doNotChangeAspectRatio: boolean;
  76231. protected _currentRefreshId: number;
  76232. protected _refreshRate: number;
  76233. protected _textureMatrix: Matrix;
  76234. protected _samples: number;
  76235. protected _renderTargetOptions: RenderTargetCreationOptions;
  76236. /**
  76237. * Gets render target creation options that were used.
  76238. */
  76239. readonly renderTargetOptions: RenderTargetCreationOptions;
  76240. protected _engine: Engine;
  76241. protected _onRatioRescale(): void;
  76242. /**
  76243. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76244. * It must define where the camera used to render the texture is set
  76245. */
  76246. boundingBoxPosition: Vector3;
  76247. private _boundingBoxSize;
  76248. /**
  76249. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76250. * When defined, the cubemap will switch to local mode
  76251. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76252. * @example https://www.babylonjs-playground.com/#RNASML
  76253. */
  76254. boundingBoxSize: Vector3;
  76255. /**
  76256. * In case the RTT has been created with a depth texture, get the associated
  76257. * depth texture.
  76258. * Otherwise, return null.
  76259. */
  76260. depthStencilTexture: Nullable<InternalTexture>;
  76261. /**
  76262. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  76263. * or used a shadow, depth texture...
  76264. * @param name The friendly name of the texture
  76265. * @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)
  76266. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  76267. * @param generateMipMaps True if mip maps need to be generated after render.
  76268. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  76269. * @param type The type of the buffer in the RTT (int, half float, float...)
  76270. * @param isCube True if a cube texture needs to be created
  76271. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  76272. * @param generateDepthBuffer True to generate a depth buffer
  76273. * @param generateStencilBuffer True to generate a stencil buffer
  76274. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  76275. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  76276. * @param delayAllocation if the texture allocation should be delayed (default: false)
  76277. */
  76278. constructor(name: string, size: number | {
  76279. width: number;
  76280. height: number;
  76281. } | {
  76282. ratio: number;
  76283. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  76284. /**
  76285. * Creates a depth stencil texture.
  76286. * This is only available in WebGL 2 or with the depth texture extension available.
  76287. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76288. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76289. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76290. */
  76291. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  76292. private _processSizeParameter;
  76293. /**
  76294. * Define the number of samples to use in case of MSAA.
  76295. * It defaults to one meaning no MSAA has been enabled.
  76296. */
  76297. samples: number;
  76298. /**
  76299. * Resets the refresh counter of the texture and start bak from scratch.
  76300. * Could be useful to regenerate the texture if it is setup to render only once.
  76301. */
  76302. resetRefreshCounter(): void;
  76303. /**
  76304. * Define the refresh rate of the texture or the rendering frequency.
  76305. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76306. */
  76307. refreshRate: number;
  76308. /**
  76309. * Adds a post process to the render target rendering passes.
  76310. * @param postProcess define the post process to add
  76311. */
  76312. addPostProcess(postProcess: PostProcess): void;
  76313. /**
  76314. * Clear all the post processes attached to the render target
  76315. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  76316. */
  76317. clearPostProcesses(dispose?: boolean): void;
  76318. /**
  76319. * Remove one of the post process from the list of attached post processes to the texture
  76320. * @param postProcess define the post process to remove from the list
  76321. */
  76322. removePostProcess(postProcess: PostProcess): void;
  76323. /** @hidden */
  76324. _shouldRender(): boolean;
  76325. /**
  76326. * Gets the actual render size of the texture.
  76327. * @returns the width of the render size
  76328. */
  76329. getRenderSize(): number;
  76330. /**
  76331. * Gets the actual render width of the texture.
  76332. * @returns the width of the render size
  76333. */
  76334. getRenderWidth(): number;
  76335. /**
  76336. * Gets the actual render height of the texture.
  76337. * @returns the height of the render size
  76338. */
  76339. getRenderHeight(): number;
  76340. /**
  76341. * Get if the texture can be rescaled or not.
  76342. */
  76343. readonly canRescale: boolean;
  76344. /**
  76345. * Resize the texture using a ratio.
  76346. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  76347. */
  76348. scale(ratio: number): void;
  76349. /**
  76350. * Get the texture reflection matrix used to rotate/transform the reflection.
  76351. * @returns the reflection matrix
  76352. */
  76353. getReflectionTextureMatrix(): Matrix;
  76354. /**
  76355. * Resize the texture to a new desired size.
  76356. * Be carrefull as it will recreate all the data in the new texture.
  76357. * @param size Define the new size. It can be:
  76358. * - a number for squared texture,
  76359. * - an object containing { width: number, height: number }
  76360. * - or an object containing a ratio { ratio: number }
  76361. */
  76362. resize(size: number | {
  76363. width: number;
  76364. height: number;
  76365. } | {
  76366. ratio: number;
  76367. }): void;
  76368. /**
  76369. * Renders all the objects from the render list into the texture.
  76370. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  76371. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  76372. */
  76373. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  76374. private _bestReflectionRenderTargetDimension;
  76375. /**
  76376. * @hidden
  76377. * @param faceIndex face index to bind to if this is a cubetexture
  76378. */
  76379. _bindFrameBuffer(faceIndex?: number): void;
  76380. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  76381. private renderToTarget;
  76382. /**
  76383. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76384. * This allowed control for front to back rendering or reversly depending of the special needs.
  76385. *
  76386. * @param renderingGroupId The rendering group id corresponding to its index
  76387. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76388. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76389. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76390. */
  76391. 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;
  76392. /**
  76393. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76394. *
  76395. * @param renderingGroupId The rendering group id corresponding to its index
  76396. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76397. */
  76398. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76399. /**
  76400. * Clones the texture.
  76401. * @returns the cloned texture
  76402. */
  76403. clone(): RenderTargetTexture;
  76404. /**
  76405. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76406. * @returns The JSON representation of the texture
  76407. */
  76408. serialize(): any;
  76409. /**
  76410. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76411. */
  76412. disposeFramebufferObjects(): void;
  76413. /**
  76414. * Dispose the texture and release its associated resources.
  76415. */
  76416. dispose(): void;
  76417. /** @hidden */
  76418. _rebuild(): void;
  76419. /**
  76420. * Clear the info related to rendering groups preventing retention point in material dispose.
  76421. */
  76422. freeRenderingGroups(): void;
  76423. /**
  76424. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  76425. * @returns the view count
  76426. */
  76427. getViewCount(): number;
  76428. }
  76429. /**
  76430. * Renders to multiple views with a single draw call
  76431. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  76432. */
  76433. export class MultiviewRenderTarget extends RenderTargetTexture {
  76434. /**
  76435. * Creates a multiview render target
  76436. * @param scene scene used with the render target
  76437. * @param size the size of the render target (used for each view)
  76438. */
  76439. constructor(scene: Scene, size?: number | {
  76440. width: number;
  76441. height: number;
  76442. } | {
  76443. ratio: number;
  76444. });
  76445. /**
  76446. * @hidden
  76447. * @param faceIndex the face index, if its a cube texture
  76448. */
  76449. _bindFrameBuffer(faceIndex?: number): void;
  76450. /**
  76451. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  76452. * @returns the view count
  76453. */
  76454. getViewCount(): number;
  76455. }
  76456. }
  76457. declare module BABYLON {
  76458. /**
  76459. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76460. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76461. * You can then easily use it as a reflectionTexture on a flat surface.
  76462. * In case the surface is not a plane, please consider relying on reflection probes.
  76463. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76464. */
  76465. export class MirrorTexture extends RenderTargetTexture {
  76466. private scene;
  76467. /**
  76468. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76469. * 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.
  76470. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76471. */
  76472. mirrorPlane: Plane;
  76473. /**
  76474. * Define the blur ratio used to blur the reflection if needed.
  76475. */
  76476. blurRatio: number;
  76477. /**
  76478. * Define the adaptive blur kernel used to blur the reflection if needed.
  76479. * This will autocompute the closest best match for the `blurKernel`
  76480. */
  76481. adaptiveBlurKernel: number;
  76482. /**
  76483. * Define the blur kernel used to blur the reflection if needed.
  76484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76485. */
  76486. blurKernel: number;
  76487. /**
  76488. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76489. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76490. */
  76491. blurKernelX: number;
  76492. /**
  76493. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76494. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76495. */
  76496. blurKernelY: number;
  76497. private _autoComputeBlurKernel;
  76498. protected _onRatioRescale(): void;
  76499. private _updateGammaSpace;
  76500. private _imageProcessingConfigChangeObserver;
  76501. private _transformMatrix;
  76502. private _mirrorMatrix;
  76503. private _savedViewMatrix;
  76504. private _blurX;
  76505. private _blurY;
  76506. private _adaptiveBlurKernel;
  76507. private _blurKernelX;
  76508. private _blurKernelY;
  76509. private _blurRatio;
  76510. /**
  76511. * Instantiates a Mirror Texture.
  76512. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76513. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76514. * You can then easily use it as a reflectionTexture on a flat surface.
  76515. * In case the surface is not a plane, please consider relying on reflection probes.
  76516. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76517. * @param name
  76518. * @param size
  76519. * @param scene
  76520. * @param generateMipMaps
  76521. * @param type
  76522. * @param samplingMode
  76523. * @param generateDepthBuffer
  76524. */
  76525. constructor(name: string, size: number | {
  76526. width: number;
  76527. height: number;
  76528. } | {
  76529. ratio: number;
  76530. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76531. private _preparePostProcesses;
  76532. /**
  76533. * Clone the mirror texture.
  76534. * @returns the cloned texture
  76535. */
  76536. clone(): MirrorTexture;
  76537. /**
  76538. * Serialize the texture to a JSON representation you could use in Parse later on
  76539. * @returns the serialized JSON representation
  76540. */
  76541. serialize(): any;
  76542. /**
  76543. * Dispose the texture and release its associated resources.
  76544. */
  76545. dispose(): void;
  76546. }
  76547. }
  76548. declare module BABYLON {
  76549. /**
  76550. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76551. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76552. */
  76553. export class Texture extends BaseTexture {
  76554. /** @hidden */
  76555. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76556. /** @hidden */
  76557. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76558. /** @hidden */
  76559. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76560. /** nearest is mag = nearest and min = nearest and mip = linear */
  76561. static readonly NEAREST_SAMPLINGMODE: number;
  76562. /** nearest is mag = nearest and min = nearest and mip = linear */
  76563. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76565. static readonly BILINEAR_SAMPLINGMODE: number;
  76566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76567. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76568. /** Trilinear is mag = linear and min = linear and mip = linear */
  76569. static readonly TRILINEAR_SAMPLINGMODE: number;
  76570. /** Trilinear is mag = linear and min = linear and mip = linear */
  76571. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76572. /** mag = nearest and min = nearest and mip = nearest */
  76573. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76574. /** mag = nearest and min = linear and mip = nearest */
  76575. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76576. /** mag = nearest and min = linear and mip = linear */
  76577. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  76578. /** mag = nearest and min = linear and mip = none */
  76579. static readonly NEAREST_LINEAR: number;
  76580. /** mag = nearest and min = nearest and mip = none */
  76581. static readonly NEAREST_NEAREST: number;
  76582. /** mag = linear and min = nearest and mip = nearest */
  76583. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  76584. /** mag = linear and min = nearest and mip = linear */
  76585. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  76586. /** mag = linear and min = linear and mip = none */
  76587. static readonly LINEAR_LINEAR: number;
  76588. /** mag = linear and min = nearest and mip = none */
  76589. static readonly LINEAR_NEAREST: number;
  76590. /** Explicit coordinates mode */
  76591. static readonly EXPLICIT_MODE: number;
  76592. /** Spherical coordinates mode */
  76593. static readonly SPHERICAL_MODE: number;
  76594. /** Planar coordinates mode */
  76595. static readonly PLANAR_MODE: number;
  76596. /** Cubic coordinates mode */
  76597. static readonly CUBIC_MODE: number;
  76598. /** Projection coordinates mode */
  76599. static readonly PROJECTION_MODE: number;
  76600. /** Inverse Cubic coordinates mode */
  76601. static readonly SKYBOX_MODE: number;
  76602. /** Inverse Cubic coordinates mode */
  76603. static readonly INVCUBIC_MODE: number;
  76604. /** Equirectangular coordinates mode */
  76605. static readonly EQUIRECTANGULAR_MODE: number;
  76606. /** Equirectangular Fixed coordinates mode */
  76607. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  76608. /** Equirectangular Fixed Mirrored coordinates mode */
  76609. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76610. /** Texture is not repeating outside of 0..1 UVs */
  76611. static readonly CLAMP_ADDRESSMODE: number;
  76612. /** Texture is repeating outside of 0..1 UVs */
  76613. static readonly WRAP_ADDRESSMODE: number;
  76614. /** Texture is repeating and mirrored */
  76615. static readonly MIRROR_ADDRESSMODE: number;
  76616. /**
  76617. * 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
  76618. */
  76619. static UseSerializedUrlIfAny: boolean;
  76620. /**
  76621. * Define the url of the texture.
  76622. */
  76623. url: Nullable<string>;
  76624. /**
  76625. * Define an offset on the texture to offset the u coordinates of the UVs
  76626. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76627. */
  76628. uOffset: number;
  76629. /**
  76630. * Define an offset on the texture to offset the v coordinates of the UVs
  76631. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76632. */
  76633. vOffset: number;
  76634. /**
  76635. * Define an offset on the texture to scale the u coordinates of the UVs
  76636. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76637. */
  76638. uScale: number;
  76639. /**
  76640. * Define an offset on the texture to scale the v coordinates of the UVs
  76641. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76642. */
  76643. vScale: number;
  76644. /**
  76645. * Define an offset on the texture to rotate around the u coordinates of the UVs
  76646. * @see http://doc.babylonjs.com/how_to/more_materials
  76647. */
  76648. uAng: number;
  76649. /**
  76650. * Define an offset on the texture to rotate around the v coordinates of the UVs
  76651. * @see http://doc.babylonjs.com/how_to/more_materials
  76652. */
  76653. vAng: number;
  76654. /**
  76655. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  76656. * @see http://doc.babylonjs.com/how_to/more_materials
  76657. */
  76658. wAng: number;
  76659. /**
  76660. * Defines the center of rotation (U)
  76661. */
  76662. uRotationCenter: number;
  76663. /**
  76664. * Defines the center of rotation (V)
  76665. */
  76666. vRotationCenter: number;
  76667. /**
  76668. * Defines the center of rotation (W)
  76669. */
  76670. wRotationCenter: number;
  76671. /**
  76672. * Are mip maps generated for this texture or not.
  76673. */
  76674. readonly noMipmap: boolean;
  76675. /**
  76676. * List of inspectable custom properties (used by the Inspector)
  76677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76678. */
  76679. inspectableCustomProperties: IInspectable[];
  76680. private _noMipmap;
  76681. /** @hidden */
  76682. _invertY: boolean;
  76683. private _rowGenerationMatrix;
  76684. private _cachedTextureMatrix;
  76685. private _projectionModeMatrix;
  76686. private _t0;
  76687. private _t1;
  76688. private _t2;
  76689. private _cachedUOffset;
  76690. private _cachedVOffset;
  76691. private _cachedUScale;
  76692. private _cachedVScale;
  76693. private _cachedUAng;
  76694. private _cachedVAng;
  76695. private _cachedWAng;
  76696. private _cachedProjectionMatrixId;
  76697. private _cachedCoordinatesMode;
  76698. /** @hidden */
  76699. protected _initialSamplingMode: number;
  76700. /** @hidden */
  76701. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  76702. private _deleteBuffer;
  76703. protected _format: Nullable<number>;
  76704. private _delayedOnLoad;
  76705. private _delayedOnError;
  76706. /**
  76707. * Observable triggered once the texture has been loaded.
  76708. */
  76709. onLoadObservable: Observable<Texture>;
  76710. protected _isBlocking: boolean;
  76711. /**
  76712. * Is the texture preventing material to render while loading.
  76713. * If false, a default texture will be used instead of the loading one during the preparation step.
  76714. */
  76715. isBlocking: boolean;
  76716. /**
  76717. * Get the current sampling mode associated with the texture.
  76718. */
  76719. readonly samplingMode: number;
  76720. /**
  76721. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  76722. */
  76723. readonly invertY: boolean;
  76724. /**
  76725. * Instantiates a new texture.
  76726. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76727. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76728. * @param url define the url of the picture to load as a texture
  76729. * @param scene define the scene the texture will belong to
  76730. * @param noMipmap define if the texture will require mip maps or not
  76731. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76732. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76733. * @param onLoad define a callback triggered when the texture has been loaded
  76734. * @param onError define a callback triggered when an error occurred during the loading session
  76735. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76736. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76737. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76738. */
  76739. 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);
  76740. /**
  76741. * Update the url (and optional buffer) of this texture if url was null during construction.
  76742. * @param url the url of the texture
  76743. * @param buffer the buffer of the texture (defaults to null)
  76744. * @param onLoad callback called when the texture is loaded (defaults to null)
  76745. */
  76746. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  76747. /**
  76748. * Finish the loading sequence of a texture flagged as delayed load.
  76749. * @hidden
  76750. */
  76751. delayLoad(): void;
  76752. private _prepareRowForTextureGeneration;
  76753. /**
  76754. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  76755. * @returns the transform matrix of the texture.
  76756. */
  76757. getTextureMatrix(): Matrix;
  76758. /**
  76759. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  76760. * @returns The reflection texture transform
  76761. */
  76762. getReflectionTextureMatrix(): Matrix;
  76763. /**
  76764. * Clones the texture.
  76765. * @returns the cloned texture
  76766. */
  76767. clone(): Texture;
  76768. /**
  76769. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76770. * @returns The JSON representation of the texture
  76771. */
  76772. serialize(): any;
  76773. /**
  76774. * Get the current class name of the texture useful for serialization or dynamic coding.
  76775. * @returns "Texture"
  76776. */
  76777. getClassName(): string;
  76778. /**
  76779. * Dispose the texture and release its associated resources.
  76780. */
  76781. dispose(): void;
  76782. /**
  76783. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  76784. * @param parsedTexture Define the JSON representation of the texture
  76785. * @param scene Define the scene the parsed texture should be instantiated in
  76786. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  76787. * @returns The parsed texture if successful
  76788. */
  76789. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  76790. /**
  76791. * Creates a texture from its base 64 representation.
  76792. * @param data Define the base64 payload without the data: prefix
  76793. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76794. * @param scene Define the scene the texture should belong to
  76795. * @param noMipmap Forces the texture to not create mip map information if true
  76796. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76797. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76798. * @param onLoad define a callback triggered when the texture has been loaded
  76799. * @param onError define a callback triggered when an error occurred during the loading session
  76800. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76801. * @returns the created texture
  76802. */
  76803. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  76804. /**
  76805. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  76806. * @param data Define the base64 payload without the data: prefix
  76807. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76808. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76809. * @param scene Define the scene the texture should belong to
  76810. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76811. * @param noMipmap Forces the texture to not create mip map information if true
  76812. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76813. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76814. * @param onLoad define a callback triggered when the texture has been loaded
  76815. * @param onError define a callback triggered when an error occurred during the loading session
  76816. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76817. * @returns the created texture
  76818. */
  76819. 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;
  76820. }
  76821. }
  76822. declare module BABYLON {
  76823. /**
  76824. * Raw texture can help creating a texture directly from an array of data.
  76825. * This can be super useful if you either get the data from an uncompressed source or
  76826. * if you wish to create your texture pixel by pixel.
  76827. */
  76828. export class RawTexture extends Texture {
  76829. /**
  76830. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76831. */
  76832. format: number;
  76833. private _engine;
  76834. /**
  76835. * Instantiates a new RawTexture.
  76836. * Raw texture can help creating a texture directly from an array of data.
  76837. * This can be super useful if you either get the data from an uncompressed source or
  76838. * if you wish to create your texture pixel by pixel.
  76839. * @param data define the array of data to use to create the texture
  76840. * @param width define the width of the texture
  76841. * @param height define the height of the texture
  76842. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76843. * @param scene define the scene the texture belongs to
  76844. * @param generateMipMaps define whether mip maps should be generated or not
  76845. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76846. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76847. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76848. */
  76849. constructor(data: ArrayBufferView, width: number, height: number,
  76850. /**
  76851. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76852. */
  76853. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76854. /**
  76855. * Updates the texture underlying data.
  76856. * @param data Define the new data of the texture
  76857. */
  76858. update(data: ArrayBufferView): void;
  76859. /**
  76860. * Creates a luminance texture from some data.
  76861. * @param data Define the texture data
  76862. * @param width Define the width of the texture
  76863. * @param height Define the height of the texture
  76864. * @param scene Define the scene the texture belongs to
  76865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76868. * @returns the luminance texture
  76869. */
  76870. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76871. /**
  76872. * Creates a luminance alpha texture from some data.
  76873. * @param data Define the texture data
  76874. * @param width Define the width of the texture
  76875. * @param height Define the height of the texture
  76876. * @param scene Define the scene the texture belongs to
  76877. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76878. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76879. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76880. * @returns the luminance alpha texture
  76881. */
  76882. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76883. /**
  76884. * Creates an alpha texture from some data.
  76885. * @param data Define the texture data
  76886. * @param width Define the width of the texture
  76887. * @param height Define the height of the texture
  76888. * @param scene Define the scene the texture belongs to
  76889. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76890. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76891. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76892. * @returns the alpha texture
  76893. */
  76894. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76895. /**
  76896. * Creates a RGB texture from some data.
  76897. * @param data Define the texture data
  76898. * @param width Define the width of the texture
  76899. * @param height Define the height of the texture
  76900. * @param scene Define the scene the texture belongs to
  76901. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76905. * @returns the RGB alpha texture
  76906. */
  76907. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76908. /**
  76909. * Creates a RGBA texture from some data.
  76910. * @param data Define the texture data
  76911. * @param width Define the width of the texture
  76912. * @param height Define the height of the texture
  76913. * @param scene Define the scene the texture belongs to
  76914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76917. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76918. * @returns the RGBA texture
  76919. */
  76920. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76921. /**
  76922. * Creates a R texture from some data.
  76923. * @param data Define the texture data
  76924. * @param width Define the width of the texture
  76925. * @param height Define the height of the texture
  76926. * @param scene Define the scene the texture belongs to
  76927. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76928. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76929. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76930. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76931. * @returns the R texture
  76932. */
  76933. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76934. }
  76935. }
  76936. declare module BABYLON {
  76937. /**
  76938. * Defines a runtime animation
  76939. */
  76940. export class RuntimeAnimation {
  76941. private _events;
  76942. /**
  76943. * The current frame of the runtime animation
  76944. */
  76945. private _currentFrame;
  76946. /**
  76947. * The animation used by the runtime animation
  76948. */
  76949. private _animation;
  76950. /**
  76951. * The target of the runtime animation
  76952. */
  76953. private _target;
  76954. /**
  76955. * The initiating animatable
  76956. */
  76957. private _host;
  76958. /**
  76959. * The original value of the runtime animation
  76960. */
  76961. private _originalValue;
  76962. /**
  76963. * The original blend value of the runtime animation
  76964. */
  76965. private _originalBlendValue;
  76966. /**
  76967. * The offsets cache of the runtime animation
  76968. */
  76969. private _offsetsCache;
  76970. /**
  76971. * The high limits cache of the runtime animation
  76972. */
  76973. private _highLimitsCache;
  76974. /**
  76975. * Specifies if the runtime animation has been stopped
  76976. */
  76977. private _stopped;
  76978. /**
  76979. * The blending factor of the runtime animation
  76980. */
  76981. private _blendingFactor;
  76982. /**
  76983. * The BabylonJS scene
  76984. */
  76985. private _scene;
  76986. /**
  76987. * The current value of the runtime animation
  76988. */
  76989. private _currentValue;
  76990. /** @hidden */
  76991. _workValue: any;
  76992. /**
  76993. * The active target of the runtime animation
  76994. */
  76995. private _activeTarget;
  76996. /**
  76997. * The target path of the runtime animation
  76998. */
  76999. private _targetPath;
  77000. /**
  77001. * The weight of the runtime animation
  77002. */
  77003. private _weight;
  77004. /**
  77005. * The ratio offset of the runtime animation
  77006. */
  77007. private _ratioOffset;
  77008. /**
  77009. * The previous delay of the runtime animation
  77010. */
  77011. private _previousDelay;
  77012. /**
  77013. * The previous ratio of the runtime animation
  77014. */
  77015. private _previousRatio;
  77016. /**
  77017. * Gets the current frame of the runtime animation
  77018. */
  77019. readonly currentFrame: number;
  77020. /**
  77021. * Gets the weight of the runtime animation
  77022. */
  77023. readonly weight: number;
  77024. /**
  77025. * Gets the current value of the runtime animation
  77026. */
  77027. readonly currentValue: any;
  77028. /**
  77029. * Gets the target path of the runtime animation
  77030. */
  77031. readonly targetPath: string;
  77032. /**
  77033. * Gets the actual target of the runtime animation
  77034. */
  77035. readonly target: any;
  77036. /**
  77037. * Create a new RuntimeAnimation object
  77038. * @param target defines the target of the animation
  77039. * @param animation defines the source animation object
  77040. * @param scene defines the hosting scene
  77041. * @param host defines the initiating Animatable
  77042. */
  77043. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77044. /**
  77045. * Gets the animation from the runtime animation
  77046. */
  77047. readonly animation: Animation;
  77048. /**
  77049. * Resets the runtime animation to the beginning
  77050. * @param restoreOriginal defines whether to restore the target property to the original value
  77051. */
  77052. reset(restoreOriginal?: boolean): void;
  77053. /**
  77054. * Specifies if the runtime animation is stopped
  77055. * @returns Boolean specifying if the runtime animation is stopped
  77056. */
  77057. isStopped(): boolean;
  77058. /**
  77059. * Disposes of the runtime animation
  77060. */
  77061. dispose(): void;
  77062. /**
  77063. * Interpolates the animation from the current frame
  77064. * @param currentFrame The frame to interpolate the animation to
  77065. * @param repeatCount The number of times that the animation should loop
  77066. * @param loopMode The type of looping mode to use
  77067. * @param offsetValue Animation offset value
  77068. * @param highLimitValue The high limit value
  77069. * @returns The interpolated value
  77070. */
  77071. private _interpolate;
  77072. /**
  77073. * Apply the interpolated value to the target
  77074. * @param currentValue defines the value computed by the animation
  77075. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77076. */
  77077. setValue(currentValue: any, weight?: number): void;
  77078. private _setValue;
  77079. /**
  77080. * Gets the loop pmode of the runtime animation
  77081. * @returns Loop Mode
  77082. */
  77083. private _getCorrectLoopMode;
  77084. /**
  77085. * Move the current animation to a given frame
  77086. * @param frame defines the frame to move to
  77087. */
  77088. goToFrame(frame: number): void;
  77089. /**
  77090. * @hidden Internal use only
  77091. */
  77092. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77093. /**
  77094. * Execute the current animation
  77095. * @param delay defines the delay to add to the current frame
  77096. * @param from defines the lower bound of the animation range
  77097. * @param to defines the upper bound of the animation range
  77098. * @param loop defines if the current animation must loop
  77099. * @param speedRatio defines the current speed ratio
  77100. * @param weight defines the weight of the animation (default is -1 so no weight)
  77101. * @param onLoop optional callback called when animation loops
  77102. * @returns a boolean indicating if the animation is running
  77103. */
  77104. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77105. }
  77106. }
  77107. declare module BABYLON {
  77108. /**
  77109. * Class used to store an actual running animation
  77110. */
  77111. export class Animatable {
  77112. /** defines the target object */
  77113. target: any;
  77114. /** defines the starting frame number (default is 0) */
  77115. fromFrame: number;
  77116. /** defines the ending frame number (default is 100) */
  77117. toFrame: number;
  77118. /** defines if the animation must loop (default is false) */
  77119. loopAnimation: boolean;
  77120. /** defines a callback to call when animation ends if it is not looping */
  77121. onAnimationEnd?: (() => void) | null | undefined;
  77122. /** defines a callback to call when animation loops */
  77123. onAnimationLoop?: (() => void) | null | undefined;
  77124. private _localDelayOffset;
  77125. private _pausedDelay;
  77126. private _runtimeAnimations;
  77127. private _paused;
  77128. private _scene;
  77129. private _speedRatio;
  77130. private _weight;
  77131. private _syncRoot;
  77132. /**
  77133. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77134. * This will only apply for non looping animation (default is true)
  77135. */
  77136. disposeOnEnd: boolean;
  77137. /**
  77138. * Gets a boolean indicating if the animation has started
  77139. */
  77140. animationStarted: boolean;
  77141. /**
  77142. * Observer raised when the animation ends
  77143. */
  77144. onAnimationEndObservable: Observable<Animatable>;
  77145. /**
  77146. * Observer raised when the animation loops
  77147. */
  77148. onAnimationLoopObservable: Observable<Animatable>;
  77149. /**
  77150. * Gets the root Animatable used to synchronize and normalize animations
  77151. */
  77152. readonly syncRoot: Animatable;
  77153. /**
  77154. * Gets the current frame of the first RuntimeAnimation
  77155. * Used to synchronize Animatables
  77156. */
  77157. readonly masterFrame: number;
  77158. /**
  77159. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77160. */
  77161. weight: number;
  77162. /**
  77163. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77164. */
  77165. speedRatio: number;
  77166. /**
  77167. * Creates a new Animatable
  77168. * @param scene defines the hosting scene
  77169. * @param target defines the target object
  77170. * @param fromFrame defines the starting frame number (default is 0)
  77171. * @param toFrame defines the ending frame number (default is 100)
  77172. * @param loopAnimation defines if the animation must loop (default is false)
  77173. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77174. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77175. * @param animations defines a group of animation to add to the new Animatable
  77176. * @param onAnimationLoop defines a callback to call when animation loops
  77177. */
  77178. constructor(scene: Scene,
  77179. /** defines the target object */
  77180. target: any,
  77181. /** defines the starting frame number (default is 0) */
  77182. fromFrame?: number,
  77183. /** defines the ending frame number (default is 100) */
  77184. toFrame?: number,
  77185. /** defines if the animation must loop (default is false) */
  77186. loopAnimation?: boolean, speedRatio?: number,
  77187. /** defines a callback to call when animation ends if it is not looping */
  77188. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77189. /** defines a callback to call when animation loops */
  77190. onAnimationLoop?: (() => void) | null | undefined);
  77191. /**
  77192. * Synchronize and normalize current Animatable with a source Animatable
  77193. * This is useful when using animation weights and when animations are not of the same length
  77194. * @param root defines the root Animatable to synchronize with
  77195. * @returns the current Animatable
  77196. */
  77197. syncWith(root: Animatable): Animatable;
  77198. /**
  77199. * Gets the list of runtime animations
  77200. * @returns an array of RuntimeAnimation
  77201. */
  77202. getAnimations(): RuntimeAnimation[];
  77203. /**
  77204. * Adds more animations to the current animatable
  77205. * @param target defines the target of the animations
  77206. * @param animations defines the new animations to add
  77207. */
  77208. appendAnimations(target: any, animations: Animation[]): void;
  77209. /**
  77210. * Gets the source animation for a specific property
  77211. * @param property defines the propertyu to look for
  77212. * @returns null or the source animation for the given property
  77213. */
  77214. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77215. /**
  77216. * Gets the runtime animation for a specific property
  77217. * @param property defines the propertyu to look for
  77218. * @returns null or the runtime animation for the given property
  77219. */
  77220. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77221. /**
  77222. * Resets the animatable to its original state
  77223. */
  77224. reset(): void;
  77225. /**
  77226. * Allows the animatable to blend with current running animations
  77227. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77228. * @param blendingSpeed defines the blending speed to use
  77229. */
  77230. enableBlending(blendingSpeed: number): void;
  77231. /**
  77232. * Disable animation blending
  77233. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77234. */
  77235. disableBlending(): void;
  77236. /**
  77237. * Jump directly to a given frame
  77238. * @param frame defines the frame to jump to
  77239. */
  77240. goToFrame(frame: number): void;
  77241. /**
  77242. * Pause the animation
  77243. */
  77244. pause(): void;
  77245. /**
  77246. * Restart the animation
  77247. */
  77248. restart(): void;
  77249. private _raiseOnAnimationEnd;
  77250. /**
  77251. * Stop and delete the current animation
  77252. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77253. * @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)
  77254. */
  77255. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77256. /**
  77257. * Wait asynchronously for the animation to end
  77258. * @returns a promise which will be fullfilled when the animation ends
  77259. */
  77260. waitAsync(): Promise<Animatable>;
  77261. /** @hidden */
  77262. _animate(delay: number): boolean;
  77263. }
  77264. interface Scene {
  77265. /** @hidden */
  77266. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77267. /** @hidden */
  77268. _processLateAnimationBindingsForMatrices(holder: {
  77269. totalWeight: number;
  77270. animations: RuntimeAnimation[];
  77271. originalValue: Matrix;
  77272. }): any;
  77273. /** @hidden */
  77274. _processLateAnimationBindingsForQuaternions(holder: {
  77275. totalWeight: number;
  77276. animations: RuntimeAnimation[];
  77277. originalValue: Quaternion;
  77278. }, refQuaternion: Quaternion): Quaternion;
  77279. /** @hidden */
  77280. _processLateAnimationBindings(): void;
  77281. /**
  77282. * Will start the animation sequence of a given target
  77283. * @param target defines the target
  77284. * @param from defines from which frame should animation start
  77285. * @param to defines until which frame should animation run.
  77286. * @param weight defines the weight to apply to the animation (1.0 by default)
  77287. * @param loop defines if the animation loops
  77288. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77289. * @param onAnimationEnd defines the function to be executed when the animation ends
  77290. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77291. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77292. * @param onAnimationLoop defines the callback to call when an animation loops
  77293. * @returns the animatable object created for this animation
  77294. */
  77295. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77296. /**
  77297. * Will start the animation sequence of a given target
  77298. * @param target defines the target
  77299. * @param from defines from which frame should animation start
  77300. * @param to defines until which frame should animation run.
  77301. * @param loop defines if the animation loops
  77302. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77303. * @param onAnimationEnd defines the function to be executed when the animation ends
  77304. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77305. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77306. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77307. * @param onAnimationLoop defines the callback to call when an animation loops
  77308. * @returns the animatable object created for this animation
  77309. */
  77310. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77311. /**
  77312. * Will start the animation sequence of a given target and its hierarchy
  77313. * @param target defines the target
  77314. * @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.
  77315. * @param from defines from which frame should animation start
  77316. * @param to defines until which frame should animation run.
  77317. * @param loop defines if the animation loops
  77318. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77319. * @param onAnimationEnd defines the function to be executed when the animation ends
  77320. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77321. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77322. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77323. * @param onAnimationLoop defines the callback to call when an animation loops
  77324. * @returns the list of created animatables
  77325. */
  77326. 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[];
  77327. /**
  77328. * Begin a new animation on a given node
  77329. * @param target defines the target where the animation will take place
  77330. * @param animations defines the list of animations to start
  77331. * @param from defines the initial value
  77332. * @param to defines the final value
  77333. * @param loop defines if you want animation to loop (off by default)
  77334. * @param speedRatio defines the speed ratio to apply to all animations
  77335. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77336. * @param onAnimationLoop defines the callback to call when an animation loops
  77337. * @returns the list of created animatables
  77338. */
  77339. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77340. /**
  77341. * Begin a new animation on a given node and its hierarchy
  77342. * @param target defines the root node where the animation will take place
  77343. * @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.
  77344. * @param animations defines the list of animations to start
  77345. * @param from defines the initial value
  77346. * @param to defines the final value
  77347. * @param loop defines if you want animation to loop (off by default)
  77348. * @param speedRatio defines the speed ratio to apply to all animations
  77349. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77350. * @param onAnimationLoop defines the callback to call when an animation loops
  77351. * @returns the list of animatables created for all nodes
  77352. */
  77353. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77354. /**
  77355. * Gets the animatable associated with a specific target
  77356. * @param target defines the target of the animatable
  77357. * @returns the required animatable if found
  77358. */
  77359. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77360. /**
  77361. * Gets all animatables associated with a given target
  77362. * @param target defines the target to look animatables for
  77363. * @returns an array of Animatables
  77364. */
  77365. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77366. /**
  77367. * Will stop the animation of the given target
  77368. * @param target - the target
  77369. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  77370. * @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)
  77371. */
  77372. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  77373. /**
  77374. * Stops and removes all animations that have been applied to the scene
  77375. */
  77376. stopAllAnimations(): void;
  77377. }
  77378. interface Bone {
  77379. /**
  77380. * Copy an animation range from another bone
  77381. * @param source defines the source bone
  77382. * @param rangeName defines the range name to copy
  77383. * @param frameOffset defines the frame offset
  77384. * @param rescaleAsRequired defines if rescaling must be applied if required
  77385. * @param skelDimensionsRatio defines the scaling ratio
  77386. * @returns true if operation was successful
  77387. */
  77388. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77389. }
  77390. }
  77391. declare module BABYLON {
  77392. /**
  77393. * Class used to handle skinning animations
  77394. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77395. */
  77396. export class Skeleton implements IAnimatable {
  77397. /** defines the skeleton name */
  77398. name: string;
  77399. /** defines the skeleton Id */
  77400. id: string;
  77401. /**
  77402. * Defines the list of child bones
  77403. */
  77404. bones: Bone[];
  77405. /**
  77406. * Defines an estimate of the dimension of the skeleton at rest
  77407. */
  77408. dimensionsAtRest: Vector3;
  77409. /**
  77410. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77411. */
  77412. needInitialSkinMatrix: boolean;
  77413. /**
  77414. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77415. */
  77416. overrideMesh: Nullable<AbstractMesh>;
  77417. /**
  77418. * Gets the list of animations attached to this skeleton
  77419. */
  77420. animations: Array<Animation>;
  77421. private _scene;
  77422. private _isDirty;
  77423. private _transformMatrices;
  77424. private _transformMatrixTexture;
  77425. private _meshesWithPoseMatrix;
  77426. private _animatables;
  77427. private _identity;
  77428. private _synchronizedWithMesh;
  77429. private _ranges;
  77430. private _lastAbsoluteTransformsUpdateId;
  77431. private _canUseTextureForBones;
  77432. private _uniqueId;
  77433. /** @hidden */
  77434. _numBonesWithLinkedTransformNode: number;
  77435. /**
  77436. * Specifies if the skeleton should be serialized
  77437. */
  77438. doNotSerialize: boolean;
  77439. private _useTextureToStoreBoneMatrices;
  77440. /**
  77441. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77442. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77443. */
  77444. useTextureToStoreBoneMatrices: boolean;
  77445. private _animationPropertiesOverride;
  77446. /**
  77447. * Gets or sets the animation properties override
  77448. */
  77449. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77450. /**
  77451. * List of inspectable custom properties (used by the Inspector)
  77452. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77453. */
  77454. inspectableCustomProperties: IInspectable[];
  77455. /**
  77456. * An observable triggered before computing the skeleton's matrices
  77457. */
  77458. onBeforeComputeObservable: Observable<Skeleton>;
  77459. /**
  77460. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77461. */
  77462. readonly isUsingTextureForMatrices: boolean;
  77463. /**
  77464. * Gets the unique ID of this skeleton
  77465. */
  77466. readonly uniqueId: number;
  77467. /**
  77468. * Creates a new skeleton
  77469. * @param name defines the skeleton name
  77470. * @param id defines the skeleton Id
  77471. * @param scene defines the hosting scene
  77472. */
  77473. constructor(
  77474. /** defines the skeleton name */
  77475. name: string,
  77476. /** defines the skeleton Id */
  77477. id: string, scene: Scene);
  77478. /**
  77479. * Gets the current object class name.
  77480. * @return the class name
  77481. */
  77482. getClassName(): string;
  77483. /**
  77484. * Returns an array containing the root bones
  77485. * @returns an array containing the root bones
  77486. */
  77487. getChildren(): Array<Bone>;
  77488. /**
  77489. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77490. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77491. * @returns a Float32Array containing matrices data
  77492. */
  77493. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77494. /**
  77495. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77496. * @returns a raw texture containing the data
  77497. */
  77498. getTransformMatrixTexture(): Nullable<RawTexture>;
  77499. /**
  77500. * Gets the current hosting scene
  77501. * @returns a scene object
  77502. */
  77503. getScene(): Scene;
  77504. /**
  77505. * Gets a string representing the current skeleton data
  77506. * @param fullDetails defines a boolean indicating if we want a verbose version
  77507. * @returns a string representing the current skeleton data
  77508. */
  77509. toString(fullDetails?: boolean): string;
  77510. /**
  77511. * Get bone's index searching by name
  77512. * @param name defines bone's name to search for
  77513. * @return the indice of the bone. Returns -1 if not found
  77514. */
  77515. getBoneIndexByName(name: string): number;
  77516. /**
  77517. * Creater a new animation range
  77518. * @param name defines the name of the range
  77519. * @param from defines the start key
  77520. * @param to defines the end key
  77521. */
  77522. createAnimationRange(name: string, from: number, to: number): void;
  77523. /**
  77524. * Delete a specific animation range
  77525. * @param name defines the name of the range
  77526. * @param deleteFrames defines if frames must be removed as well
  77527. */
  77528. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77529. /**
  77530. * Gets a specific animation range
  77531. * @param name defines the name of the range to look for
  77532. * @returns the requested animation range or null if not found
  77533. */
  77534. getAnimationRange(name: string): Nullable<AnimationRange>;
  77535. /**
  77536. * Gets the list of all animation ranges defined on this skeleton
  77537. * @returns an array
  77538. */
  77539. getAnimationRanges(): Nullable<AnimationRange>[];
  77540. /**
  77541. * Copy animation range from a source skeleton.
  77542. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77543. * @param source defines the source skeleton
  77544. * @param name defines the name of the range to copy
  77545. * @param rescaleAsRequired defines if rescaling must be applied if required
  77546. * @returns true if operation was successful
  77547. */
  77548. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77549. /**
  77550. * Forces the skeleton to go to rest pose
  77551. */
  77552. returnToRest(): void;
  77553. private _getHighestAnimationFrame;
  77554. /**
  77555. * Begin a specific animation range
  77556. * @param name defines the name of the range to start
  77557. * @param loop defines if looping must be turned on (false by default)
  77558. * @param speedRatio defines the speed ratio to apply (1 by default)
  77559. * @param onAnimationEnd defines a callback which will be called when animation will end
  77560. * @returns a new animatable
  77561. */
  77562. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77563. /** @hidden */
  77564. _markAsDirty(): void;
  77565. /** @hidden */
  77566. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77567. /** @hidden */
  77568. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77569. private _computeTransformMatrices;
  77570. /**
  77571. * Build all resources required to render a skeleton
  77572. */
  77573. prepare(): void;
  77574. /**
  77575. * Gets the list of animatables currently running for this skeleton
  77576. * @returns an array of animatables
  77577. */
  77578. getAnimatables(): IAnimatable[];
  77579. /**
  77580. * Clone the current skeleton
  77581. * @param name defines the name of the new skeleton
  77582. * @param id defines the id of the enw skeleton
  77583. * @returns the new skeleton
  77584. */
  77585. clone(name: string, id: string): Skeleton;
  77586. /**
  77587. * Enable animation blending for this skeleton
  77588. * @param blendingSpeed defines the blending speed to apply
  77589. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77590. */
  77591. enableBlending(blendingSpeed?: number): void;
  77592. /**
  77593. * Releases all resources associated with the current skeleton
  77594. */
  77595. dispose(): void;
  77596. /**
  77597. * Serialize the skeleton in a JSON object
  77598. * @returns a JSON object
  77599. */
  77600. serialize(): any;
  77601. /**
  77602. * Creates a new skeleton from serialized data
  77603. * @param parsedSkeleton defines the serialized data
  77604. * @param scene defines the hosting scene
  77605. * @returns a new skeleton
  77606. */
  77607. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77608. /**
  77609. * Compute all node absolute transforms
  77610. * @param forceUpdate defines if computation must be done even if cache is up to date
  77611. */
  77612. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77613. /**
  77614. * Gets the root pose matrix
  77615. * @returns a matrix
  77616. */
  77617. getPoseMatrix(): Nullable<Matrix>;
  77618. /**
  77619. * Sorts bones per internal index
  77620. */
  77621. sortBones(): void;
  77622. private _sortBones;
  77623. }
  77624. }
  77625. declare module BABYLON {
  77626. /**
  77627. * Defines a target to use with MorphTargetManager
  77628. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77629. */
  77630. export class MorphTarget implements IAnimatable {
  77631. /** defines the name of the target */
  77632. name: string;
  77633. /**
  77634. * Gets or sets the list of animations
  77635. */
  77636. animations: Animation[];
  77637. private _scene;
  77638. private _positions;
  77639. private _normals;
  77640. private _tangents;
  77641. private _influence;
  77642. /**
  77643. * Observable raised when the influence changes
  77644. */
  77645. onInfluenceChanged: Observable<boolean>;
  77646. /** @hidden */
  77647. _onDataLayoutChanged: Observable<void>;
  77648. /**
  77649. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  77650. */
  77651. influence: number;
  77652. /**
  77653. * Gets or sets the id of the morph Target
  77654. */
  77655. id: string;
  77656. private _animationPropertiesOverride;
  77657. /**
  77658. * Gets or sets the animation properties override
  77659. */
  77660. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77661. /**
  77662. * Creates a new MorphTarget
  77663. * @param name defines the name of the target
  77664. * @param influence defines the influence to use
  77665. * @param scene defines the scene the morphtarget belongs to
  77666. */
  77667. constructor(
  77668. /** defines the name of the target */
  77669. name: string, influence?: number, scene?: Nullable<Scene>);
  77670. /**
  77671. * Gets a boolean defining if the target contains position data
  77672. */
  77673. readonly hasPositions: boolean;
  77674. /**
  77675. * Gets a boolean defining if the target contains normal data
  77676. */
  77677. readonly hasNormals: boolean;
  77678. /**
  77679. * Gets a boolean defining if the target contains tangent data
  77680. */
  77681. readonly hasTangents: boolean;
  77682. /**
  77683. * Affects position data to this target
  77684. * @param data defines the position data to use
  77685. */
  77686. setPositions(data: Nullable<FloatArray>): void;
  77687. /**
  77688. * Gets the position data stored in this target
  77689. * @returns a FloatArray containing the position data (or null if not present)
  77690. */
  77691. getPositions(): Nullable<FloatArray>;
  77692. /**
  77693. * Affects normal data to this target
  77694. * @param data defines the normal data to use
  77695. */
  77696. setNormals(data: Nullable<FloatArray>): void;
  77697. /**
  77698. * Gets the normal data stored in this target
  77699. * @returns a FloatArray containing the normal data (or null if not present)
  77700. */
  77701. getNormals(): Nullable<FloatArray>;
  77702. /**
  77703. * Affects tangent data to this target
  77704. * @param data defines the tangent data to use
  77705. */
  77706. setTangents(data: Nullable<FloatArray>): void;
  77707. /**
  77708. * Gets the tangent data stored in this target
  77709. * @returns a FloatArray containing the tangent data (or null if not present)
  77710. */
  77711. getTangents(): Nullable<FloatArray>;
  77712. /**
  77713. * Serializes the current target into a Serialization object
  77714. * @returns the serialized object
  77715. */
  77716. serialize(): any;
  77717. /**
  77718. * Returns the string "MorphTarget"
  77719. * @returns "MorphTarget"
  77720. */
  77721. getClassName(): string;
  77722. /**
  77723. * Creates a new target from serialized data
  77724. * @param serializationObject defines the serialized data to use
  77725. * @returns a new MorphTarget
  77726. */
  77727. static Parse(serializationObject: any): MorphTarget;
  77728. /**
  77729. * Creates a MorphTarget from mesh data
  77730. * @param mesh defines the source mesh
  77731. * @param name defines the name to use for the new target
  77732. * @param influence defines the influence to attach to the target
  77733. * @returns a new MorphTarget
  77734. */
  77735. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  77736. }
  77737. }
  77738. declare module BABYLON {
  77739. /**
  77740. * This class is used to deform meshes using morphing between different targets
  77741. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77742. */
  77743. export class MorphTargetManager {
  77744. private _targets;
  77745. private _targetInfluenceChangedObservers;
  77746. private _targetDataLayoutChangedObservers;
  77747. private _activeTargets;
  77748. private _scene;
  77749. private _influences;
  77750. private _supportsNormals;
  77751. private _supportsTangents;
  77752. private _vertexCount;
  77753. private _uniqueId;
  77754. private _tempInfluences;
  77755. /**
  77756. * Creates a new MorphTargetManager
  77757. * @param scene defines the current scene
  77758. */
  77759. constructor(scene?: Nullable<Scene>);
  77760. /**
  77761. * Gets the unique ID of this manager
  77762. */
  77763. readonly uniqueId: number;
  77764. /**
  77765. * Gets the number of vertices handled by this manager
  77766. */
  77767. readonly vertexCount: number;
  77768. /**
  77769. * Gets a boolean indicating if this manager supports morphing of normals
  77770. */
  77771. readonly supportsNormals: boolean;
  77772. /**
  77773. * Gets a boolean indicating if this manager supports morphing of tangents
  77774. */
  77775. readonly supportsTangents: boolean;
  77776. /**
  77777. * Gets the number of targets stored in this manager
  77778. */
  77779. readonly numTargets: number;
  77780. /**
  77781. * Gets the number of influencers (ie. the number of targets with influences > 0)
  77782. */
  77783. readonly numInfluencers: number;
  77784. /**
  77785. * Gets the list of influences (one per target)
  77786. */
  77787. readonly influences: Float32Array;
  77788. /**
  77789. * Gets the active target at specified index. An active target is a target with an influence > 0
  77790. * @param index defines the index to check
  77791. * @returns the requested target
  77792. */
  77793. getActiveTarget(index: number): MorphTarget;
  77794. /**
  77795. * Gets the target at specified index
  77796. * @param index defines the index to check
  77797. * @returns the requested target
  77798. */
  77799. getTarget(index: number): MorphTarget;
  77800. /**
  77801. * Add a new target to this manager
  77802. * @param target defines the target to add
  77803. */
  77804. addTarget(target: MorphTarget): void;
  77805. /**
  77806. * Removes a target from the manager
  77807. * @param target defines the target to remove
  77808. */
  77809. removeTarget(target: MorphTarget): void;
  77810. /**
  77811. * Serializes the current manager into a Serialization object
  77812. * @returns the serialized object
  77813. */
  77814. serialize(): any;
  77815. private _syncActiveTargets;
  77816. /**
  77817. * Syncrhonize the targets with all the meshes using this morph target manager
  77818. */
  77819. synchronize(): void;
  77820. /**
  77821. * Creates a new MorphTargetManager from serialized data
  77822. * @param serializationObject defines the serialized data
  77823. * @param scene defines the hosting scene
  77824. * @returns the new MorphTargetManager
  77825. */
  77826. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  77827. }
  77828. }
  77829. declare module BABYLON {
  77830. /**
  77831. * Mesh representing the gorund
  77832. */
  77833. export class GroundMesh extends Mesh {
  77834. /** If octree should be generated */
  77835. generateOctree: boolean;
  77836. private _heightQuads;
  77837. /** @hidden */
  77838. _subdivisionsX: number;
  77839. /** @hidden */
  77840. _subdivisionsY: number;
  77841. /** @hidden */
  77842. _width: number;
  77843. /** @hidden */
  77844. _height: number;
  77845. /** @hidden */
  77846. _minX: number;
  77847. /** @hidden */
  77848. _maxX: number;
  77849. /** @hidden */
  77850. _minZ: number;
  77851. /** @hidden */
  77852. _maxZ: number;
  77853. constructor(name: string, scene: Scene);
  77854. /**
  77855. * "GroundMesh"
  77856. * @returns "GroundMesh"
  77857. */
  77858. getClassName(): string;
  77859. /**
  77860. * The minimum of x and y subdivisions
  77861. */
  77862. readonly subdivisions: number;
  77863. /**
  77864. * X subdivisions
  77865. */
  77866. readonly subdivisionsX: number;
  77867. /**
  77868. * Y subdivisions
  77869. */
  77870. readonly subdivisionsY: number;
  77871. /**
  77872. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  77873. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  77874. * @param chunksCount the number of subdivisions for x and y
  77875. * @param octreeBlocksSize (Default: 32)
  77876. */
  77877. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  77878. /**
  77879. * Returns a height (y) value in the Worl system :
  77880. * the ground altitude at the coordinates (x, z) expressed in the World system.
  77881. * @param x x coordinate
  77882. * @param z z coordinate
  77883. * @returns the ground y position if (x, z) are outside the ground surface.
  77884. */
  77885. getHeightAtCoordinates(x: number, z: number): number;
  77886. /**
  77887. * Returns a normalized vector (Vector3) orthogonal to the ground
  77888. * at the ground coordinates (x, z) expressed in the World system.
  77889. * @param x x coordinate
  77890. * @param z z coordinate
  77891. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  77892. */
  77893. getNormalAtCoordinates(x: number, z: number): Vector3;
  77894. /**
  77895. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  77896. * at the ground coordinates (x, z) expressed in the World system.
  77897. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  77898. * @param x x coordinate
  77899. * @param z z coordinate
  77900. * @param ref vector to store the result
  77901. * @returns the GroundMesh.
  77902. */
  77903. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  77904. /**
  77905. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  77906. * if the ground has been updated.
  77907. * This can be used in the render loop.
  77908. * @returns the GroundMesh.
  77909. */
  77910. updateCoordinateHeights(): GroundMesh;
  77911. private _getFacetAt;
  77912. private _initHeightQuads;
  77913. private _computeHeightQuads;
  77914. /**
  77915. * Serializes this ground mesh
  77916. * @param serializationObject object to write serialization to
  77917. */
  77918. serialize(serializationObject: any): void;
  77919. /**
  77920. * Parses a serialized ground mesh
  77921. * @param parsedMesh the serialized mesh
  77922. * @param scene the scene to create the ground mesh in
  77923. * @returns the created ground mesh
  77924. */
  77925. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  77926. }
  77927. }
  77928. declare module BABYLON {
  77929. /**
  77930. * Interface for Physics-Joint data
  77931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77932. */
  77933. export interface PhysicsJointData {
  77934. /**
  77935. * The main pivot of the joint
  77936. */
  77937. mainPivot?: Vector3;
  77938. /**
  77939. * The connected pivot of the joint
  77940. */
  77941. connectedPivot?: Vector3;
  77942. /**
  77943. * The main axis of the joint
  77944. */
  77945. mainAxis?: Vector3;
  77946. /**
  77947. * The connected axis of the joint
  77948. */
  77949. connectedAxis?: Vector3;
  77950. /**
  77951. * The collision of the joint
  77952. */
  77953. collision?: boolean;
  77954. /**
  77955. * Native Oimo/Cannon/Energy data
  77956. */
  77957. nativeParams?: any;
  77958. }
  77959. /**
  77960. * This is a holder class for the physics joint created by the physics plugin
  77961. * It holds a set of functions to control the underlying joint
  77962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77963. */
  77964. export class PhysicsJoint {
  77965. /**
  77966. * The type of the physics joint
  77967. */
  77968. type: number;
  77969. /**
  77970. * The data for the physics joint
  77971. */
  77972. jointData: PhysicsJointData;
  77973. private _physicsJoint;
  77974. protected _physicsPlugin: IPhysicsEnginePlugin;
  77975. /**
  77976. * Initializes the physics joint
  77977. * @param type The type of the physics joint
  77978. * @param jointData The data for the physics joint
  77979. */
  77980. constructor(
  77981. /**
  77982. * The type of the physics joint
  77983. */
  77984. type: number,
  77985. /**
  77986. * The data for the physics joint
  77987. */
  77988. jointData: PhysicsJointData);
  77989. /**
  77990. * Gets the physics joint
  77991. */
  77992. /**
  77993. * Sets the physics joint
  77994. */
  77995. physicsJoint: any;
  77996. /**
  77997. * Sets the physics plugin
  77998. */
  77999. physicsPlugin: IPhysicsEnginePlugin;
  78000. /**
  78001. * Execute a function that is physics-plugin specific.
  78002. * @param {Function} func the function that will be executed.
  78003. * It accepts two parameters: the physics world and the physics joint
  78004. */
  78005. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78006. /**
  78007. * Distance-Joint type
  78008. */
  78009. static DistanceJoint: number;
  78010. /**
  78011. * Hinge-Joint type
  78012. */
  78013. static HingeJoint: number;
  78014. /**
  78015. * Ball-and-Socket joint type
  78016. */
  78017. static BallAndSocketJoint: number;
  78018. /**
  78019. * Wheel-Joint type
  78020. */
  78021. static WheelJoint: number;
  78022. /**
  78023. * Slider-Joint type
  78024. */
  78025. static SliderJoint: number;
  78026. /**
  78027. * Prismatic-Joint type
  78028. */
  78029. static PrismaticJoint: number;
  78030. /**
  78031. * Universal-Joint type
  78032. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78033. */
  78034. static UniversalJoint: number;
  78035. /**
  78036. * Hinge-Joint 2 type
  78037. */
  78038. static Hinge2Joint: number;
  78039. /**
  78040. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78041. */
  78042. static PointToPointJoint: number;
  78043. /**
  78044. * Spring-Joint type
  78045. */
  78046. static SpringJoint: number;
  78047. /**
  78048. * Lock-Joint type
  78049. */
  78050. static LockJoint: number;
  78051. }
  78052. /**
  78053. * A class representing a physics distance joint
  78054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78055. */
  78056. export class DistanceJoint extends PhysicsJoint {
  78057. /**
  78058. *
  78059. * @param jointData The data for the Distance-Joint
  78060. */
  78061. constructor(jointData: DistanceJointData);
  78062. /**
  78063. * Update the predefined distance.
  78064. * @param maxDistance The maximum preferred distance
  78065. * @param minDistance The minimum preferred distance
  78066. */
  78067. updateDistance(maxDistance: number, minDistance?: number): void;
  78068. }
  78069. /**
  78070. * Represents a Motor-Enabled Joint
  78071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78072. */
  78073. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78074. /**
  78075. * Initializes the Motor-Enabled Joint
  78076. * @param type The type of the joint
  78077. * @param jointData The physica joint data for the joint
  78078. */
  78079. constructor(type: number, jointData: PhysicsJointData);
  78080. /**
  78081. * Set the motor values.
  78082. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78083. * @param force the force to apply
  78084. * @param maxForce max force for this motor.
  78085. */
  78086. setMotor(force?: number, maxForce?: number): void;
  78087. /**
  78088. * Set the motor's limits.
  78089. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78090. * @param upperLimit The upper limit of the motor
  78091. * @param lowerLimit The lower limit of the motor
  78092. */
  78093. setLimit(upperLimit: number, lowerLimit?: number): void;
  78094. }
  78095. /**
  78096. * This class represents a single physics Hinge-Joint
  78097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78098. */
  78099. export class HingeJoint extends MotorEnabledJoint {
  78100. /**
  78101. * Initializes the Hinge-Joint
  78102. * @param jointData The joint data for the Hinge-Joint
  78103. */
  78104. constructor(jointData: PhysicsJointData);
  78105. /**
  78106. * Set the motor values.
  78107. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78108. * @param {number} force the force to apply
  78109. * @param {number} maxForce max force for this motor.
  78110. */
  78111. setMotor(force?: number, maxForce?: number): void;
  78112. /**
  78113. * Set the motor's limits.
  78114. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78115. * @param upperLimit The upper limit of the motor
  78116. * @param lowerLimit The lower limit of the motor
  78117. */
  78118. setLimit(upperLimit: number, lowerLimit?: number): void;
  78119. }
  78120. /**
  78121. * This class represents a dual hinge physics joint (same as wheel joint)
  78122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78123. */
  78124. export class Hinge2Joint extends MotorEnabledJoint {
  78125. /**
  78126. * Initializes the Hinge2-Joint
  78127. * @param jointData The joint data for the Hinge2-Joint
  78128. */
  78129. constructor(jointData: PhysicsJointData);
  78130. /**
  78131. * Set the motor values.
  78132. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78133. * @param {number} targetSpeed the speed the motor is to reach
  78134. * @param {number} maxForce max force for this motor.
  78135. * @param {motorIndex} the motor's index, 0 or 1.
  78136. */
  78137. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78138. /**
  78139. * Set the motor limits.
  78140. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78141. * @param {number} upperLimit the upper limit
  78142. * @param {number} lowerLimit lower limit
  78143. * @param {motorIndex} the motor's index, 0 or 1.
  78144. */
  78145. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78146. }
  78147. /**
  78148. * Interface for a motor enabled joint
  78149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78150. */
  78151. export interface IMotorEnabledJoint {
  78152. /**
  78153. * Physics joint
  78154. */
  78155. physicsJoint: any;
  78156. /**
  78157. * Sets the motor of the motor-enabled joint
  78158. * @param force The force of the motor
  78159. * @param maxForce The maximum force of the motor
  78160. * @param motorIndex The index of the motor
  78161. */
  78162. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78163. /**
  78164. * Sets the limit of the motor
  78165. * @param upperLimit The upper limit of the motor
  78166. * @param lowerLimit The lower limit of the motor
  78167. * @param motorIndex The index of the motor
  78168. */
  78169. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78170. }
  78171. /**
  78172. * Joint data for a Distance-Joint
  78173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78174. */
  78175. export interface DistanceJointData extends PhysicsJointData {
  78176. /**
  78177. * Max distance the 2 joint objects can be apart
  78178. */
  78179. maxDistance: number;
  78180. }
  78181. /**
  78182. * Joint data from a spring joint
  78183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78184. */
  78185. export interface SpringJointData extends PhysicsJointData {
  78186. /**
  78187. * Length of the spring
  78188. */
  78189. length: number;
  78190. /**
  78191. * Stiffness of the spring
  78192. */
  78193. stiffness: number;
  78194. /**
  78195. * Damping of the spring
  78196. */
  78197. damping: number;
  78198. /** this callback will be called when applying the force to the impostors. */
  78199. forceApplicationCallback: () => void;
  78200. }
  78201. }
  78202. declare module BABYLON {
  78203. /**
  78204. * Holds the data for the raycast result
  78205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78206. */
  78207. export class PhysicsRaycastResult {
  78208. private _hasHit;
  78209. private _hitDistance;
  78210. private _hitNormalWorld;
  78211. private _hitPointWorld;
  78212. private _rayFromWorld;
  78213. private _rayToWorld;
  78214. /**
  78215. * Gets if there was a hit
  78216. */
  78217. readonly hasHit: boolean;
  78218. /**
  78219. * Gets the distance from the hit
  78220. */
  78221. readonly hitDistance: number;
  78222. /**
  78223. * Gets the hit normal/direction in the world
  78224. */
  78225. readonly hitNormalWorld: Vector3;
  78226. /**
  78227. * Gets the hit point in the world
  78228. */
  78229. readonly hitPointWorld: Vector3;
  78230. /**
  78231. * Gets the ray "start point" of the ray in the world
  78232. */
  78233. readonly rayFromWorld: Vector3;
  78234. /**
  78235. * Gets the ray "end point" of the ray in the world
  78236. */
  78237. readonly rayToWorld: Vector3;
  78238. /**
  78239. * Sets the hit data (normal & point in world space)
  78240. * @param hitNormalWorld defines the normal in world space
  78241. * @param hitPointWorld defines the point in world space
  78242. */
  78243. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78244. /**
  78245. * Sets the distance from the start point to the hit point
  78246. * @param distance
  78247. */
  78248. setHitDistance(distance: number): void;
  78249. /**
  78250. * Calculates the distance manually
  78251. */
  78252. calculateHitDistance(): void;
  78253. /**
  78254. * Resets all the values to default
  78255. * @param from The from point on world space
  78256. * @param to The to point on world space
  78257. */
  78258. reset(from?: Vector3, to?: Vector3): void;
  78259. }
  78260. /**
  78261. * Interface for the size containing width and height
  78262. */
  78263. interface IXYZ {
  78264. /**
  78265. * X
  78266. */
  78267. x: number;
  78268. /**
  78269. * Y
  78270. */
  78271. y: number;
  78272. /**
  78273. * Z
  78274. */
  78275. z: number;
  78276. }
  78277. }
  78278. declare module BABYLON {
  78279. /**
  78280. * Interface used to describe a physics joint
  78281. */
  78282. export interface PhysicsImpostorJoint {
  78283. /** Defines the main impostor to which the joint is linked */
  78284. mainImpostor: PhysicsImpostor;
  78285. /** Defines the impostor that is connected to the main impostor using this joint */
  78286. connectedImpostor: PhysicsImpostor;
  78287. /** Defines the joint itself */
  78288. joint: PhysicsJoint;
  78289. }
  78290. /** @hidden */
  78291. export interface IPhysicsEnginePlugin {
  78292. world: any;
  78293. name: string;
  78294. setGravity(gravity: Vector3): void;
  78295. setTimeStep(timeStep: number): void;
  78296. getTimeStep(): number;
  78297. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  78298. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78299. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78300. generatePhysicsBody(impostor: PhysicsImpostor): void;
  78301. removePhysicsBody(impostor: PhysicsImpostor): void;
  78302. generateJoint(joint: PhysicsImpostorJoint): void;
  78303. removeJoint(joint: PhysicsImpostorJoint): void;
  78304. isSupported(): boolean;
  78305. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  78306. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  78307. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78308. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78309. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78310. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78311. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  78312. getBodyMass(impostor: PhysicsImpostor): number;
  78313. getBodyFriction(impostor: PhysicsImpostor): number;
  78314. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  78315. getBodyRestitution(impostor: PhysicsImpostor): number;
  78316. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  78317. getBodyPressure?(impostor: PhysicsImpostor): number;
  78318. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  78319. getBodyStiffness?(impostor: PhysicsImpostor): number;
  78320. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  78321. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  78322. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  78323. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  78324. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  78325. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78326. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78327. sleepBody(impostor: PhysicsImpostor): void;
  78328. wakeUpBody(impostor: PhysicsImpostor): void;
  78329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78330. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  78331. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  78332. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78333. getRadius(impostor: PhysicsImpostor): number;
  78334. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  78335. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  78336. dispose(): void;
  78337. }
  78338. /**
  78339. * Interface used to define a physics engine
  78340. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  78341. */
  78342. export interface IPhysicsEngine {
  78343. /**
  78344. * Gets the gravity vector used by the simulation
  78345. */
  78346. gravity: Vector3;
  78347. /**
  78348. * Sets the gravity vector used by the simulation
  78349. * @param gravity defines the gravity vector to use
  78350. */
  78351. setGravity(gravity: Vector3): void;
  78352. /**
  78353. * Set the time step of the physics engine.
  78354. * Default is 1/60.
  78355. * To slow it down, enter 1/600 for example.
  78356. * To speed it up, 1/30
  78357. * @param newTimeStep the new timestep to apply to this world.
  78358. */
  78359. setTimeStep(newTimeStep: number): void;
  78360. /**
  78361. * Get the time step of the physics engine.
  78362. * @returns the current time step
  78363. */
  78364. getTimeStep(): number;
  78365. /**
  78366. * Release all resources
  78367. */
  78368. dispose(): void;
  78369. /**
  78370. * Gets the name of the current physics plugin
  78371. * @returns the name of the plugin
  78372. */
  78373. getPhysicsPluginName(): string;
  78374. /**
  78375. * Adding a new impostor for the impostor tracking.
  78376. * This will be done by the impostor itself.
  78377. * @param impostor the impostor to add
  78378. */
  78379. addImpostor(impostor: PhysicsImpostor): void;
  78380. /**
  78381. * Remove an impostor from the engine.
  78382. * This impostor and its mesh will not longer be updated by the physics engine.
  78383. * @param impostor the impostor to remove
  78384. */
  78385. removeImpostor(impostor: PhysicsImpostor): void;
  78386. /**
  78387. * Add a joint to the physics engine
  78388. * @param mainImpostor defines the main impostor to which the joint is added.
  78389. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  78390. * @param joint defines the joint that will connect both impostors.
  78391. */
  78392. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78393. /**
  78394. * Removes a joint from the simulation
  78395. * @param mainImpostor defines the impostor used with the joint
  78396. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  78397. * @param joint defines the joint to remove
  78398. */
  78399. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78400. /**
  78401. * Gets the current plugin used to run the simulation
  78402. * @returns current plugin
  78403. */
  78404. getPhysicsPlugin(): IPhysicsEnginePlugin;
  78405. /**
  78406. * Gets the list of physic impostors
  78407. * @returns an array of PhysicsImpostor
  78408. */
  78409. getImpostors(): Array<PhysicsImpostor>;
  78410. /**
  78411. * Gets the impostor for a physics enabled object
  78412. * @param object defines the object impersonated by the impostor
  78413. * @returns the PhysicsImpostor or null if not found
  78414. */
  78415. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78416. /**
  78417. * Gets the impostor for a physics body object
  78418. * @param body defines physics body used by the impostor
  78419. * @returns the PhysicsImpostor or null if not found
  78420. */
  78421. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78422. /**
  78423. * Does a raycast in the physics world
  78424. * @param from when should the ray start?
  78425. * @param to when should the ray end?
  78426. * @returns PhysicsRaycastResult
  78427. */
  78428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78429. /**
  78430. * Called by the scene. No need to call it.
  78431. * @param delta defines the timespam between frames
  78432. */
  78433. _step(delta: number): void;
  78434. }
  78435. }
  78436. declare module BABYLON {
  78437. /**
  78438. * The interface for the physics imposter parameters
  78439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78440. */
  78441. export interface PhysicsImpostorParameters {
  78442. /**
  78443. * The mass of the physics imposter
  78444. */
  78445. mass: number;
  78446. /**
  78447. * The friction of the physics imposter
  78448. */
  78449. friction?: number;
  78450. /**
  78451. * The coefficient of restitution of the physics imposter
  78452. */
  78453. restitution?: number;
  78454. /**
  78455. * The native options of the physics imposter
  78456. */
  78457. nativeOptions?: any;
  78458. /**
  78459. * Specifies if the parent should be ignored
  78460. */
  78461. ignoreParent?: boolean;
  78462. /**
  78463. * Specifies if bi-directional transformations should be disabled
  78464. */
  78465. disableBidirectionalTransformation?: boolean;
  78466. /**
  78467. * The pressure inside the physics imposter, soft object only
  78468. */
  78469. pressure?: number;
  78470. /**
  78471. * The stiffness the physics imposter, soft object only
  78472. */
  78473. stiffness?: number;
  78474. /**
  78475. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78476. */
  78477. velocityIterations?: number;
  78478. /**
  78479. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78480. */
  78481. positionIterations?: number;
  78482. /**
  78483. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78484. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78485. * Add to fix multiple points
  78486. */
  78487. fixedPoints?: number;
  78488. /**
  78489. * The collision margin around a soft object
  78490. */
  78491. margin?: number;
  78492. /**
  78493. * The collision margin around a soft object
  78494. */
  78495. damping?: number;
  78496. /**
  78497. * The path for a rope based on an extrusion
  78498. */
  78499. path?: any;
  78500. /**
  78501. * The shape of an extrusion used for a rope based on an extrusion
  78502. */
  78503. shape?: any;
  78504. }
  78505. /**
  78506. * Interface for a physics-enabled object
  78507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78508. */
  78509. export interface IPhysicsEnabledObject {
  78510. /**
  78511. * The position of the physics-enabled object
  78512. */
  78513. position: Vector3;
  78514. /**
  78515. * The rotation of the physics-enabled object
  78516. */
  78517. rotationQuaternion: Nullable<Quaternion>;
  78518. /**
  78519. * The scale of the physics-enabled object
  78520. */
  78521. scaling: Vector3;
  78522. /**
  78523. * The rotation of the physics-enabled object
  78524. */
  78525. rotation?: Vector3;
  78526. /**
  78527. * The parent of the physics-enabled object
  78528. */
  78529. parent?: any;
  78530. /**
  78531. * The bounding info of the physics-enabled object
  78532. * @returns The bounding info of the physics-enabled object
  78533. */
  78534. getBoundingInfo(): BoundingInfo;
  78535. /**
  78536. * Computes the world matrix
  78537. * @param force Specifies if the world matrix should be computed by force
  78538. * @returns A world matrix
  78539. */
  78540. computeWorldMatrix(force: boolean): Matrix;
  78541. /**
  78542. * Gets the world matrix
  78543. * @returns A world matrix
  78544. */
  78545. getWorldMatrix?(): Matrix;
  78546. /**
  78547. * Gets the child meshes
  78548. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78549. * @returns An array of abstract meshes
  78550. */
  78551. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78552. /**
  78553. * Gets the vertex data
  78554. * @param kind The type of vertex data
  78555. * @returns A nullable array of numbers, or a float32 array
  78556. */
  78557. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78558. /**
  78559. * Gets the indices from the mesh
  78560. * @returns A nullable array of index arrays
  78561. */
  78562. getIndices?(): Nullable<IndicesArray>;
  78563. /**
  78564. * Gets the scene from the mesh
  78565. * @returns the indices array or null
  78566. */
  78567. getScene?(): Scene;
  78568. /**
  78569. * Gets the absolute position from the mesh
  78570. * @returns the absolute position
  78571. */
  78572. getAbsolutePosition(): Vector3;
  78573. /**
  78574. * Gets the absolute pivot point from the mesh
  78575. * @returns the absolute pivot point
  78576. */
  78577. getAbsolutePivotPoint(): Vector3;
  78578. /**
  78579. * Rotates the mesh
  78580. * @param axis The axis of rotation
  78581. * @param amount The amount of rotation
  78582. * @param space The space of the rotation
  78583. * @returns The rotation transform node
  78584. */
  78585. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78586. /**
  78587. * Translates the mesh
  78588. * @param axis The axis of translation
  78589. * @param distance The distance of translation
  78590. * @param space The space of the translation
  78591. * @returns The transform node
  78592. */
  78593. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78594. /**
  78595. * Sets the absolute position of the mesh
  78596. * @param absolutePosition The absolute position of the mesh
  78597. * @returns The transform node
  78598. */
  78599. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78600. /**
  78601. * Gets the class name of the mesh
  78602. * @returns The class name
  78603. */
  78604. getClassName(): string;
  78605. }
  78606. /**
  78607. * Represents a physics imposter
  78608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78609. */
  78610. export class PhysicsImpostor {
  78611. /**
  78612. * The physics-enabled object used as the physics imposter
  78613. */
  78614. object: IPhysicsEnabledObject;
  78615. /**
  78616. * The type of the physics imposter
  78617. */
  78618. type: number;
  78619. private _options;
  78620. private _scene?;
  78621. /**
  78622. * The default object size of the imposter
  78623. */
  78624. static DEFAULT_OBJECT_SIZE: Vector3;
  78625. /**
  78626. * The identity quaternion of the imposter
  78627. */
  78628. static IDENTITY_QUATERNION: Quaternion;
  78629. /** @hidden */
  78630. _pluginData: any;
  78631. private _physicsEngine;
  78632. private _physicsBody;
  78633. private _bodyUpdateRequired;
  78634. private _onBeforePhysicsStepCallbacks;
  78635. private _onAfterPhysicsStepCallbacks;
  78636. /** @hidden */
  78637. _onPhysicsCollideCallbacks: Array<{
  78638. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  78639. otherImpostors: Array<PhysicsImpostor>;
  78640. }>;
  78641. private _deltaPosition;
  78642. private _deltaRotation;
  78643. private _deltaRotationConjugated;
  78644. /** hidden */
  78645. _isFromLine: boolean;
  78646. private _parent;
  78647. private _isDisposed;
  78648. private static _tmpVecs;
  78649. private static _tmpQuat;
  78650. /**
  78651. * Specifies if the physics imposter is disposed
  78652. */
  78653. readonly isDisposed: boolean;
  78654. /**
  78655. * Gets the mass of the physics imposter
  78656. */
  78657. mass: number;
  78658. /**
  78659. * Gets the coefficient of friction
  78660. */
  78661. /**
  78662. * Sets the coefficient of friction
  78663. */
  78664. friction: number;
  78665. /**
  78666. * Gets the coefficient of restitution
  78667. */
  78668. /**
  78669. * Sets the coefficient of restitution
  78670. */
  78671. restitution: number;
  78672. /**
  78673. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  78674. */
  78675. /**
  78676. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  78677. */
  78678. pressure: number;
  78679. /**
  78680. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78681. */
  78682. /**
  78683. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78684. */
  78685. stiffness: number;
  78686. /**
  78687. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78688. */
  78689. /**
  78690. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78691. */
  78692. velocityIterations: number;
  78693. /**
  78694. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78695. */
  78696. /**
  78697. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78698. */
  78699. positionIterations: number;
  78700. /**
  78701. * The unique id of the physics imposter
  78702. * set by the physics engine when adding this impostor to the array
  78703. */
  78704. uniqueId: number;
  78705. /**
  78706. * @hidden
  78707. */
  78708. soft: boolean;
  78709. /**
  78710. * @hidden
  78711. */
  78712. segments: number;
  78713. private _joints;
  78714. /**
  78715. * Initializes the physics imposter
  78716. * @param object The physics-enabled object used as the physics imposter
  78717. * @param type The type of the physics imposter
  78718. * @param _options The options for the physics imposter
  78719. * @param _scene The Babylon scene
  78720. */
  78721. constructor(
  78722. /**
  78723. * The physics-enabled object used as the physics imposter
  78724. */
  78725. object: IPhysicsEnabledObject,
  78726. /**
  78727. * The type of the physics imposter
  78728. */
  78729. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  78730. /**
  78731. * This function will completly initialize this impostor.
  78732. * It will create a new body - but only if this mesh has no parent.
  78733. * If it has, this impostor will not be used other than to define the impostor
  78734. * of the child mesh.
  78735. * @hidden
  78736. */
  78737. _init(): void;
  78738. private _getPhysicsParent;
  78739. /**
  78740. * Should a new body be generated.
  78741. * @returns boolean specifying if body initialization is required
  78742. */
  78743. isBodyInitRequired(): boolean;
  78744. /**
  78745. * Sets the updated scaling
  78746. * @param updated Specifies if the scaling is updated
  78747. */
  78748. setScalingUpdated(): void;
  78749. /**
  78750. * Force a regeneration of this or the parent's impostor's body.
  78751. * Use under cautious - This will remove all joints already implemented.
  78752. */
  78753. forceUpdate(): void;
  78754. /**
  78755. * Gets the body that holds this impostor. Either its own, or its parent.
  78756. */
  78757. /**
  78758. * Set the physics body. Used mainly by the physics engine/plugin
  78759. */
  78760. physicsBody: any;
  78761. /**
  78762. * Get the parent of the physics imposter
  78763. * @returns Physics imposter or null
  78764. */
  78765. /**
  78766. * Sets the parent of the physics imposter
  78767. */
  78768. parent: Nullable<PhysicsImpostor>;
  78769. /**
  78770. * Resets the update flags
  78771. */
  78772. resetUpdateFlags(): void;
  78773. /**
  78774. * Gets the object extend size
  78775. * @returns the object extend size
  78776. */
  78777. getObjectExtendSize(): Vector3;
  78778. /**
  78779. * Gets the object center
  78780. * @returns The object center
  78781. */
  78782. getObjectCenter(): Vector3;
  78783. /**
  78784. * Get a specific parametes from the options parameter
  78785. * @param paramName The object parameter name
  78786. * @returns The object parameter
  78787. */
  78788. getParam(paramName: string): any;
  78789. /**
  78790. * Sets a specific parameter in the options given to the physics plugin
  78791. * @param paramName The parameter name
  78792. * @param value The value of the parameter
  78793. */
  78794. setParam(paramName: string, value: number): void;
  78795. /**
  78796. * Specifically change the body's mass option. Won't recreate the physics body object
  78797. * @param mass The mass of the physics imposter
  78798. */
  78799. setMass(mass: number): void;
  78800. /**
  78801. * Gets the linear velocity
  78802. * @returns linear velocity or null
  78803. */
  78804. getLinearVelocity(): Nullable<Vector3>;
  78805. /**
  78806. * Sets the linear velocity
  78807. * @param velocity linear velocity or null
  78808. */
  78809. setLinearVelocity(velocity: Nullable<Vector3>): void;
  78810. /**
  78811. * Gets the angular velocity
  78812. * @returns angular velocity or null
  78813. */
  78814. getAngularVelocity(): Nullable<Vector3>;
  78815. /**
  78816. * Sets the angular velocity
  78817. * @param velocity The velocity or null
  78818. */
  78819. setAngularVelocity(velocity: Nullable<Vector3>): void;
  78820. /**
  78821. * Execute a function with the physics plugin native code
  78822. * Provide a function the will have two variables - the world object and the physics body object
  78823. * @param func The function to execute with the physics plugin native code
  78824. */
  78825. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  78826. /**
  78827. * Register a function that will be executed before the physics world is stepping forward
  78828. * @param func The function to execute before the physics world is stepped forward
  78829. */
  78830. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78831. /**
  78832. * Unregister a function that will be executed before the physics world is stepping forward
  78833. * @param func The function to execute before the physics world is stepped forward
  78834. */
  78835. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78836. /**
  78837. * Register a function that will be executed after the physics step
  78838. * @param func The function to execute after physics step
  78839. */
  78840. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78841. /**
  78842. * Unregisters a function that will be executed after the physics step
  78843. * @param func The function to execute after physics step
  78844. */
  78845. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78846. /**
  78847. * register a function that will be executed when this impostor collides against a different body
  78848. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  78849. * @param func Callback that is executed on collision
  78850. */
  78851. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  78852. /**
  78853. * Unregisters the physics imposter on contact
  78854. * @param collideAgainst The physics object to collide against
  78855. * @param func Callback to execute on collision
  78856. */
  78857. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  78858. private _tmpQuat;
  78859. private _tmpQuat2;
  78860. /**
  78861. * Get the parent rotation
  78862. * @returns The parent rotation
  78863. */
  78864. getParentsRotation(): Quaternion;
  78865. /**
  78866. * this function is executed by the physics engine.
  78867. */
  78868. beforeStep: () => void;
  78869. /**
  78870. * this function is executed by the physics engine
  78871. */
  78872. afterStep: () => void;
  78873. /**
  78874. * Legacy collision detection event support
  78875. */
  78876. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  78877. /**
  78878. * event and body object due to cannon's event-based architecture.
  78879. */
  78880. onCollide: (e: {
  78881. body: any;
  78882. }) => void;
  78883. /**
  78884. * Apply a force
  78885. * @param force The force to apply
  78886. * @param contactPoint The contact point for the force
  78887. * @returns The physics imposter
  78888. */
  78889. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78890. /**
  78891. * Apply an impulse
  78892. * @param force The impulse force
  78893. * @param contactPoint The contact point for the impulse force
  78894. * @returns The physics imposter
  78895. */
  78896. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78897. /**
  78898. * A help function to create a joint
  78899. * @param otherImpostor A physics imposter used to create a joint
  78900. * @param jointType The type of joint
  78901. * @param jointData The data for the joint
  78902. * @returns The physics imposter
  78903. */
  78904. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  78905. /**
  78906. * Add a joint to this impostor with a different impostor
  78907. * @param otherImpostor A physics imposter used to add a joint
  78908. * @param joint The joint to add
  78909. * @returns The physics imposter
  78910. */
  78911. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  78912. /**
  78913. * Add an anchor to a cloth impostor
  78914. * @param otherImpostor rigid impostor to anchor to
  78915. * @param width ratio across width from 0 to 1
  78916. * @param height ratio up height from 0 to 1
  78917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  78918. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  78919. * @returns impostor the soft imposter
  78920. */
  78921. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78922. /**
  78923. * Add a hook to a rope impostor
  78924. * @param otherImpostor rigid impostor to anchor to
  78925. * @param length ratio across rope from 0 to 1
  78926. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  78927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  78928. * @returns impostor the rope imposter
  78929. */
  78930. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78931. /**
  78932. * Will keep this body still, in a sleep mode.
  78933. * @returns the physics imposter
  78934. */
  78935. sleep(): PhysicsImpostor;
  78936. /**
  78937. * Wake the body up.
  78938. * @returns The physics imposter
  78939. */
  78940. wakeUp(): PhysicsImpostor;
  78941. /**
  78942. * Clones the physics imposter
  78943. * @param newObject The physics imposter clones to this physics-enabled object
  78944. * @returns A nullable physics imposter
  78945. */
  78946. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78947. /**
  78948. * Disposes the physics imposter
  78949. */
  78950. dispose(): void;
  78951. /**
  78952. * Sets the delta position
  78953. * @param position The delta position amount
  78954. */
  78955. setDeltaPosition(position: Vector3): void;
  78956. /**
  78957. * Sets the delta rotation
  78958. * @param rotation The delta rotation amount
  78959. */
  78960. setDeltaRotation(rotation: Quaternion): void;
  78961. /**
  78962. * Gets the box size of the physics imposter and stores the result in the input parameter
  78963. * @param result Stores the box size
  78964. * @returns The physics imposter
  78965. */
  78966. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  78967. /**
  78968. * Gets the radius of the physics imposter
  78969. * @returns Radius of the physics imposter
  78970. */
  78971. getRadius(): number;
  78972. /**
  78973. * Sync a bone with this impostor
  78974. * @param bone The bone to sync to the impostor.
  78975. * @param boneMesh The mesh that the bone is influencing.
  78976. * @param jointPivot The pivot of the joint / bone in local space.
  78977. * @param distToJoint Optional distance from the impostor to the joint.
  78978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78979. */
  78980. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  78981. /**
  78982. * Sync impostor to a bone
  78983. * @param bone The bone that the impostor will be synced to.
  78984. * @param boneMesh The mesh that the bone is influencing.
  78985. * @param jointPivot The pivot of the joint / bone in local space.
  78986. * @param distToJoint Optional distance from the impostor to the joint.
  78987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78988. * @param boneAxis Optional vector3 axis the bone is aligned with
  78989. */
  78990. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  78991. /**
  78992. * No-Imposter type
  78993. */
  78994. static NoImpostor: number;
  78995. /**
  78996. * Sphere-Imposter type
  78997. */
  78998. static SphereImpostor: number;
  78999. /**
  79000. * Box-Imposter type
  79001. */
  79002. static BoxImpostor: number;
  79003. /**
  79004. * Plane-Imposter type
  79005. */
  79006. static PlaneImpostor: number;
  79007. /**
  79008. * Mesh-imposter type
  79009. */
  79010. static MeshImpostor: number;
  79011. /**
  79012. * Cylinder-Imposter type
  79013. */
  79014. static CylinderImpostor: number;
  79015. /**
  79016. * Particle-Imposter type
  79017. */
  79018. static ParticleImpostor: number;
  79019. /**
  79020. * Heightmap-Imposter type
  79021. */
  79022. static HeightmapImpostor: number;
  79023. /**
  79024. * ConvexHull-Impostor type (Ammo.js plugin only)
  79025. */
  79026. static ConvexHullImpostor: number;
  79027. /**
  79028. * Rope-Imposter type
  79029. */
  79030. static RopeImpostor: number;
  79031. /**
  79032. * Cloth-Imposter type
  79033. */
  79034. static ClothImpostor: number;
  79035. /**
  79036. * Softbody-Imposter type
  79037. */
  79038. static SoftbodyImpostor: number;
  79039. }
  79040. }
  79041. declare module BABYLON {
  79042. /**
  79043. * Class used to represent a specific level of detail of a mesh
  79044. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79045. */
  79046. export class MeshLODLevel {
  79047. /** Defines the distance where this level should star being displayed */
  79048. distance: number;
  79049. /** Defines the mesh to use to render this level */
  79050. mesh: Nullable<Mesh>;
  79051. /**
  79052. * Creates a new LOD level
  79053. * @param distance defines the distance where this level should star being displayed
  79054. * @param mesh defines the mesh to use to render this level
  79055. */
  79056. constructor(
  79057. /** Defines the distance where this level should star being displayed */
  79058. distance: number,
  79059. /** Defines the mesh to use to render this level */
  79060. mesh: Nullable<Mesh>);
  79061. }
  79062. /**
  79063. * @hidden
  79064. **/
  79065. export class _CreationDataStorage {
  79066. closePath?: boolean;
  79067. closeArray?: boolean;
  79068. idx: number[];
  79069. dashSize: number;
  79070. gapSize: number;
  79071. path3D: Path3D;
  79072. pathArray: Vector3[][];
  79073. arc: number;
  79074. radius: number;
  79075. cap: number;
  79076. tessellation: number;
  79077. }
  79078. /**
  79079. * @hidden
  79080. **/
  79081. class _InstanceDataStorage {
  79082. visibleInstances: any;
  79083. renderIdForInstances: number[];
  79084. batchCache: _InstancesBatch;
  79085. instancesBufferSize: number;
  79086. instancesBuffer: Nullable<Buffer>;
  79087. instancesData: Float32Array;
  79088. overridenInstanceCount: number;
  79089. }
  79090. /**
  79091. * @hidden
  79092. **/
  79093. export class _InstancesBatch {
  79094. mustReturn: boolean;
  79095. visibleInstances: Nullable<InstancedMesh[]>[];
  79096. renderSelf: boolean[];
  79097. }
  79098. /**
  79099. * Class used to represent renderable models
  79100. */
  79101. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79102. /**
  79103. * Mesh side orientation : usually the external or front surface
  79104. */
  79105. static readonly FRONTSIDE: number;
  79106. /**
  79107. * Mesh side orientation : usually the internal or back surface
  79108. */
  79109. static readonly BACKSIDE: number;
  79110. /**
  79111. * Mesh side orientation : both internal and external or front and back surfaces
  79112. */
  79113. static readonly DOUBLESIDE: number;
  79114. /**
  79115. * Mesh side orientation : by default, `FRONTSIDE`
  79116. */
  79117. static readonly DEFAULTSIDE: number;
  79118. /**
  79119. * Mesh cap setting : no cap
  79120. */
  79121. static readonly NO_CAP: number;
  79122. /**
  79123. * Mesh cap setting : one cap at the beginning of the mesh
  79124. */
  79125. static readonly CAP_START: number;
  79126. /**
  79127. * Mesh cap setting : one cap at the end of the mesh
  79128. */
  79129. static readonly CAP_END: number;
  79130. /**
  79131. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79132. */
  79133. static readonly CAP_ALL: number;
  79134. /**
  79135. * Gets the default side orientation.
  79136. * @param orientation the orientation to value to attempt to get
  79137. * @returns the default orientation
  79138. * @hidden
  79139. */
  79140. static _GetDefaultSideOrientation(orientation?: number): number;
  79141. private _onBeforeRenderObservable;
  79142. private _onBeforeBindObservable;
  79143. private _onAfterRenderObservable;
  79144. private _onBeforeDrawObservable;
  79145. /**
  79146. * An event triggered before rendering the mesh
  79147. */
  79148. readonly onBeforeRenderObservable: Observable<Mesh>;
  79149. /**
  79150. * An event triggered before binding the mesh
  79151. */
  79152. readonly onBeforeBindObservable: Observable<Mesh>;
  79153. /**
  79154. * An event triggered after rendering the mesh
  79155. */
  79156. readonly onAfterRenderObservable: Observable<Mesh>;
  79157. /**
  79158. * An event triggered before drawing the mesh
  79159. */
  79160. readonly onBeforeDrawObservable: Observable<Mesh>;
  79161. private _onBeforeDrawObserver;
  79162. /**
  79163. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79164. */
  79165. onBeforeDraw: () => void;
  79166. /**
  79167. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79168. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79169. */
  79170. delayLoadState: number;
  79171. /**
  79172. * Gets the list of instances created from this mesh
  79173. * it is not supposed to be modified manually.
  79174. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79175. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79176. */
  79177. instances: InstancedMesh[];
  79178. /**
  79179. * Gets the file containing delay loading data for this mesh
  79180. */
  79181. delayLoadingFile: string;
  79182. /** @hidden */
  79183. _binaryInfo: any;
  79184. private _LODLevels;
  79185. /**
  79186. * User defined function used to change how LOD level selection is done
  79187. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79188. */
  79189. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79190. private _morphTargetManager;
  79191. /**
  79192. * Gets or sets the morph target manager
  79193. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79194. */
  79195. morphTargetManager: Nullable<MorphTargetManager>;
  79196. /** @hidden */
  79197. _creationDataStorage: Nullable<_CreationDataStorage>;
  79198. /** @hidden */
  79199. _geometry: Nullable<Geometry>;
  79200. /** @hidden */
  79201. _delayInfo: Array<string>;
  79202. /** @hidden */
  79203. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79204. /** @hidden */
  79205. _instanceDataStorage: _InstanceDataStorage;
  79206. private _effectiveMaterial;
  79207. /** @hidden */
  79208. _shouldGenerateFlatShading: boolean;
  79209. private _preActivateId;
  79210. /** @hidden */
  79211. _originalBuilderSideOrientation: number;
  79212. /**
  79213. * Use this property to change the original side orientation defined at construction time
  79214. */
  79215. overrideMaterialSideOrientation: Nullable<number>;
  79216. private _areNormalsFrozen;
  79217. private _sourcePositions;
  79218. private _sourceNormals;
  79219. private _source;
  79220. private meshMap;
  79221. /**
  79222. * Gets the source mesh (the one used to clone this one from)
  79223. */
  79224. readonly source: Nullable<Mesh>;
  79225. /**
  79226. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79227. */
  79228. isUnIndexed: boolean;
  79229. /**
  79230. * @constructor
  79231. * @param name The value used by scene.getMeshByName() to do a lookup.
  79232. * @param scene The scene to add this mesh to.
  79233. * @param parent The parent of this mesh, if it has one
  79234. * @param source An optional Mesh from which geometry is shared, cloned.
  79235. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79236. * When false, achieved by calling a clone(), also passing False.
  79237. * This will make creation of children, recursive.
  79238. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79239. */
  79240. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79241. /**
  79242. * Gets the class name
  79243. * @returns the string "Mesh".
  79244. */
  79245. getClassName(): string;
  79246. /** @hidden */
  79247. readonly _isMesh: boolean;
  79248. /**
  79249. * Returns a description of this mesh
  79250. * @param fullDetails define if full details about this mesh must be used
  79251. * @returns a descriptive string representing this mesh
  79252. */
  79253. toString(fullDetails?: boolean): string;
  79254. /** @hidden */
  79255. _unBindEffect(): void;
  79256. /**
  79257. * Gets a boolean indicating if this mesh has LOD
  79258. */
  79259. readonly hasLODLevels: boolean;
  79260. /**
  79261. * Gets the list of MeshLODLevel associated with the current mesh
  79262. * @returns an array of MeshLODLevel
  79263. */
  79264. getLODLevels(): MeshLODLevel[];
  79265. private _sortLODLevels;
  79266. /**
  79267. * Add a mesh as LOD level triggered at the given distance.
  79268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79269. * @param distance The distance from the center of the object to show this level
  79270. * @param mesh The mesh to be added as LOD level (can be null)
  79271. * @return This mesh (for chaining)
  79272. */
  79273. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  79274. /**
  79275. * Returns the LOD level mesh at the passed distance or null if not found.
  79276. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79277. * @param distance The distance from the center of the object to show this level
  79278. * @returns a Mesh or `null`
  79279. */
  79280. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  79281. /**
  79282. * Remove a mesh from the LOD array
  79283. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79284. * @param mesh defines the mesh to be removed
  79285. * @return This mesh (for chaining)
  79286. */
  79287. removeLODLevel(mesh: Mesh): Mesh;
  79288. /**
  79289. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  79290. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79291. * @param camera defines the camera to use to compute distance
  79292. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  79293. * @return This mesh (for chaining)
  79294. */
  79295. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  79296. /**
  79297. * Gets the mesh internal Geometry object
  79298. */
  79299. readonly geometry: Nullable<Geometry>;
  79300. /**
  79301. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  79302. * @returns the total number of vertices
  79303. */
  79304. getTotalVertices(): number;
  79305. /**
  79306. * Returns the content of an associated vertex buffer
  79307. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79308. * - VertexBuffer.PositionKind
  79309. * - VertexBuffer.UVKind
  79310. * - VertexBuffer.UV2Kind
  79311. * - VertexBuffer.UV3Kind
  79312. * - VertexBuffer.UV4Kind
  79313. * - VertexBuffer.UV5Kind
  79314. * - VertexBuffer.UV6Kind
  79315. * - VertexBuffer.ColorKind
  79316. * - VertexBuffer.MatricesIndicesKind
  79317. * - VertexBuffer.MatricesIndicesExtraKind
  79318. * - VertexBuffer.MatricesWeightsKind
  79319. * - VertexBuffer.MatricesWeightsExtraKind
  79320. * @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
  79321. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  79322. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  79323. */
  79324. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79325. /**
  79326. * Returns the mesh VertexBuffer object from the requested `kind`
  79327. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79328. * - VertexBuffer.PositionKind
  79329. * - VertexBuffer.UVKind
  79330. * - VertexBuffer.UV2Kind
  79331. * - VertexBuffer.UV3Kind
  79332. * - VertexBuffer.UV4Kind
  79333. * - VertexBuffer.UV5Kind
  79334. * - VertexBuffer.UV6Kind
  79335. * - VertexBuffer.ColorKind
  79336. * - VertexBuffer.MatricesIndicesKind
  79337. * - VertexBuffer.MatricesIndicesExtraKind
  79338. * - VertexBuffer.MatricesWeightsKind
  79339. * - VertexBuffer.MatricesWeightsExtraKind
  79340. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  79341. */
  79342. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79343. /**
  79344. * Tests if a specific vertex buffer is associated with this mesh
  79345. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79346. * - VertexBuffer.PositionKind
  79347. * - VertexBuffer.UVKind
  79348. * - VertexBuffer.UV2Kind
  79349. * - VertexBuffer.UV3Kind
  79350. * - VertexBuffer.UV4Kind
  79351. * - VertexBuffer.UV5Kind
  79352. * - VertexBuffer.UV6Kind
  79353. * - VertexBuffer.ColorKind
  79354. * - VertexBuffer.MatricesIndicesKind
  79355. * - VertexBuffer.MatricesIndicesExtraKind
  79356. * - VertexBuffer.MatricesWeightsKind
  79357. * - VertexBuffer.MatricesWeightsExtraKind
  79358. * @returns a boolean
  79359. */
  79360. isVerticesDataPresent(kind: string): boolean;
  79361. /**
  79362. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  79363. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79364. * - VertexBuffer.PositionKind
  79365. * - VertexBuffer.UVKind
  79366. * - VertexBuffer.UV2Kind
  79367. * - VertexBuffer.UV3Kind
  79368. * - VertexBuffer.UV4Kind
  79369. * - VertexBuffer.UV5Kind
  79370. * - VertexBuffer.UV6Kind
  79371. * - VertexBuffer.ColorKind
  79372. * - VertexBuffer.MatricesIndicesKind
  79373. * - VertexBuffer.MatricesIndicesExtraKind
  79374. * - VertexBuffer.MatricesWeightsKind
  79375. * - VertexBuffer.MatricesWeightsExtraKind
  79376. * @returns a boolean
  79377. */
  79378. isVertexBufferUpdatable(kind: string): boolean;
  79379. /**
  79380. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  79381. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79382. * - VertexBuffer.PositionKind
  79383. * - VertexBuffer.UVKind
  79384. * - VertexBuffer.UV2Kind
  79385. * - VertexBuffer.UV3Kind
  79386. * - VertexBuffer.UV4Kind
  79387. * - VertexBuffer.UV5Kind
  79388. * - VertexBuffer.UV6Kind
  79389. * - VertexBuffer.ColorKind
  79390. * - VertexBuffer.MatricesIndicesKind
  79391. * - VertexBuffer.MatricesIndicesExtraKind
  79392. * - VertexBuffer.MatricesWeightsKind
  79393. * - VertexBuffer.MatricesWeightsExtraKind
  79394. * @returns an array of strings
  79395. */
  79396. getVerticesDataKinds(): string[];
  79397. /**
  79398. * Returns a positive integer : the total number of indices in this mesh geometry.
  79399. * @returns the numner of indices or zero if the mesh has no geometry.
  79400. */
  79401. getTotalIndices(): number;
  79402. /**
  79403. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79404. * @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.
  79405. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79406. * @returns the indices array or an empty array if the mesh has no geometry
  79407. */
  79408. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79409. readonly isBlocked: boolean;
  79410. /**
  79411. * Determine if the current mesh is ready to be rendered
  79412. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79413. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  79414. * @returns true if all associated assets are ready (material, textures, shaders)
  79415. */
  79416. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  79417. /**
  79418. * 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.
  79419. */
  79420. readonly areNormalsFrozen: boolean;
  79421. /**
  79422. * 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.
  79423. * @returns the current mesh
  79424. */
  79425. freezeNormals(): Mesh;
  79426. /**
  79427. * 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
  79428. * @returns the current mesh
  79429. */
  79430. unfreezeNormals(): Mesh;
  79431. /**
  79432. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  79433. */
  79434. overridenInstanceCount: number;
  79435. /** @hidden */
  79436. _preActivate(): Mesh;
  79437. /** @hidden */
  79438. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79439. /** @hidden */
  79440. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79441. /**
  79442. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79443. * This means the mesh underlying bounding box and sphere are recomputed.
  79444. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79445. * @returns the current mesh
  79446. */
  79447. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79448. /** @hidden */
  79449. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79450. /**
  79451. * This function will subdivide the mesh into multiple submeshes
  79452. * @param count defines the expected number of submeshes
  79453. */
  79454. subdivide(count: number): void;
  79455. /**
  79456. * Copy a FloatArray into a specific associated vertex buffer
  79457. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79458. * - VertexBuffer.PositionKind
  79459. * - VertexBuffer.UVKind
  79460. * - VertexBuffer.UV2Kind
  79461. * - VertexBuffer.UV3Kind
  79462. * - VertexBuffer.UV4Kind
  79463. * - VertexBuffer.UV5Kind
  79464. * - VertexBuffer.UV6Kind
  79465. * - VertexBuffer.ColorKind
  79466. * - VertexBuffer.MatricesIndicesKind
  79467. * - VertexBuffer.MatricesIndicesExtraKind
  79468. * - VertexBuffer.MatricesWeightsKind
  79469. * - VertexBuffer.MatricesWeightsExtraKind
  79470. * @param data defines the data source
  79471. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79472. * @param stride defines the data stride size (can be null)
  79473. * @returns the current mesh
  79474. */
  79475. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79476. /**
  79477. * Flags an associated vertex buffer as updatable
  79478. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79479. * - VertexBuffer.PositionKind
  79480. * - VertexBuffer.UVKind
  79481. * - VertexBuffer.UV2Kind
  79482. * - VertexBuffer.UV3Kind
  79483. * - VertexBuffer.UV4Kind
  79484. * - VertexBuffer.UV5Kind
  79485. * - VertexBuffer.UV6Kind
  79486. * - VertexBuffer.ColorKind
  79487. * - VertexBuffer.MatricesIndicesKind
  79488. * - VertexBuffer.MatricesIndicesExtraKind
  79489. * - VertexBuffer.MatricesWeightsKind
  79490. * - VertexBuffer.MatricesWeightsExtraKind
  79491. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79492. */
  79493. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79494. /**
  79495. * Sets the mesh global Vertex Buffer
  79496. * @param buffer defines the buffer to use
  79497. * @returns the current mesh
  79498. */
  79499. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79500. /**
  79501. * Update a specific associated vertex buffer
  79502. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79503. * - VertexBuffer.PositionKind
  79504. * - VertexBuffer.UVKind
  79505. * - VertexBuffer.UV2Kind
  79506. * - VertexBuffer.UV3Kind
  79507. * - VertexBuffer.UV4Kind
  79508. * - VertexBuffer.UV5Kind
  79509. * - VertexBuffer.UV6Kind
  79510. * - VertexBuffer.ColorKind
  79511. * - VertexBuffer.MatricesIndicesKind
  79512. * - VertexBuffer.MatricesIndicesExtraKind
  79513. * - VertexBuffer.MatricesWeightsKind
  79514. * - VertexBuffer.MatricesWeightsExtraKind
  79515. * @param data defines the data source
  79516. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79517. * @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)
  79518. * @returns the current mesh
  79519. */
  79520. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79521. /**
  79522. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79523. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79524. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79525. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79526. * @returns the current mesh
  79527. */
  79528. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79529. /**
  79530. * Creates a un-shared specific occurence of the geometry for the mesh.
  79531. * @returns the current mesh
  79532. */
  79533. makeGeometryUnique(): Mesh;
  79534. /**
  79535. * Set the index buffer of this mesh
  79536. * @param indices defines the source data
  79537. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79538. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79539. * @returns the current mesh
  79540. */
  79541. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79542. /**
  79543. * Update the current index buffer
  79544. * @param indices defines the source data
  79545. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79546. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  79547. * @returns the current mesh
  79548. */
  79549. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79550. /**
  79551. * Invert the geometry to move from a right handed system to a left handed one.
  79552. * @returns the current mesh
  79553. */
  79554. toLeftHanded(): Mesh;
  79555. /** @hidden */
  79556. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79557. /** @hidden */
  79558. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  79559. /**
  79560. * Registers for this mesh a javascript function called just before the rendering process
  79561. * @param func defines the function to call before rendering this mesh
  79562. * @returns the current mesh
  79563. */
  79564. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79565. /**
  79566. * Disposes a previously registered javascript function called before the rendering
  79567. * @param func defines the function to remove
  79568. * @returns the current mesh
  79569. */
  79570. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79571. /**
  79572. * Registers for this mesh a javascript function called just after the rendering is complete
  79573. * @param func defines the function to call after rendering this mesh
  79574. * @returns the current mesh
  79575. */
  79576. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79577. /**
  79578. * Disposes a previously registered javascript function called after the rendering.
  79579. * @param func defines the function to remove
  79580. * @returns the current mesh
  79581. */
  79582. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79583. /** @hidden */
  79584. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  79585. /** @hidden */
  79586. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  79587. /** @hidden */
  79588. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  79589. /**
  79590. * 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
  79591. * @param subMesh defines the subMesh to render
  79592. * @param enableAlphaMode defines if alpha mode can be changed
  79593. * @returns the current mesh
  79594. */
  79595. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  79596. private _onBeforeDraw;
  79597. /**
  79598. * Renormalize the mesh and patch it up if there are no weights
  79599. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  79600. * However in the case of zero weights then we set just a single influence to 1.
  79601. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  79602. */
  79603. cleanMatrixWeights(): void;
  79604. private normalizeSkinFourWeights;
  79605. private normalizeSkinWeightsAndExtra;
  79606. /**
  79607. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  79608. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  79609. * the user know there was an issue with importing the mesh
  79610. * @returns a validation object with skinned, valid and report string
  79611. */
  79612. validateSkinning(): {
  79613. skinned: boolean;
  79614. valid: boolean;
  79615. report: string;
  79616. };
  79617. /** @hidden */
  79618. _checkDelayState(): Mesh;
  79619. private _queueLoad;
  79620. /**
  79621. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79622. * A mesh is in the frustum if its bounding box intersects the frustum
  79623. * @param frustumPlanes defines the frustum to test
  79624. * @returns true if the mesh is in the frustum planes
  79625. */
  79626. isInFrustum(frustumPlanes: Plane[]): boolean;
  79627. /**
  79628. * Sets the mesh material by the material or multiMaterial `id` property
  79629. * @param id is a string identifying the material or the multiMaterial
  79630. * @returns the current mesh
  79631. */
  79632. setMaterialByID(id: string): Mesh;
  79633. /**
  79634. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  79635. * @returns an array of IAnimatable
  79636. */
  79637. getAnimatables(): IAnimatable[];
  79638. /**
  79639. * Modifies the mesh geometry according to the passed transformation matrix.
  79640. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  79641. * The mesh normals are modified using the same transformation.
  79642. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79643. * @param transform defines the transform matrix to use
  79644. * @see http://doc.babylonjs.com/resources/baking_transformations
  79645. * @returns the current mesh
  79646. */
  79647. bakeTransformIntoVertices(transform: Matrix): Mesh;
  79648. /**
  79649. * Modifies the mesh geometry according to its own current World Matrix.
  79650. * The mesh World Matrix is then reset.
  79651. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  79652. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79653. * @see http://doc.babylonjs.com/resources/baking_transformations
  79654. * @returns the current mesh
  79655. */
  79656. bakeCurrentTransformIntoVertices(): Mesh;
  79657. /** @hidden */
  79658. readonly _positions: Nullable<Vector3[]>;
  79659. /** @hidden */
  79660. _resetPointsArrayCache(): Mesh;
  79661. /** @hidden */
  79662. _generatePointsArray(): boolean;
  79663. /**
  79664. * Returns a new Mesh object generated from the current mesh properties.
  79665. * This method must not get confused with createInstance()
  79666. * @param name is a string, the name given to the new mesh
  79667. * @param newParent can be any Node object (default `null`)
  79668. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  79669. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  79670. * @returns a new mesh
  79671. */
  79672. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  79673. /**
  79674. * Releases resources associated with this mesh.
  79675. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79676. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79677. */
  79678. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79679. /**
  79680. * Modifies the mesh geometry according to a displacement map.
  79681. * 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.
  79682. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79683. * @param url is a string, the URL from the image file is to be downloaded.
  79684. * @param minHeight is the lower limit of the displacement.
  79685. * @param maxHeight is the upper limit of the displacement.
  79686. * @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.
  79687. * @param uvOffset is an optional vector2 used to offset UV.
  79688. * @param uvScale is an optional vector2 used to scale UV.
  79689. * @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.
  79690. * @returns the Mesh.
  79691. */
  79692. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79693. /**
  79694. * Modifies the mesh geometry according to a displacementMap buffer.
  79695. * 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.
  79696. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79697. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  79698. * @param heightMapWidth is the width of the buffer image.
  79699. * @param heightMapHeight is the height of the buffer image.
  79700. * @param minHeight is the lower limit of the displacement.
  79701. * @param maxHeight is the upper limit of the displacement.
  79702. * @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.
  79703. * @param uvOffset is an optional vector2 used to offset UV.
  79704. * @param uvScale is an optional vector2 used to scale UV.
  79705. * @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.
  79706. * @returns the Mesh.
  79707. */
  79708. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79709. /**
  79710. * Modify the mesh to get a flat shading rendering.
  79711. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  79712. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  79713. * @returns current mesh
  79714. */
  79715. convertToFlatShadedMesh(): Mesh;
  79716. /**
  79717. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  79718. * In other words, more vertices, no more indices and a single bigger VBO.
  79719. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  79720. * @returns current mesh
  79721. */
  79722. convertToUnIndexedMesh(): Mesh;
  79723. /**
  79724. * Inverses facet orientations.
  79725. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79726. * @param flipNormals will also inverts the normals
  79727. * @returns current mesh
  79728. */
  79729. flipFaces(flipNormals?: boolean): Mesh;
  79730. /**
  79731. * Increase the number of facets and hence vertices in a mesh
  79732. * Vertex normals are interpolated from existing vertex normals
  79733. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79734. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  79735. */
  79736. increaseVertices(numberPerEdge: number): void;
  79737. /**
  79738. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  79739. * This will undo any application of covertToFlatShadedMesh
  79740. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79741. */
  79742. forceSharedVertices(): void;
  79743. /** @hidden */
  79744. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  79745. /** @hidden */
  79746. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  79747. /**
  79748. * Creates a new InstancedMesh object from the mesh model.
  79749. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79750. * @param name defines the name of the new instance
  79751. * @returns a new InstancedMesh
  79752. */
  79753. createInstance(name: string): InstancedMesh;
  79754. /**
  79755. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  79756. * After this call, all the mesh instances have the same submeshes than the current mesh.
  79757. * @returns the current mesh
  79758. */
  79759. synchronizeInstances(): Mesh;
  79760. /**
  79761. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  79762. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  79763. * This should be used together with the simplification to avoid disappearing triangles.
  79764. * @param successCallback an optional success callback to be called after the optimization finished.
  79765. * @returns the current mesh
  79766. */
  79767. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  79768. /**
  79769. * Serialize current mesh
  79770. * @param serializationObject defines the object which will receive the serialization data
  79771. */
  79772. serialize(serializationObject: any): void;
  79773. /** @hidden */
  79774. _syncGeometryWithMorphTargetManager(): void;
  79775. /** @hidden */
  79776. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  79777. /**
  79778. * Returns a new Mesh object parsed from the source provided.
  79779. * @param parsedMesh is the source
  79780. * @param scene defines the hosting scene
  79781. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  79782. * @returns a new Mesh
  79783. */
  79784. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  79785. /**
  79786. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  79787. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79788. * @param name defines the name of the mesh to create
  79789. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  79790. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  79791. * @param closePath creates a seam between the first and the last points of each path of the path array
  79792. * @param offset is taken in account only if the `pathArray` is containing a single path
  79793. * @param scene defines the hosting scene
  79794. * @param updatable defines if the mesh must be flagged as updatable
  79795. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79796. * @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)
  79797. * @returns a new Mesh
  79798. */
  79799. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79800. /**
  79801. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  79802. * @param name defines the name of the mesh to create
  79803. * @param radius sets the radius size (float) of the polygon (default 0.5)
  79804. * @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
  79805. * @param scene defines the hosting scene
  79806. * @param updatable defines if the mesh must be flagged as updatable
  79807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79808. * @returns a new Mesh
  79809. */
  79810. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79811. /**
  79812. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  79813. * @param name defines the name of the mesh to create
  79814. * @param size sets the size (float) of each box side (default 1)
  79815. * @param scene defines the hosting scene
  79816. * @param updatable defines if the mesh must be flagged as updatable
  79817. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79818. * @returns a new Mesh
  79819. */
  79820. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79821. /**
  79822. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  79823. * @param name defines the name of the mesh to create
  79824. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  79825. * @param diameter sets the diameter size (float) of the sphere (default 1)
  79826. * @param scene defines the hosting scene
  79827. * @param updatable defines if the mesh must be flagged as updatable
  79828. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79829. * @returns a new Mesh
  79830. */
  79831. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79832. /**
  79833. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  79834. * @param name defines the name of the mesh to create
  79835. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  79836. * @param diameterTop set the top cap diameter (floats, default 1)
  79837. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  79838. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  79839. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  79840. * @param scene defines the hosting scene
  79841. * @param updatable defines if the mesh must be flagged as updatable
  79842. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79843. * @returns a new Mesh
  79844. */
  79845. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  79846. /**
  79847. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  79848. * @param name defines the name of the mesh to create
  79849. * @param diameter sets the diameter size (float) of the torus (default 1)
  79850. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  79851. * @param tessellation sets the number of torus sides (postive integer, default 16)
  79852. * @param scene defines the hosting scene
  79853. * @param updatable defines if the mesh must be flagged as updatable
  79854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79855. * @returns a new Mesh
  79856. */
  79857. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79858. /**
  79859. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  79860. * @param name defines the name of the mesh to create
  79861. * @param radius sets the global radius size (float) of the torus knot (default 2)
  79862. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  79863. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  79864. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  79865. * @param p the number of windings on X axis (positive integers, default 2)
  79866. * @param q the number of windings on Y axis (positive integers, default 3)
  79867. * @param scene defines the hosting scene
  79868. * @param updatable defines if the mesh must be flagged as updatable
  79869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79870. * @returns a new Mesh
  79871. */
  79872. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79873. /**
  79874. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  79875. * @param name defines the name of the mesh to create
  79876. * @param points is an array successive Vector3
  79877. * @param scene defines the hosting scene
  79878. * @param updatable defines if the mesh must be flagged as updatable
  79879. * @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).
  79880. * @returns a new Mesh
  79881. */
  79882. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  79883. /**
  79884. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  79885. * @param name defines the name of the mesh to create
  79886. * @param points is an array successive Vector3
  79887. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  79888. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79889. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  79890. * @param scene defines the hosting scene
  79891. * @param updatable defines if the mesh must be flagged as updatable
  79892. * @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)
  79893. * @returns a new Mesh
  79894. */
  79895. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  79896. /**
  79897. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  79898. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  79899. * 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.
  79900. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79901. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79902. * Remember you can only change the shape positions, not their number when updating a polygon.
  79903. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  79904. * @param name defines the name of the mesh to create
  79905. * @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
  79906. * @param scene defines the hosting scene
  79907. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79908. * @param updatable defines if the mesh must be flagged as updatable
  79909. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79910. * @param earcutInjection can be used to inject your own earcut reference
  79911. * @returns a new Mesh
  79912. */
  79913. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79914. /**
  79915. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  79916. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  79917. * @param name defines the name of the mesh to create
  79918. * @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
  79919. * @param depth defines the height of extrusion
  79920. * @param scene defines the hosting scene
  79921. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79922. * @param updatable defines if the mesh must be flagged as updatable
  79923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79924. * @param earcutInjection can be used to inject your own earcut reference
  79925. * @returns a new Mesh
  79926. */
  79927. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79928. /**
  79929. * Creates an extruded shape mesh.
  79930. * 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
  79931. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79932. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79933. * @param name defines the name of the mesh to create
  79934. * @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
  79935. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79936. * @param scale is the value to scale the shape
  79937. * @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
  79938. * @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
  79939. * @param scene defines the hosting scene
  79940. * @param updatable defines if the mesh must be flagged as updatable
  79941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79942. * @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)
  79943. * @returns a new Mesh
  79944. */
  79945. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79946. /**
  79947. * Creates an custom extruded shape mesh.
  79948. * The custom extrusion is a parametric shape.
  79949. * It has no predefined shape. Its final shape will depend on the input parameters.
  79950. * Please consider using the same method from the MeshBuilder class instead
  79951. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79952. * @param name defines the name of the mesh to create
  79953. * @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
  79954. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79955. * @param scaleFunction is a custom Javascript function called on each path point
  79956. * @param rotationFunction is a custom Javascript function called on each path point
  79957. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79958. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  79959. * @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
  79960. * @param scene defines the hosting scene
  79961. * @param updatable defines if the mesh must be flagged as updatable
  79962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79963. * @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)
  79964. * @returns a new Mesh
  79965. */
  79966. 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;
  79967. /**
  79968. * Creates lathe mesh.
  79969. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  79970. * Please consider using the same method from the MeshBuilder class instead
  79971. * @param name defines the name of the mesh to create
  79972. * @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
  79973. * @param radius is the radius value of the lathe
  79974. * @param tessellation is the side number of the lathe.
  79975. * @param scene defines the hosting scene
  79976. * @param updatable defines if the mesh must be flagged as updatable
  79977. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79978. * @returns a new Mesh
  79979. */
  79980. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79981. /**
  79982. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  79983. * @param name defines the name of the mesh to create
  79984. * @param size sets the size (float) of both sides of the plane at once (default 1)
  79985. * @param scene defines the hosting scene
  79986. * @param updatable defines if the mesh must be flagged as updatable
  79987. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79988. * @returns a new Mesh
  79989. */
  79990. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79991. /**
  79992. * Creates a ground mesh.
  79993. * Please consider using the same method from the MeshBuilder class instead
  79994. * @param name defines the name of the mesh to create
  79995. * @param width set the width of the ground
  79996. * @param height set the height of the ground
  79997. * @param subdivisions sets the number of subdivisions per side
  79998. * @param scene defines the hosting scene
  79999. * @param updatable defines if the mesh must be flagged as updatable
  80000. * @returns a new Mesh
  80001. */
  80002. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80003. /**
  80004. * Creates a tiled ground mesh.
  80005. * Please consider using the same method from the MeshBuilder class instead
  80006. * @param name defines the name of the mesh to create
  80007. * @param xmin set the ground minimum X coordinate
  80008. * @param zmin set the ground minimum Y coordinate
  80009. * @param xmax set the ground maximum X coordinate
  80010. * @param zmax set the ground maximum Z coordinate
  80011. * @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
  80012. * @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
  80013. * @param scene defines the hosting scene
  80014. * @param updatable defines if the mesh must be flagged as updatable
  80015. * @returns a new Mesh
  80016. */
  80017. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80018. w: number;
  80019. h: number;
  80020. }, precision: {
  80021. w: number;
  80022. h: number;
  80023. }, scene: Scene, updatable?: boolean): Mesh;
  80024. /**
  80025. * Creates a ground mesh from a height map.
  80026. * Please consider using the same method from the MeshBuilder class instead
  80027. * @see http://doc.babylonjs.com/babylon101/height_map
  80028. * @param name defines the name of the mesh to create
  80029. * @param url sets the URL of the height map image resource
  80030. * @param width set the ground width size
  80031. * @param height set the ground height size
  80032. * @param subdivisions sets the number of subdivision per side
  80033. * @param minHeight is the minimum altitude on the ground
  80034. * @param maxHeight is the maximum altitude on the ground
  80035. * @param scene defines the hosting scene
  80036. * @param updatable defines if the mesh must be flagged as updatable
  80037. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80038. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80039. * @returns a new Mesh
  80040. */
  80041. 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;
  80042. /**
  80043. * Creates a tube mesh.
  80044. * The tube is a parametric shape.
  80045. * It has no predefined shape. Its final shape will depend on the input parameters.
  80046. * Please consider using the same method from the MeshBuilder class instead
  80047. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80048. * @param name defines the name of the mesh to create
  80049. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80050. * @param radius sets the tube radius size
  80051. * @param tessellation is the number of sides on the tubular surface
  80052. * @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
  80053. * @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
  80054. * @param scene defines the hosting scene
  80055. * @param updatable defines if the mesh must be flagged as updatable
  80056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80057. * @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)
  80058. * @returns a new Mesh
  80059. */
  80060. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80061. (i: number, distance: number): number;
  80062. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80063. /**
  80064. * Creates a polyhedron mesh.
  80065. * Please consider using the same method from the MeshBuilder class instead.
  80066. * * 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
  80067. * * The parameter `size` (positive float, default 1) sets the polygon size
  80068. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80069. * * 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`
  80070. * * 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
  80071. * * 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)`)
  80072. * * 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
  80073. * * 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
  80074. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80075. * * If you create a double-sided mesh, you can choose what parts of 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
  80076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80077. * @param name defines the name of the mesh to create
  80078. * @param options defines the options used to create the mesh
  80079. * @param scene defines the hosting scene
  80080. * @returns a new Mesh
  80081. */
  80082. static CreatePolyhedron(name: string, options: {
  80083. type?: number;
  80084. size?: number;
  80085. sizeX?: number;
  80086. sizeY?: number;
  80087. sizeZ?: number;
  80088. custom?: any;
  80089. faceUV?: Vector4[];
  80090. faceColors?: Color4[];
  80091. updatable?: boolean;
  80092. sideOrientation?: number;
  80093. }, scene: Scene): Mesh;
  80094. /**
  80095. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80096. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80097. * * 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`)
  80098. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80099. * * 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
  80100. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80101. * * If you create a double-sided mesh, you can choose what parts of 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
  80102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80103. * @param name defines the name of the mesh
  80104. * @param options defines the options used to create the mesh
  80105. * @param scene defines the hosting scene
  80106. * @returns a new Mesh
  80107. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80108. */
  80109. static CreateIcoSphere(name: string, options: {
  80110. radius?: number;
  80111. flat?: boolean;
  80112. subdivisions?: number;
  80113. sideOrientation?: number;
  80114. updatable?: boolean;
  80115. }, scene: Scene): Mesh;
  80116. /**
  80117. * Creates a decal mesh.
  80118. * Please consider using the same method from the MeshBuilder class instead.
  80119. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80120. * @param name defines the name of the mesh
  80121. * @param sourceMesh defines the mesh receiving the decal
  80122. * @param position sets the position of the decal in world coordinates
  80123. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80124. * @param size sets the decal scaling
  80125. * @param angle sets the angle to rotate the decal
  80126. * @returns a new Mesh
  80127. */
  80128. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80129. /**
  80130. * Prepare internal position array for software CPU skinning
  80131. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80132. */
  80133. setPositionsForCPUSkinning(): Float32Array;
  80134. /**
  80135. * Prepare internal normal array for software CPU skinning
  80136. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80137. */
  80138. setNormalsForCPUSkinning(): Float32Array;
  80139. /**
  80140. * Updates the vertex buffer by applying transformation from the bones
  80141. * @param skeleton defines the skeleton to apply to current mesh
  80142. * @returns the current mesh
  80143. */
  80144. applySkeleton(skeleton: Skeleton): Mesh;
  80145. /**
  80146. * 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
  80147. * @param meshes defines the list of meshes to scan
  80148. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80149. */
  80150. static MinMax(meshes: AbstractMesh[]): {
  80151. min: Vector3;
  80152. max: Vector3;
  80153. };
  80154. /**
  80155. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80156. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80157. * @returns a vector3
  80158. */
  80159. static Center(meshesOrMinMaxVector: {
  80160. min: Vector3;
  80161. max: Vector3;
  80162. } | AbstractMesh[]): Vector3;
  80163. /**
  80164. * Merge the array of meshes into a single mesh for performance reasons.
  80165. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80166. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80167. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80168. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80169. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80170. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80171. * @returns a new mesh
  80172. */
  80173. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80174. /** @hidden */
  80175. addInstance(instance: InstancedMesh): void;
  80176. /** @hidden */
  80177. removeInstance(instance: InstancedMesh): void;
  80178. }
  80179. }
  80180. declare module BABYLON {
  80181. /**
  80182. * Base class for the main features of a material in Babylon.js
  80183. */
  80184. export class Material implements IAnimatable {
  80185. /**
  80186. * Returns the triangle fill mode
  80187. */
  80188. static readonly TriangleFillMode: number;
  80189. /**
  80190. * Returns the wireframe mode
  80191. */
  80192. static readonly WireFrameFillMode: number;
  80193. /**
  80194. * Returns the point fill mode
  80195. */
  80196. static readonly PointFillMode: number;
  80197. /**
  80198. * Returns the point list draw mode
  80199. */
  80200. static readonly PointListDrawMode: number;
  80201. /**
  80202. * Returns the line list draw mode
  80203. */
  80204. static readonly LineListDrawMode: number;
  80205. /**
  80206. * Returns the line loop draw mode
  80207. */
  80208. static readonly LineLoopDrawMode: number;
  80209. /**
  80210. * Returns the line strip draw mode
  80211. */
  80212. static readonly LineStripDrawMode: number;
  80213. /**
  80214. * Returns the triangle strip draw mode
  80215. */
  80216. static readonly TriangleStripDrawMode: number;
  80217. /**
  80218. * Returns the triangle fan draw mode
  80219. */
  80220. static readonly TriangleFanDrawMode: number;
  80221. /**
  80222. * Stores the clock-wise side orientation
  80223. */
  80224. static readonly ClockWiseSideOrientation: number;
  80225. /**
  80226. * Stores the counter clock-wise side orientation
  80227. */
  80228. static readonly CounterClockWiseSideOrientation: number;
  80229. /**
  80230. * The dirty texture flag value
  80231. */
  80232. static readonly TextureDirtyFlag: number;
  80233. /**
  80234. * The dirty light flag value
  80235. */
  80236. static readonly LightDirtyFlag: number;
  80237. /**
  80238. * The dirty fresnel flag value
  80239. */
  80240. static readonly FresnelDirtyFlag: number;
  80241. /**
  80242. * The dirty attribute flag value
  80243. */
  80244. static readonly AttributesDirtyFlag: number;
  80245. /**
  80246. * The dirty misc flag value
  80247. */
  80248. static readonly MiscDirtyFlag: number;
  80249. /**
  80250. * The all dirty flag value
  80251. */
  80252. static readonly AllDirtyFlag: number;
  80253. /**
  80254. * The ID of the material
  80255. */
  80256. id: string;
  80257. /**
  80258. * Gets or sets the unique id of the material
  80259. */
  80260. uniqueId: number;
  80261. /**
  80262. * The name of the material
  80263. */
  80264. name: string;
  80265. /**
  80266. * Gets or sets user defined metadata
  80267. */
  80268. metadata: any;
  80269. /**
  80270. * For internal use only. Please do not use.
  80271. */
  80272. reservedDataStore: any;
  80273. /**
  80274. * Specifies if the ready state should be checked on each call
  80275. */
  80276. checkReadyOnEveryCall: boolean;
  80277. /**
  80278. * Specifies if the ready state should be checked once
  80279. */
  80280. checkReadyOnlyOnce: boolean;
  80281. /**
  80282. * The state of the material
  80283. */
  80284. state: string;
  80285. /**
  80286. * The alpha value of the material
  80287. */
  80288. protected _alpha: number;
  80289. /**
  80290. * List of inspectable custom properties (used by the Inspector)
  80291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80292. */
  80293. inspectableCustomProperties: IInspectable[];
  80294. /**
  80295. * Sets the alpha value of the material
  80296. */
  80297. /**
  80298. * Gets the alpha value of the material
  80299. */
  80300. alpha: number;
  80301. /**
  80302. * Specifies if back face culling is enabled
  80303. */
  80304. protected _backFaceCulling: boolean;
  80305. /**
  80306. * Sets the back-face culling state
  80307. */
  80308. /**
  80309. * Gets the back-face culling state
  80310. */
  80311. backFaceCulling: boolean;
  80312. /**
  80313. * Stores the value for side orientation
  80314. */
  80315. sideOrientation: number;
  80316. /**
  80317. * Callback triggered when the material is compiled
  80318. */
  80319. onCompiled: (effect: Effect) => void;
  80320. /**
  80321. * Callback triggered when an error occurs
  80322. */
  80323. onError: (effect: Effect, errors: string) => void;
  80324. /**
  80325. * Callback triggered to get the render target textures
  80326. */
  80327. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  80328. /**
  80329. * Gets a boolean indicating that current material needs to register RTT
  80330. */
  80331. readonly hasRenderTargetTextures: boolean;
  80332. /**
  80333. * Specifies if the material should be serialized
  80334. */
  80335. doNotSerialize: boolean;
  80336. /**
  80337. * @hidden
  80338. */
  80339. _storeEffectOnSubMeshes: boolean;
  80340. /**
  80341. * Stores the animations for the material
  80342. */
  80343. animations: Array<Animation>;
  80344. /**
  80345. * An event triggered when the material is disposed
  80346. */
  80347. onDisposeObservable: Observable<Material>;
  80348. /**
  80349. * An observer which watches for dispose events
  80350. */
  80351. private _onDisposeObserver;
  80352. private _onUnBindObservable;
  80353. /**
  80354. * Called during a dispose event
  80355. */
  80356. onDispose: () => void;
  80357. private _onBindObservable;
  80358. /**
  80359. * An event triggered when the material is bound
  80360. */
  80361. readonly onBindObservable: Observable<AbstractMesh>;
  80362. /**
  80363. * An observer which watches for bind events
  80364. */
  80365. private _onBindObserver;
  80366. /**
  80367. * Called during a bind event
  80368. */
  80369. onBind: (Mesh: AbstractMesh) => void;
  80370. /**
  80371. * An event triggered when the material is unbound
  80372. */
  80373. readonly onUnBindObservable: Observable<Material>;
  80374. /**
  80375. * Stores the value of the alpha mode
  80376. */
  80377. private _alphaMode;
  80378. /**
  80379. * Sets the value of the alpha mode.
  80380. *
  80381. * | Value | Type | Description |
  80382. * | --- | --- | --- |
  80383. * | 0 | ALPHA_DISABLE | |
  80384. * | 1 | ALPHA_ADD | |
  80385. * | 2 | ALPHA_COMBINE | |
  80386. * | 3 | ALPHA_SUBTRACT | |
  80387. * | 4 | ALPHA_MULTIPLY | |
  80388. * | 5 | ALPHA_MAXIMIZED | |
  80389. * | 6 | ALPHA_ONEONE | |
  80390. * | 7 | ALPHA_PREMULTIPLIED | |
  80391. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  80392. * | 9 | ALPHA_INTERPOLATE | |
  80393. * | 10 | ALPHA_SCREENMODE | |
  80394. *
  80395. */
  80396. /**
  80397. * Gets the value of the alpha mode
  80398. */
  80399. alphaMode: number;
  80400. /**
  80401. * Stores the state of the need depth pre-pass value
  80402. */
  80403. private _needDepthPrePass;
  80404. /**
  80405. * Sets the need depth pre-pass value
  80406. */
  80407. /**
  80408. * Gets the depth pre-pass value
  80409. */
  80410. needDepthPrePass: boolean;
  80411. /**
  80412. * Specifies if depth writing should be disabled
  80413. */
  80414. disableDepthWrite: boolean;
  80415. /**
  80416. * Specifies if depth writing should be forced
  80417. */
  80418. forceDepthWrite: boolean;
  80419. /**
  80420. * Specifies if there should be a separate pass for culling
  80421. */
  80422. separateCullingPass: boolean;
  80423. /**
  80424. * Stores the state specifing if fog should be enabled
  80425. */
  80426. private _fogEnabled;
  80427. /**
  80428. * Sets the state for enabling fog
  80429. */
  80430. /**
  80431. * Gets the value of the fog enabled state
  80432. */
  80433. fogEnabled: boolean;
  80434. /**
  80435. * Stores the size of points
  80436. */
  80437. pointSize: number;
  80438. /**
  80439. * Stores the z offset value
  80440. */
  80441. zOffset: number;
  80442. /**
  80443. * Gets a value specifying if wireframe mode is enabled
  80444. */
  80445. /**
  80446. * Sets the state of wireframe mode
  80447. */
  80448. wireframe: boolean;
  80449. /**
  80450. * Gets the value specifying if point clouds are enabled
  80451. */
  80452. /**
  80453. * Sets the state of point cloud mode
  80454. */
  80455. pointsCloud: boolean;
  80456. /**
  80457. * Gets the material fill mode
  80458. */
  80459. /**
  80460. * Sets the material fill mode
  80461. */
  80462. fillMode: number;
  80463. /**
  80464. * @hidden
  80465. * Stores the effects for the material
  80466. */
  80467. _effect: Nullable<Effect>;
  80468. /**
  80469. * @hidden
  80470. * Specifies if the material was previously ready
  80471. */
  80472. _wasPreviouslyReady: boolean;
  80473. /**
  80474. * Specifies if uniform buffers should be used
  80475. */
  80476. private _useUBO;
  80477. /**
  80478. * Stores a reference to the scene
  80479. */
  80480. private _scene;
  80481. /**
  80482. * Stores the fill mode state
  80483. */
  80484. private _fillMode;
  80485. /**
  80486. * Specifies if the depth write state should be cached
  80487. */
  80488. private _cachedDepthWriteState;
  80489. /**
  80490. * Stores the uniform buffer
  80491. */
  80492. protected _uniformBuffer: UniformBuffer;
  80493. /** @hidden */
  80494. _indexInSceneMaterialArray: number;
  80495. /** @hidden */
  80496. meshMap: Nullable<{
  80497. [id: string]: AbstractMesh | undefined;
  80498. }>;
  80499. /**
  80500. * Creates a material instance
  80501. * @param name defines the name of the material
  80502. * @param scene defines the scene to reference
  80503. * @param doNotAdd specifies if the material should be added to the scene
  80504. */
  80505. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80506. /**
  80507. * Returns a string representation of the current material
  80508. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80509. * @returns a string with material information
  80510. */
  80511. toString(fullDetails?: boolean): string;
  80512. /**
  80513. * Gets the class name of the material
  80514. * @returns a string with the class name of the material
  80515. */
  80516. getClassName(): string;
  80517. /**
  80518. * Specifies if updates for the material been locked
  80519. */
  80520. readonly isFrozen: boolean;
  80521. /**
  80522. * Locks updates for the material
  80523. */
  80524. freeze(): void;
  80525. /**
  80526. * Unlocks updates for the material
  80527. */
  80528. unfreeze(): void;
  80529. /**
  80530. * Specifies if the material is ready to be used
  80531. * @param mesh defines the mesh to check
  80532. * @param useInstances specifies if instances should be used
  80533. * @returns a boolean indicating if the material is ready to be used
  80534. */
  80535. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80536. /**
  80537. * Specifies that the submesh is ready to be used
  80538. * @param mesh defines the mesh to check
  80539. * @param subMesh defines which submesh to check
  80540. * @param useInstances specifies that instances should be used
  80541. * @returns a boolean indicating that the submesh is ready or not
  80542. */
  80543. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80544. /**
  80545. * Returns the material effect
  80546. * @returns the effect associated with the material
  80547. */
  80548. getEffect(): Nullable<Effect>;
  80549. /**
  80550. * Returns the current scene
  80551. * @returns a Scene
  80552. */
  80553. getScene(): Scene;
  80554. /**
  80555. * Specifies if the material will require alpha blending
  80556. * @returns a boolean specifying if alpha blending is needed
  80557. */
  80558. needAlphaBlending(): boolean;
  80559. /**
  80560. * Specifies if the mesh will require alpha blending
  80561. * @param mesh defines the mesh to check
  80562. * @returns a boolean specifying if alpha blending is needed for the mesh
  80563. */
  80564. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80565. /**
  80566. * Specifies if this material should be rendered in alpha test mode
  80567. * @returns a boolean specifying if an alpha test is needed.
  80568. */
  80569. needAlphaTesting(): boolean;
  80570. /**
  80571. * Gets the texture used for the alpha test
  80572. * @returns the texture to use for alpha testing
  80573. */
  80574. getAlphaTestTexture(): Nullable<BaseTexture>;
  80575. /**
  80576. * Marks the material to indicate that it needs to be re-calculated
  80577. */
  80578. markDirty(): void;
  80579. /** @hidden */
  80580. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  80581. /**
  80582. * Binds the material to the mesh
  80583. * @param world defines the world transformation matrix
  80584. * @param mesh defines the mesh to bind the material to
  80585. */
  80586. bind(world: Matrix, mesh?: Mesh): void;
  80587. /**
  80588. * Binds the submesh to the material
  80589. * @param world defines the world transformation matrix
  80590. * @param mesh defines the mesh containing the submesh
  80591. * @param subMesh defines the submesh to bind the material to
  80592. */
  80593. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  80594. /**
  80595. * Binds the world matrix to the material
  80596. * @param world defines the world transformation matrix
  80597. */
  80598. bindOnlyWorldMatrix(world: Matrix): void;
  80599. /**
  80600. * Binds the scene's uniform buffer to the effect.
  80601. * @param effect defines the effect to bind to the scene uniform buffer
  80602. * @param sceneUbo defines the uniform buffer storing scene data
  80603. */
  80604. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  80605. /**
  80606. * Binds the view matrix to the effect
  80607. * @param effect defines the effect to bind the view matrix to
  80608. */
  80609. bindView(effect: Effect): void;
  80610. /**
  80611. * Binds the view projection matrix to the effect
  80612. * @param effect defines the effect to bind the view projection matrix to
  80613. */
  80614. bindViewProjection(effect: Effect): void;
  80615. /**
  80616. * Specifies if material alpha testing should be turned on for the mesh
  80617. * @param mesh defines the mesh to check
  80618. */
  80619. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  80620. /**
  80621. * Processes to execute after binding the material to a mesh
  80622. * @param mesh defines the rendered mesh
  80623. */
  80624. protected _afterBind(mesh?: Mesh): void;
  80625. /**
  80626. * Unbinds the material from the mesh
  80627. */
  80628. unbind(): void;
  80629. /**
  80630. * Gets the active textures from the material
  80631. * @returns an array of textures
  80632. */
  80633. getActiveTextures(): BaseTexture[];
  80634. /**
  80635. * Specifies if the material uses a texture
  80636. * @param texture defines the texture to check against the material
  80637. * @returns a boolean specifying if the material uses the texture
  80638. */
  80639. hasTexture(texture: BaseTexture): boolean;
  80640. /**
  80641. * Makes a duplicate of the material, and gives it a new name
  80642. * @param name defines the new name for the duplicated material
  80643. * @returns the cloned material
  80644. */
  80645. clone(name: string): Nullable<Material>;
  80646. /**
  80647. * Gets the meshes bound to the material
  80648. * @returns an array of meshes bound to the material
  80649. */
  80650. getBindedMeshes(): AbstractMesh[];
  80651. /**
  80652. * Force shader compilation
  80653. * @param mesh defines the mesh associated with this material
  80654. * @param onCompiled defines a function to execute once the material is compiled
  80655. * @param options defines the options to configure the compilation
  80656. */
  80657. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  80658. clipPlane: boolean;
  80659. }>): void;
  80660. /**
  80661. * Force shader compilation
  80662. * @param mesh defines the mesh that will use this material
  80663. * @param options defines additional options for compiling the shaders
  80664. * @returns a promise that resolves when the compilation completes
  80665. */
  80666. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  80667. clipPlane: boolean;
  80668. }>): Promise<void>;
  80669. private static readonly _ImageProcessingDirtyCallBack;
  80670. private static readonly _TextureDirtyCallBack;
  80671. private static readonly _FresnelDirtyCallBack;
  80672. private static readonly _MiscDirtyCallBack;
  80673. private static readonly _LightsDirtyCallBack;
  80674. private static readonly _AttributeDirtyCallBack;
  80675. private static _FresnelAndMiscDirtyCallBack;
  80676. private static _TextureAndMiscDirtyCallBack;
  80677. private static readonly _DirtyCallbackArray;
  80678. private static readonly _RunDirtyCallBacks;
  80679. /**
  80680. * Marks a define in the material to indicate that it needs to be re-computed
  80681. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  80682. */
  80683. markAsDirty(flag: number): void;
  80684. /**
  80685. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  80686. * @param func defines a function which checks material defines against the submeshes
  80687. */
  80688. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  80689. /**
  80690. * Indicates that image processing needs to be re-calculated for all submeshes
  80691. */
  80692. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  80693. /**
  80694. * Indicates that textures need to be re-calculated for all submeshes
  80695. */
  80696. protected _markAllSubMeshesAsTexturesDirty(): void;
  80697. /**
  80698. * Indicates that fresnel needs to be re-calculated for all submeshes
  80699. */
  80700. protected _markAllSubMeshesAsFresnelDirty(): void;
  80701. /**
  80702. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  80703. */
  80704. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  80705. /**
  80706. * Indicates that lights need to be re-calculated for all submeshes
  80707. */
  80708. protected _markAllSubMeshesAsLightsDirty(): void;
  80709. /**
  80710. * Indicates that attributes need to be re-calculated for all submeshes
  80711. */
  80712. protected _markAllSubMeshesAsAttributesDirty(): void;
  80713. /**
  80714. * Indicates that misc needs to be re-calculated for all submeshes
  80715. */
  80716. protected _markAllSubMeshesAsMiscDirty(): void;
  80717. /**
  80718. * Indicates that textures and misc need to be re-calculated for all submeshes
  80719. */
  80720. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  80721. /**
  80722. * Disposes the material
  80723. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80724. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  80725. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  80726. */
  80727. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  80728. /** @hidden */
  80729. private releaseVertexArrayObject;
  80730. /**
  80731. * Serializes this material
  80732. * @returns the serialized material object
  80733. */
  80734. serialize(): any;
  80735. /**
  80736. * Creates a material from parsed material data
  80737. * @param parsedMaterial defines parsed material data
  80738. * @param scene defines the hosting scene
  80739. * @param rootUrl defines the root URL to use to load textures
  80740. * @returns a new material
  80741. */
  80742. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  80743. }
  80744. }
  80745. declare module BABYLON {
  80746. /**
  80747. * Base class for submeshes
  80748. */
  80749. export class BaseSubMesh {
  80750. /** @hidden */
  80751. _materialDefines: Nullable<MaterialDefines>;
  80752. /** @hidden */
  80753. _materialEffect: Nullable<Effect>;
  80754. /**
  80755. * Gets associated effect
  80756. */
  80757. readonly effect: Nullable<Effect>;
  80758. /**
  80759. * Sets associated effect (effect used to render this submesh)
  80760. * @param effect defines the effect to associate with
  80761. * @param defines defines the set of defines used to compile this effect
  80762. */
  80763. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  80764. }
  80765. /**
  80766. * Defines a subdivision inside a mesh
  80767. */
  80768. export class SubMesh extends BaseSubMesh implements ICullable {
  80769. /** the material index to use */
  80770. materialIndex: number;
  80771. /** vertex index start */
  80772. verticesStart: number;
  80773. /** vertices count */
  80774. verticesCount: number;
  80775. /** index start */
  80776. indexStart: number;
  80777. /** indices count */
  80778. indexCount: number;
  80779. /** @hidden */
  80780. _linesIndexCount: number;
  80781. private _mesh;
  80782. private _renderingMesh;
  80783. private _boundingInfo;
  80784. private _linesIndexBuffer;
  80785. /** @hidden */
  80786. _lastColliderWorldVertices: Nullable<Vector3[]>;
  80787. /** @hidden */
  80788. _trianglePlanes: Plane[];
  80789. /** @hidden */
  80790. _lastColliderTransformMatrix: Matrix;
  80791. /** @hidden */
  80792. _renderId: number;
  80793. /** @hidden */
  80794. _alphaIndex: number;
  80795. /** @hidden */
  80796. _distanceToCamera: number;
  80797. /** @hidden */
  80798. _id: number;
  80799. private _currentMaterial;
  80800. /**
  80801. * Add a new submesh to a mesh
  80802. * @param materialIndex defines the material index to use
  80803. * @param verticesStart defines vertex index start
  80804. * @param verticesCount defines vertices count
  80805. * @param indexStart defines index start
  80806. * @param indexCount defines indices count
  80807. * @param mesh defines the parent mesh
  80808. * @param renderingMesh defines an optional rendering mesh
  80809. * @param createBoundingBox defines if bounding box should be created for this submesh
  80810. * @returns the new submesh
  80811. */
  80812. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  80813. /**
  80814. * Creates a new submesh
  80815. * @param materialIndex defines the material index to use
  80816. * @param verticesStart defines vertex index start
  80817. * @param verticesCount defines vertices count
  80818. * @param indexStart defines index start
  80819. * @param indexCount defines indices count
  80820. * @param mesh defines the parent mesh
  80821. * @param renderingMesh defines an optional rendering mesh
  80822. * @param createBoundingBox defines if bounding box should be created for this submesh
  80823. */
  80824. constructor(
  80825. /** the material index to use */
  80826. materialIndex: number,
  80827. /** vertex index start */
  80828. verticesStart: number,
  80829. /** vertices count */
  80830. verticesCount: number,
  80831. /** index start */
  80832. indexStart: number,
  80833. /** indices count */
  80834. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  80835. /**
  80836. * Returns true if this submesh covers the entire parent mesh
  80837. * @ignorenaming
  80838. */
  80839. readonly IsGlobal: boolean;
  80840. /**
  80841. * Returns the submesh BoudingInfo object
  80842. * @returns current bounding info (or mesh's one if the submesh is global)
  80843. */
  80844. getBoundingInfo(): BoundingInfo;
  80845. /**
  80846. * Sets the submesh BoundingInfo
  80847. * @param boundingInfo defines the new bounding info to use
  80848. * @returns the SubMesh
  80849. */
  80850. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  80851. /**
  80852. * Returns the mesh of the current submesh
  80853. * @return the parent mesh
  80854. */
  80855. getMesh(): AbstractMesh;
  80856. /**
  80857. * Returns the rendering mesh of the submesh
  80858. * @returns the rendering mesh (could be different from parent mesh)
  80859. */
  80860. getRenderingMesh(): Mesh;
  80861. /**
  80862. * Returns the submesh material
  80863. * @returns null or the current material
  80864. */
  80865. getMaterial(): Nullable<Material>;
  80866. /**
  80867. * Sets a new updated BoundingInfo object to the submesh
  80868. * @returns the SubMesh
  80869. */
  80870. refreshBoundingInfo(): SubMesh;
  80871. /** @hidden */
  80872. _checkCollision(collider: Collider): boolean;
  80873. /**
  80874. * Updates the submesh BoundingInfo
  80875. * @param world defines the world matrix to use to update the bounding info
  80876. * @returns the submesh
  80877. */
  80878. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  80879. /**
  80880. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  80881. * @param frustumPlanes defines the frustum planes
  80882. * @returns true if the submesh is intersecting with the frustum
  80883. */
  80884. isInFrustum(frustumPlanes: Plane[]): boolean;
  80885. /**
  80886. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  80887. * @param frustumPlanes defines the frustum planes
  80888. * @returns true if the submesh is inside the frustum
  80889. */
  80890. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80891. /**
  80892. * Renders the submesh
  80893. * @param enableAlphaMode defines if alpha needs to be used
  80894. * @returns the submesh
  80895. */
  80896. render(enableAlphaMode: boolean): SubMesh;
  80897. /**
  80898. * @hidden
  80899. */
  80900. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  80901. /**
  80902. * Checks if the submesh intersects with a ray
  80903. * @param ray defines the ray to test
  80904. * @returns true is the passed ray intersects the submesh bounding box
  80905. */
  80906. canIntersects(ray: Ray): boolean;
  80907. /**
  80908. * Intersects current submesh with a ray
  80909. * @param ray defines the ray to test
  80910. * @param positions defines mesh's positions array
  80911. * @param indices defines mesh's indices array
  80912. * @param fastCheck defines if only bounding info should be used
  80913. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80914. * @returns intersection info or null if no intersection
  80915. */
  80916. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  80917. /** @hidden */
  80918. private _intersectLines;
  80919. /** @hidden */
  80920. private _intersectTriangles;
  80921. /** @hidden */
  80922. _rebuild(): void;
  80923. /**
  80924. * Creates a new submesh from the passed mesh
  80925. * @param newMesh defines the new hosting mesh
  80926. * @param newRenderingMesh defines an optional rendering mesh
  80927. * @returns the new submesh
  80928. */
  80929. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  80930. /**
  80931. * Release associated resources
  80932. */
  80933. dispose(): void;
  80934. /**
  80935. * Gets the class name
  80936. * @returns the string "SubMesh".
  80937. */
  80938. getClassName(): string;
  80939. /**
  80940. * Creates a new submesh from indices data
  80941. * @param materialIndex the index of the main mesh material
  80942. * @param startIndex the index where to start the copy in the mesh indices array
  80943. * @param indexCount the number of indices to copy then from the startIndex
  80944. * @param mesh the main mesh to create the submesh from
  80945. * @param renderingMesh the optional rendering mesh
  80946. * @returns a new submesh
  80947. */
  80948. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  80949. }
  80950. }
  80951. declare module BABYLON {
  80952. /**
  80953. * Class used to store geometry data (vertex buffers + index buffer)
  80954. */
  80955. export class Geometry implements IGetSetVerticesData {
  80956. /**
  80957. * Gets or sets the ID of the geometry
  80958. */
  80959. id: string;
  80960. /**
  80961. * Gets or sets the unique ID of the geometry
  80962. */
  80963. uniqueId: number;
  80964. /**
  80965. * Gets the delay loading state of the geometry (none by default which means not delayed)
  80966. */
  80967. delayLoadState: number;
  80968. /**
  80969. * Gets the file containing the data to load when running in delay load state
  80970. */
  80971. delayLoadingFile: Nullable<string>;
  80972. /**
  80973. * Callback called when the geometry is updated
  80974. */
  80975. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  80976. private _scene;
  80977. private _engine;
  80978. private _meshes;
  80979. private _totalVertices;
  80980. /** @hidden */
  80981. _indices: IndicesArray;
  80982. /** @hidden */
  80983. _vertexBuffers: {
  80984. [key: string]: VertexBuffer;
  80985. };
  80986. private _isDisposed;
  80987. private _extend;
  80988. private _boundingBias;
  80989. /** @hidden */
  80990. _delayInfo: Array<string>;
  80991. private _indexBuffer;
  80992. private _indexBufferIsUpdatable;
  80993. /** @hidden */
  80994. _boundingInfo: Nullable<BoundingInfo>;
  80995. /** @hidden */
  80996. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  80997. /** @hidden */
  80998. _softwareSkinningFrameId: number;
  80999. private _vertexArrayObjects;
  81000. private _updatable;
  81001. /** @hidden */
  81002. _positions: Nullable<Vector3[]>;
  81003. /**
  81004. * 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
  81005. */
  81006. /**
  81007. * 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
  81008. */
  81009. boundingBias: Vector2;
  81010. /**
  81011. * Static function used to attach a new empty geometry to a mesh
  81012. * @param mesh defines the mesh to attach the geometry to
  81013. * @returns the new Geometry
  81014. */
  81015. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81016. /**
  81017. * Creates a new geometry
  81018. * @param id defines the unique ID
  81019. * @param scene defines the hosting scene
  81020. * @param vertexData defines the VertexData used to get geometry data
  81021. * @param updatable defines if geometry must be updatable (false by default)
  81022. * @param mesh defines the mesh that will be associated with the geometry
  81023. */
  81024. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81025. /**
  81026. * Gets the current extend of the geometry
  81027. */
  81028. readonly extend: {
  81029. minimum: Vector3;
  81030. maximum: Vector3;
  81031. };
  81032. /**
  81033. * Gets the hosting scene
  81034. * @returns the hosting Scene
  81035. */
  81036. getScene(): Scene;
  81037. /**
  81038. * Gets the hosting engine
  81039. * @returns the hosting Engine
  81040. */
  81041. getEngine(): Engine;
  81042. /**
  81043. * Defines if the geometry is ready to use
  81044. * @returns true if the geometry is ready to be used
  81045. */
  81046. isReady(): boolean;
  81047. /**
  81048. * Gets a value indicating that the geometry should not be serialized
  81049. */
  81050. readonly doNotSerialize: boolean;
  81051. /** @hidden */
  81052. _rebuild(): void;
  81053. /**
  81054. * Affects all geometry data in one call
  81055. * @param vertexData defines the geometry data
  81056. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81057. */
  81058. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81059. /**
  81060. * Set specific vertex data
  81061. * @param kind defines the data kind (Position, normal, etc...)
  81062. * @param data defines the vertex data to use
  81063. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81064. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81065. */
  81066. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81067. /**
  81068. * Removes a specific vertex data
  81069. * @param kind defines the data kind (Position, normal, etc...)
  81070. */
  81071. removeVerticesData(kind: string): void;
  81072. /**
  81073. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81074. * @param buffer defines the vertex buffer to use
  81075. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81076. */
  81077. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81078. /**
  81079. * Update a specific vertex buffer
  81080. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81081. * It will do nothing if the buffer is not updatable
  81082. * @param kind defines the data kind (Position, normal, etc...)
  81083. * @param data defines the data to use
  81084. * @param offset defines the offset in the target buffer where to store the data
  81085. * @param useBytes set to true if the offset is in bytes
  81086. */
  81087. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81088. /**
  81089. * Update a specific vertex buffer
  81090. * This function will create a new buffer if the current one is not updatable
  81091. * @param kind defines the data kind (Position, normal, etc...)
  81092. * @param data defines the data to use
  81093. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81094. */
  81095. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81096. private _updateBoundingInfo;
  81097. /** @hidden */
  81098. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81099. /**
  81100. * Gets total number of vertices
  81101. * @returns the total number of vertices
  81102. */
  81103. getTotalVertices(): number;
  81104. /**
  81105. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81106. * @param kind defines the data kind (Position, normal, etc...)
  81107. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81108. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81109. * @returns a float array containing vertex data
  81110. */
  81111. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81112. /**
  81113. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81114. * @param kind defines the data kind (Position, normal, etc...)
  81115. * @returns true if the vertex buffer with the specified kind is updatable
  81116. */
  81117. isVertexBufferUpdatable(kind: string): boolean;
  81118. /**
  81119. * Gets a specific vertex buffer
  81120. * @param kind defines the data kind (Position, normal, etc...)
  81121. * @returns a VertexBuffer
  81122. */
  81123. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81124. /**
  81125. * Returns all vertex buffers
  81126. * @return an object holding all vertex buffers indexed by kind
  81127. */
  81128. getVertexBuffers(): Nullable<{
  81129. [key: string]: VertexBuffer;
  81130. }>;
  81131. /**
  81132. * Gets a boolean indicating if specific vertex buffer is present
  81133. * @param kind defines the data kind (Position, normal, etc...)
  81134. * @returns true if data is present
  81135. */
  81136. isVerticesDataPresent(kind: string): boolean;
  81137. /**
  81138. * Gets a list of all attached data kinds (Position, normal, etc...)
  81139. * @returns a list of string containing all kinds
  81140. */
  81141. getVerticesDataKinds(): string[];
  81142. /**
  81143. * Update index buffer
  81144. * @param indices defines the indices to store in the index buffer
  81145. * @param offset defines the offset in the target buffer where to store the data
  81146. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  81147. */
  81148. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81149. /**
  81150. * Creates a new index buffer
  81151. * @param indices defines the indices to store in the index buffer
  81152. * @param totalVertices defines the total number of vertices (could be null)
  81153. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81154. */
  81155. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81156. /**
  81157. * Return the total number of indices
  81158. * @returns the total number of indices
  81159. */
  81160. getTotalIndices(): number;
  81161. /**
  81162. * Gets the index buffer array
  81163. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81165. * @returns the index buffer array
  81166. */
  81167. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81168. /**
  81169. * Gets the index buffer
  81170. * @return the index buffer
  81171. */
  81172. getIndexBuffer(): Nullable<WebGLBuffer>;
  81173. /** @hidden */
  81174. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81175. /**
  81176. * Release the associated resources for a specific mesh
  81177. * @param mesh defines the source mesh
  81178. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81179. */
  81180. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81181. /**
  81182. * Apply current geometry to a given mesh
  81183. * @param mesh defines the mesh to apply geometry to
  81184. */
  81185. applyToMesh(mesh: Mesh): void;
  81186. private _updateExtend;
  81187. private _applyToMesh;
  81188. private notifyUpdate;
  81189. /**
  81190. * Load the geometry if it was flagged as delay loaded
  81191. * @param scene defines the hosting scene
  81192. * @param onLoaded defines a callback called when the geometry is loaded
  81193. */
  81194. load(scene: Scene, onLoaded?: () => void): void;
  81195. private _queueLoad;
  81196. /**
  81197. * Invert the geometry to move from a right handed system to a left handed one.
  81198. */
  81199. toLeftHanded(): void;
  81200. /** @hidden */
  81201. _resetPointsArrayCache(): void;
  81202. /** @hidden */
  81203. _generatePointsArray(): boolean;
  81204. /**
  81205. * Gets a value indicating if the geometry is disposed
  81206. * @returns true if the geometry was disposed
  81207. */
  81208. isDisposed(): boolean;
  81209. private _disposeVertexArrayObjects;
  81210. /**
  81211. * Free all associated resources
  81212. */
  81213. dispose(): void;
  81214. /**
  81215. * Clone the current geometry into a new geometry
  81216. * @param id defines the unique ID of the new geometry
  81217. * @returns a new geometry object
  81218. */
  81219. copy(id: string): Geometry;
  81220. /**
  81221. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81222. * @return a JSON representation of the current geometry data (without the vertices data)
  81223. */
  81224. serialize(): any;
  81225. private toNumberArray;
  81226. /**
  81227. * Serialize all vertices data into a JSON oject
  81228. * @returns a JSON representation of the current geometry data
  81229. */
  81230. serializeVerticeData(): any;
  81231. /**
  81232. * Extracts a clone of a mesh geometry
  81233. * @param mesh defines the source mesh
  81234. * @param id defines the unique ID of the new geometry object
  81235. * @returns the new geometry object
  81236. */
  81237. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81238. /**
  81239. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81240. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81241. * Be aware Math.random() could cause collisions, but:
  81242. * "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"
  81243. * @returns a string containing a new GUID
  81244. */
  81245. static RandomId(): string;
  81246. /** @hidden */
  81247. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81248. private static _CleanMatricesWeights;
  81249. /**
  81250. * Create a new geometry from persisted data (Using .babylon file format)
  81251. * @param parsedVertexData defines the persisted data
  81252. * @param scene defines the hosting scene
  81253. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81254. * @returns the new geometry object
  81255. */
  81256. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81257. }
  81258. }
  81259. declare module BABYLON {
  81260. /**
  81261. * Define an interface for all classes that will get and set the data on vertices
  81262. */
  81263. export interface IGetSetVerticesData {
  81264. /**
  81265. * Gets a boolean indicating if specific vertex data is present
  81266. * @param kind defines the vertex data kind to use
  81267. * @returns true is data kind is present
  81268. */
  81269. isVerticesDataPresent(kind: string): boolean;
  81270. /**
  81271. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81272. * @param kind defines the data kind (Position, normal, etc...)
  81273. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81274. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81275. * @returns a float array containing vertex data
  81276. */
  81277. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81278. /**
  81279. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81280. * @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.
  81281. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81282. * @returns the indices array or an empty array if the mesh has no geometry
  81283. */
  81284. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81285. /**
  81286. * Set specific vertex data
  81287. * @param kind defines the data kind (Position, normal, etc...)
  81288. * @param data defines the vertex data to use
  81289. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81290. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81291. */
  81292. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  81293. /**
  81294. * Update a specific associated vertex buffer
  81295. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81296. * - VertexBuffer.PositionKind
  81297. * - VertexBuffer.UVKind
  81298. * - VertexBuffer.UV2Kind
  81299. * - VertexBuffer.UV3Kind
  81300. * - VertexBuffer.UV4Kind
  81301. * - VertexBuffer.UV5Kind
  81302. * - VertexBuffer.UV6Kind
  81303. * - VertexBuffer.ColorKind
  81304. * - VertexBuffer.MatricesIndicesKind
  81305. * - VertexBuffer.MatricesIndicesExtraKind
  81306. * - VertexBuffer.MatricesWeightsKind
  81307. * - VertexBuffer.MatricesWeightsExtraKind
  81308. * @param data defines the data source
  81309. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81310. * @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)
  81311. */
  81312. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  81313. /**
  81314. * Creates a new index buffer
  81315. * @param indices defines the indices to store in the index buffer
  81316. * @param totalVertices defines the total number of vertices (could be null)
  81317. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81318. */
  81319. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  81320. }
  81321. /**
  81322. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  81323. */
  81324. export class VertexData {
  81325. /**
  81326. * Mesh side orientation : usually the external or front surface
  81327. */
  81328. static readonly FRONTSIDE: number;
  81329. /**
  81330. * Mesh side orientation : usually the internal or back surface
  81331. */
  81332. static readonly BACKSIDE: number;
  81333. /**
  81334. * Mesh side orientation : both internal and external or front and back surfaces
  81335. */
  81336. static readonly DOUBLESIDE: number;
  81337. /**
  81338. * Mesh side orientation : by default, `FRONTSIDE`
  81339. */
  81340. static readonly DEFAULTSIDE: number;
  81341. /**
  81342. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  81343. */
  81344. positions: Nullable<FloatArray>;
  81345. /**
  81346. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  81347. */
  81348. normals: Nullable<FloatArray>;
  81349. /**
  81350. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  81351. */
  81352. tangents: Nullable<FloatArray>;
  81353. /**
  81354. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81355. */
  81356. uvs: Nullable<FloatArray>;
  81357. /**
  81358. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81359. */
  81360. uvs2: Nullable<FloatArray>;
  81361. /**
  81362. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81363. */
  81364. uvs3: Nullable<FloatArray>;
  81365. /**
  81366. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81367. */
  81368. uvs4: Nullable<FloatArray>;
  81369. /**
  81370. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81371. */
  81372. uvs5: Nullable<FloatArray>;
  81373. /**
  81374. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81375. */
  81376. uvs6: Nullable<FloatArray>;
  81377. /**
  81378. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  81379. */
  81380. colors: Nullable<FloatArray>;
  81381. /**
  81382. * 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).
  81383. */
  81384. matricesIndices: Nullable<FloatArray>;
  81385. /**
  81386. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  81387. */
  81388. matricesWeights: Nullable<FloatArray>;
  81389. /**
  81390. * An array extending the number of possible indices
  81391. */
  81392. matricesIndicesExtra: Nullable<FloatArray>;
  81393. /**
  81394. * An array extending the number of possible weights when the number of indices is extended
  81395. */
  81396. matricesWeightsExtra: Nullable<FloatArray>;
  81397. /**
  81398. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  81399. */
  81400. indices: Nullable<IndicesArray>;
  81401. /**
  81402. * Uses the passed data array to set the set the values for the specified kind of data
  81403. * @param data a linear array of floating numbers
  81404. * @param kind the type of data that is being set, eg positions, colors etc
  81405. */
  81406. set(data: FloatArray, kind: string): void;
  81407. /**
  81408. * Associates the vertexData to the passed Mesh.
  81409. * Sets it as updatable or not (default `false`)
  81410. * @param mesh the mesh the vertexData is applied to
  81411. * @param updatable when used and having the value true allows new data to update the vertexData
  81412. * @returns the VertexData
  81413. */
  81414. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  81415. /**
  81416. * Associates the vertexData to the passed Geometry.
  81417. * Sets it as updatable or not (default `false`)
  81418. * @param geometry the geometry the vertexData is applied to
  81419. * @param updatable when used and having the value true allows new data to update the vertexData
  81420. * @returns VertexData
  81421. */
  81422. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  81423. /**
  81424. * Updates the associated mesh
  81425. * @param mesh the mesh to be updated
  81426. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81427. * @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
  81428. * @returns VertexData
  81429. */
  81430. updateMesh(mesh: Mesh): VertexData;
  81431. /**
  81432. * Updates the associated geometry
  81433. * @param geometry the geometry to be updated
  81434. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81435. * @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
  81436. * @returns VertexData.
  81437. */
  81438. updateGeometry(geometry: Geometry): VertexData;
  81439. private _applyTo;
  81440. private _update;
  81441. /**
  81442. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81443. * @param matrix the transforming matrix
  81444. * @returns the VertexData
  81445. */
  81446. transform(matrix: Matrix): VertexData;
  81447. /**
  81448. * Merges the passed VertexData into the current one
  81449. * @param other the VertexData to be merged into the current one
  81450. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81451. * @returns the modified VertexData
  81452. */
  81453. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81454. private _mergeElement;
  81455. private _validate;
  81456. /**
  81457. * Serializes the VertexData
  81458. * @returns a serialized object
  81459. */
  81460. serialize(): any;
  81461. /**
  81462. * Extracts the vertexData from a mesh
  81463. * @param mesh the mesh from which to extract the VertexData
  81464. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81465. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81466. * @returns the object VertexData associated to the passed mesh
  81467. */
  81468. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81469. /**
  81470. * Extracts the vertexData from the geometry
  81471. * @param geometry the geometry from which to extract the VertexData
  81472. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81473. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81474. * @returns the object VertexData associated to the passed mesh
  81475. */
  81476. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81477. private static _ExtractFrom;
  81478. /**
  81479. * Creates the VertexData for a Ribbon
  81480. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81481. * * pathArray array of paths, each of which an array of successive Vector3
  81482. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81483. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81484. * * 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
  81485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81486. * * 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)
  81487. * * 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)
  81488. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81489. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81490. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81491. * @returns the VertexData of the ribbon
  81492. */
  81493. static CreateRibbon(options: {
  81494. pathArray: Vector3[][];
  81495. closeArray?: boolean;
  81496. closePath?: boolean;
  81497. offset?: number;
  81498. sideOrientation?: number;
  81499. frontUVs?: Vector4;
  81500. backUVs?: Vector4;
  81501. invertUV?: boolean;
  81502. uvs?: Vector2[];
  81503. colors?: Color4[];
  81504. }): VertexData;
  81505. /**
  81506. * Creates the VertexData for a box
  81507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81508. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81509. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81510. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81511. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81512. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81513. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81515. * * 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)
  81516. * * 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)
  81517. * @returns the VertexData of the box
  81518. */
  81519. static CreateBox(options: {
  81520. size?: number;
  81521. width?: number;
  81522. height?: number;
  81523. depth?: number;
  81524. faceUV?: Vector4[];
  81525. faceColors?: Color4[];
  81526. sideOrientation?: number;
  81527. frontUVs?: Vector4;
  81528. backUVs?: Vector4;
  81529. }): VertexData;
  81530. /**
  81531. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81532. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81533. * * segments sets the number of horizontal strips optional, default 32
  81534. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81535. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81536. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81537. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81538. * * 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
  81539. * * 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
  81540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81541. * * 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)
  81542. * * 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)
  81543. * @returns the VertexData of the ellipsoid
  81544. */
  81545. static CreateSphere(options: {
  81546. segments?: number;
  81547. diameter?: number;
  81548. diameterX?: number;
  81549. diameterY?: number;
  81550. diameterZ?: number;
  81551. arc?: number;
  81552. slice?: number;
  81553. sideOrientation?: number;
  81554. frontUVs?: Vector4;
  81555. backUVs?: Vector4;
  81556. }): VertexData;
  81557. /**
  81558. * Creates the VertexData for a cylinder, cone or prism
  81559. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81560. * * height sets the height (y direction) of the cylinder, optional, default 2
  81561. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81562. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81563. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81564. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81565. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81566. * * 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
  81567. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81568. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81569. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  81570. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  81571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81572. * * 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)
  81573. * * 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)
  81574. * @returns the VertexData of the cylinder, cone or prism
  81575. */
  81576. static CreateCylinder(options: {
  81577. height?: number;
  81578. diameterTop?: number;
  81579. diameterBottom?: number;
  81580. diameter?: number;
  81581. tessellation?: number;
  81582. subdivisions?: number;
  81583. arc?: number;
  81584. faceColors?: Color4[];
  81585. faceUV?: Vector4[];
  81586. hasRings?: boolean;
  81587. enclose?: boolean;
  81588. sideOrientation?: number;
  81589. frontUVs?: Vector4;
  81590. backUVs?: Vector4;
  81591. }): VertexData;
  81592. /**
  81593. * Creates the VertexData for a torus
  81594. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81595. * * diameter the diameter of the torus, optional default 1
  81596. * * thickness the diameter of the tube forming the torus, optional default 0.5
  81597. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81598. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81599. * * 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)
  81600. * * 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)
  81601. * @returns the VertexData of the torus
  81602. */
  81603. static CreateTorus(options: {
  81604. diameter?: number;
  81605. thickness?: number;
  81606. tessellation?: number;
  81607. sideOrientation?: number;
  81608. frontUVs?: Vector4;
  81609. backUVs?: Vector4;
  81610. }): VertexData;
  81611. /**
  81612. * Creates the VertexData of the LineSystem
  81613. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  81614. * - lines an array of lines, each line being an array of successive Vector3
  81615. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  81616. * @returns the VertexData of the LineSystem
  81617. */
  81618. static CreateLineSystem(options: {
  81619. lines: Vector3[][];
  81620. colors?: Nullable<Color4[][]>;
  81621. }): VertexData;
  81622. /**
  81623. * Create the VertexData for a DashedLines
  81624. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  81625. * - points an array successive Vector3
  81626. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  81627. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  81628. * - dashNb the intended total number of dashes, optional, default 200
  81629. * @returns the VertexData for the DashedLines
  81630. */
  81631. static CreateDashedLines(options: {
  81632. points: Vector3[];
  81633. dashSize?: number;
  81634. gapSize?: number;
  81635. dashNb?: number;
  81636. }): VertexData;
  81637. /**
  81638. * Creates the VertexData for a Ground
  81639. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81640. * - width the width (x direction) of the ground, optional, default 1
  81641. * - height the height (z direction) of the ground, optional, default 1
  81642. * - subdivisions the number of subdivisions per side, optional, default 1
  81643. * @returns the VertexData of the Ground
  81644. */
  81645. static CreateGround(options: {
  81646. width?: number;
  81647. height?: number;
  81648. subdivisions?: number;
  81649. subdivisionsX?: number;
  81650. subdivisionsY?: number;
  81651. }): VertexData;
  81652. /**
  81653. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  81654. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81655. * * xmin the ground minimum X coordinate, optional, default -1
  81656. * * zmin the ground minimum Z coordinate, optional, default -1
  81657. * * xmax the ground maximum X coordinate, optional, default 1
  81658. * * zmax the ground maximum Z coordinate, optional, default 1
  81659. * * 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}
  81660. * * 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}
  81661. * @returns the VertexData of the TiledGround
  81662. */
  81663. static CreateTiledGround(options: {
  81664. xmin: number;
  81665. zmin: number;
  81666. xmax: number;
  81667. zmax: number;
  81668. subdivisions?: {
  81669. w: number;
  81670. h: number;
  81671. };
  81672. precision?: {
  81673. w: number;
  81674. h: number;
  81675. };
  81676. }): VertexData;
  81677. /**
  81678. * Creates the VertexData of the Ground designed from a heightmap
  81679. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  81680. * * width the width (x direction) of the ground
  81681. * * height the height (z direction) of the ground
  81682. * * subdivisions the number of subdivisions per side
  81683. * * minHeight the minimum altitude on the ground, optional, default 0
  81684. * * maxHeight the maximum altitude on the ground, optional default 1
  81685. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  81686. * * buffer the array holding the image color data
  81687. * * bufferWidth the width of image
  81688. * * bufferHeight the height of image
  81689. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  81690. * @returns the VertexData of the Ground designed from a heightmap
  81691. */
  81692. static CreateGroundFromHeightMap(options: {
  81693. width: number;
  81694. height: number;
  81695. subdivisions: number;
  81696. minHeight: number;
  81697. maxHeight: number;
  81698. colorFilter: Color3;
  81699. buffer: Uint8Array;
  81700. bufferWidth: number;
  81701. bufferHeight: number;
  81702. alphaFilter: number;
  81703. }): VertexData;
  81704. /**
  81705. * Creates the VertexData for a Plane
  81706. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  81707. * * size sets the width and height of the plane to the value of size, optional default 1
  81708. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  81709. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  81710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81711. * * 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)
  81712. * * 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)
  81713. * @returns the VertexData of the box
  81714. */
  81715. static CreatePlane(options: {
  81716. size?: number;
  81717. width?: number;
  81718. height?: number;
  81719. sideOrientation?: number;
  81720. frontUVs?: Vector4;
  81721. backUVs?: Vector4;
  81722. }): VertexData;
  81723. /**
  81724. * Creates the VertexData of the Disc or regular Polygon
  81725. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  81726. * * radius the radius of the disc, optional default 0.5
  81727. * * tessellation the number of polygon sides, optional, default 64
  81728. * * 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
  81729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81730. * * 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)
  81731. * * 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)
  81732. * @returns the VertexData of the box
  81733. */
  81734. static CreateDisc(options: {
  81735. radius?: number;
  81736. tessellation?: number;
  81737. arc?: number;
  81738. sideOrientation?: number;
  81739. frontUVs?: Vector4;
  81740. backUVs?: Vector4;
  81741. }): VertexData;
  81742. /**
  81743. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  81744. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  81745. * @param polygon a mesh built from polygonTriangulation.build()
  81746. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81747. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81748. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81749. * @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)
  81750. * @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)
  81751. * @returns the VertexData of the Polygon
  81752. */
  81753. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  81754. /**
  81755. * Creates the VertexData of the IcoSphere
  81756. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  81757. * * radius the radius of the IcoSphere, optional default 1
  81758. * * radiusX allows stretching in the x direction, optional, default radius
  81759. * * radiusY allows stretching in the y direction, optional, default radius
  81760. * * radiusZ allows stretching in the z direction, optional, default radius
  81761. * * flat when true creates a flat shaded mesh, optional, default true
  81762. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81763. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81764. * * 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)
  81765. * * 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)
  81766. * @returns the VertexData of the IcoSphere
  81767. */
  81768. static CreateIcoSphere(options: {
  81769. radius?: number;
  81770. radiusX?: number;
  81771. radiusY?: number;
  81772. radiusZ?: number;
  81773. flat?: boolean;
  81774. subdivisions?: number;
  81775. sideOrientation?: number;
  81776. frontUVs?: Vector4;
  81777. backUVs?: Vector4;
  81778. }): VertexData;
  81779. /**
  81780. * Creates the VertexData for a Polyhedron
  81781. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  81782. * * type provided types are:
  81783. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  81784. * * 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)
  81785. * * size the size of the IcoSphere, optional default 1
  81786. * * sizeX allows stretching in the x direction, optional, default size
  81787. * * sizeY allows stretching in the y direction, optional, default size
  81788. * * sizeZ allows stretching in the z direction, optional, default size
  81789. * * 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
  81790. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81791. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81792. * * flat when true creates a flat shaded mesh, optional, default true
  81793. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81795. * * 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)
  81796. * * 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)
  81797. * @returns the VertexData of the Polyhedron
  81798. */
  81799. static CreatePolyhedron(options: {
  81800. type?: number;
  81801. size?: number;
  81802. sizeX?: number;
  81803. sizeY?: number;
  81804. sizeZ?: number;
  81805. custom?: any;
  81806. faceUV?: Vector4[];
  81807. faceColors?: Color4[];
  81808. flat?: boolean;
  81809. sideOrientation?: number;
  81810. frontUVs?: Vector4;
  81811. backUVs?: Vector4;
  81812. }): VertexData;
  81813. /**
  81814. * Creates the VertexData for a TorusKnot
  81815. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  81816. * * radius the radius of the torus knot, optional, default 2
  81817. * * tube the thickness of the tube, optional, default 0.5
  81818. * * radialSegments the number of sides on each tube segments, optional, default 32
  81819. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  81820. * * p the number of windings around the z axis, optional, default 2
  81821. * * q the number of windings around the x axis, optional, default 3
  81822. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81823. * * 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)
  81824. * * 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)
  81825. * @returns the VertexData of the Torus Knot
  81826. */
  81827. static CreateTorusKnot(options: {
  81828. radius?: number;
  81829. tube?: number;
  81830. radialSegments?: number;
  81831. tubularSegments?: number;
  81832. p?: number;
  81833. q?: number;
  81834. sideOrientation?: number;
  81835. frontUVs?: Vector4;
  81836. backUVs?: Vector4;
  81837. }): VertexData;
  81838. /**
  81839. * Compute normals for given positions and indices
  81840. * @param positions an array of vertex positions, [...., x, y, z, ......]
  81841. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  81842. * @param normals an array of vertex normals, [...., x, y, z, ......]
  81843. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  81844. * * facetNormals : optional array of facet normals (vector3)
  81845. * * facetPositions : optional array of facet positions (vector3)
  81846. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  81847. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  81848. * * bInfo : optional bounding info, required for facetPartitioning computation
  81849. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  81850. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  81851. * * useRightHandedSystem: optional boolean to for right handed system computation
  81852. * * depthSort : optional boolean to enable the facet depth sort computation
  81853. * * distanceTo : optional Vector3 to compute the facet depth from this location
  81854. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  81855. */
  81856. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  81857. facetNormals?: any;
  81858. facetPositions?: any;
  81859. facetPartitioning?: any;
  81860. ratio?: number;
  81861. bInfo?: any;
  81862. bbSize?: Vector3;
  81863. subDiv?: any;
  81864. useRightHandedSystem?: boolean;
  81865. depthSort?: boolean;
  81866. distanceTo?: Vector3;
  81867. depthSortedFacets?: any;
  81868. }): void;
  81869. /** @hidden */
  81870. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  81871. /**
  81872. * Applies VertexData created from the imported parameters to the geometry
  81873. * @param parsedVertexData the parsed data from an imported file
  81874. * @param geometry the geometry to apply the VertexData to
  81875. */
  81876. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  81877. }
  81878. }
  81879. declare module BABYLON {
  81880. /**
  81881. * Class containing static functions to help procedurally build meshes
  81882. */
  81883. export class DiscBuilder {
  81884. /**
  81885. * Creates a plane polygonal mesh. By default, this is a disc
  81886. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  81887. * * 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
  81888. * * 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
  81889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81892. * @param name defines the name of the mesh
  81893. * @param options defines the options used to create the mesh
  81894. * @param scene defines the hosting scene
  81895. * @returns the plane polygonal mesh
  81896. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  81897. */
  81898. static CreateDisc(name: string, options: {
  81899. radius?: number;
  81900. tessellation?: number;
  81901. arc?: number;
  81902. updatable?: boolean;
  81903. sideOrientation?: number;
  81904. frontUVs?: Vector4;
  81905. backUVs?: Vector4;
  81906. }, scene?: Nullable<Scene>): Mesh;
  81907. }
  81908. }
  81909. declare module BABYLON {
  81910. /**
  81911. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  81912. *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.
  81913. * The SPS is also a particle system. It provides some methods to manage the particles.
  81914. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  81915. *
  81916. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  81917. */
  81918. export class SolidParticleSystem implements IDisposable {
  81919. /**
  81920. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  81921. * Example : var p = SPS.particles[i];
  81922. */
  81923. particles: SolidParticle[];
  81924. /**
  81925. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  81926. */
  81927. nbParticles: number;
  81928. /**
  81929. * If the particles must ever face the camera (default false). Useful for planar particles.
  81930. */
  81931. billboard: boolean;
  81932. /**
  81933. * Recompute normals when adding a shape
  81934. */
  81935. recomputeNormals: boolean;
  81936. /**
  81937. * This a counter ofr your own usage. It's not set by any SPS functions.
  81938. */
  81939. counter: number;
  81940. /**
  81941. * The SPS name. This name is also given to the underlying mesh.
  81942. */
  81943. name: string;
  81944. /**
  81945. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  81946. */
  81947. mesh: Mesh;
  81948. /**
  81949. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  81950. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  81951. */
  81952. vars: any;
  81953. /**
  81954. * This array is populated when the SPS is set as 'pickable'.
  81955. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  81956. * Each element of this array is an object `{idx: int, faceId: int}`.
  81957. * `idx` is the picked particle index in the `SPS.particles` array
  81958. * `faceId` is the picked face index counted within this particle.
  81959. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  81960. */
  81961. pickedParticles: {
  81962. idx: number;
  81963. faceId: number;
  81964. }[];
  81965. /**
  81966. * This array is populated when `enableDepthSort` is set to true.
  81967. * Each element of this array is an instance of the class DepthSortedParticle.
  81968. */
  81969. depthSortedParticles: DepthSortedParticle[];
  81970. /**
  81971. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  81972. * @hidden
  81973. */
  81974. _bSphereOnly: boolean;
  81975. /**
  81976. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  81977. * @hidden
  81978. */
  81979. _bSphereRadiusFactor: number;
  81980. private _scene;
  81981. private _positions;
  81982. private _indices;
  81983. private _normals;
  81984. private _colors;
  81985. private _uvs;
  81986. private _indices32;
  81987. private _positions32;
  81988. private _normals32;
  81989. private _fixedNormal32;
  81990. private _colors32;
  81991. private _uvs32;
  81992. private _index;
  81993. private _updatable;
  81994. private _pickable;
  81995. private _isVisibilityBoxLocked;
  81996. private _alwaysVisible;
  81997. private _depthSort;
  81998. private _shapeCounter;
  81999. private _copy;
  82000. private _color;
  82001. private _computeParticleColor;
  82002. private _computeParticleTexture;
  82003. private _computeParticleRotation;
  82004. private _computeParticleVertex;
  82005. private _computeBoundingBox;
  82006. private _depthSortParticles;
  82007. private _camera;
  82008. private _mustUnrotateFixedNormals;
  82009. private _particlesIntersect;
  82010. private _needs32Bits;
  82011. /**
  82012. * Creates a SPS (Solid Particle System) object.
  82013. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82014. * @param scene (Scene) is the scene in which the SPS is added.
  82015. * @param options defines the options of the sps e.g.
  82016. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82017. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82018. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82019. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82020. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82021. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82022. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82023. */
  82024. constructor(name: string, scene: Scene, options?: {
  82025. updatable?: boolean;
  82026. isPickable?: boolean;
  82027. enableDepthSort?: boolean;
  82028. particleIntersection?: boolean;
  82029. boundingSphereOnly?: boolean;
  82030. bSphereRadiusFactor?: number;
  82031. });
  82032. /**
  82033. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82034. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82035. * @returns the created mesh
  82036. */
  82037. buildMesh(): Mesh;
  82038. /**
  82039. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82040. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82041. * Thus the particles generated from `digest()` have their property `position` set yet.
  82042. * @param mesh ( Mesh ) is the mesh to be digested
  82043. * @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
  82044. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82045. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82046. * @returns the current SPS
  82047. */
  82048. digest(mesh: Mesh, options?: {
  82049. facetNb?: number;
  82050. number?: number;
  82051. delta?: number;
  82052. }): SolidParticleSystem;
  82053. private _unrotateFixedNormals;
  82054. private _resetCopy;
  82055. private _meshBuilder;
  82056. private _posToShape;
  82057. private _uvsToShapeUV;
  82058. private _addParticle;
  82059. /**
  82060. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82061. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82062. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82063. * @param nb (positive integer) the number of particles to be created from this model
  82064. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82065. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82066. * @returns the number of shapes in the system
  82067. */
  82068. addShape(mesh: Mesh, nb: number, options?: {
  82069. positionFunction?: any;
  82070. vertexFunction?: any;
  82071. }): number;
  82072. private _rebuildParticle;
  82073. /**
  82074. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82075. * @returns the SPS.
  82076. */
  82077. rebuildMesh(): SolidParticleSystem;
  82078. /**
  82079. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82080. * This method calls `updateParticle()` for each particle of the SPS.
  82081. * For an animated SPS, it is usually called within the render loop.
  82082. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82083. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82084. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82085. * @returns the SPS.
  82086. */
  82087. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82088. /**
  82089. * Disposes the SPS.
  82090. */
  82091. dispose(): void;
  82092. /**
  82093. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82094. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82095. * @returns the SPS.
  82096. */
  82097. refreshVisibleSize(): SolidParticleSystem;
  82098. /**
  82099. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82100. * @param size the size (float) of the visibility box
  82101. * note : this doesn't lock the SPS mesh bounding box.
  82102. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82103. */
  82104. setVisibilityBox(size: number): void;
  82105. /**
  82106. * Gets whether the SPS as always visible or not
  82107. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82108. */
  82109. /**
  82110. * Sets the SPS as always visible or not
  82111. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82112. */
  82113. isAlwaysVisible: boolean;
  82114. /**
  82115. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82116. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82117. */
  82118. /**
  82119. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82120. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82121. */
  82122. isVisibilityBoxLocked: boolean;
  82123. /**
  82124. * Tells to `setParticles()` to compute the particle rotations or not.
  82125. * Default value : true. The SPS is faster when it's set to false.
  82126. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82127. */
  82128. /**
  82129. * Gets if `setParticles()` computes the particle rotations or not.
  82130. * Default value : true. The SPS is faster when it's set to false.
  82131. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82132. */
  82133. computeParticleRotation: boolean;
  82134. /**
  82135. * Tells to `setParticles()` to compute the particle colors or not.
  82136. * Default value : true. The SPS is faster when it's set to false.
  82137. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82138. */
  82139. /**
  82140. * Gets if `setParticles()` computes the particle colors or not.
  82141. * Default value : true. The SPS is faster when it's set to false.
  82142. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82143. */
  82144. computeParticleColor: boolean;
  82145. /**
  82146. * Gets if `setParticles()` computes the particle textures or not.
  82147. * Default value : true. The SPS is faster when it's set to false.
  82148. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82149. */
  82150. computeParticleTexture: boolean;
  82151. /**
  82152. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82153. * Default value : false. The SPS is faster when it's set to false.
  82154. * Note : the particle custom vertex positions aren't stored values.
  82155. */
  82156. /**
  82157. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82158. * Default value : false. The SPS is faster when it's set to false.
  82159. * Note : the particle custom vertex positions aren't stored values.
  82160. */
  82161. computeParticleVertex: boolean;
  82162. /**
  82163. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82164. */
  82165. /**
  82166. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82167. */
  82168. computeBoundingBox: boolean;
  82169. /**
  82170. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82171. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82172. * Default : `true`
  82173. */
  82174. /**
  82175. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82176. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82177. * Default : `true`
  82178. */
  82179. depthSortParticles: boolean;
  82180. /**
  82181. * This function does nothing. It may be overwritten to set all the particle first values.
  82182. * The SPS doesn't call this function, you may have to call it by your own.
  82183. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82184. */
  82185. initParticles(): void;
  82186. /**
  82187. * This function does nothing. It may be overwritten to recycle a particle.
  82188. * The SPS doesn't call this function, you may have to call it by your own.
  82189. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82190. * @param particle The particle to recycle
  82191. * @returns the recycled particle
  82192. */
  82193. recycleParticle(particle: SolidParticle): SolidParticle;
  82194. /**
  82195. * Updates a particle : this function should be overwritten by the user.
  82196. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82197. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82198. * @example : just set a particle position or velocity and recycle conditions
  82199. * @param particle The particle to update
  82200. * @returns the updated particle
  82201. */
  82202. updateParticle(particle: SolidParticle): SolidParticle;
  82203. /**
  82204. * Updates a vertex of a particle : it can be overwritten by the user.
  82205. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82206. * @param particle the current particle
  82207. * @param vertex the current index of the current particle
  82208. * @param pt the index of the current vertex in the particle shape
  82209. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82210. * @example : just set a vertex particle position
  82211. * @returns the updated vertex
  82212. */
  82213. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82214. /**
  82215. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82216. * This does nothing and may be overwritten by the user.
  82217. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82218. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82219. * @param update the boolean update value actually passed to setParticles()
  82220. */
  82221. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82222. /**
  82223. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82224. * This will be passed three parameters.
  82225. * This does nothing and may be overwritten by the user.
  82226. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82227. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82228. * @param update the boolean update value actually passed to setParticles()
  82229. */
  82230. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82231. }
  82232. }
  82233. declare module BABYLON {
  82234. /**
  82235. * Represents one particle of a solid particle system.
  82236. */
  82237. export class SolidParticle {
  82238. /**
  82239. * particle global index
  82240. */
  82241. idx: number;
  82242. /**
  82243. * The color of the particle
  82244. */
  82245. color: Nullable<Color4>;
  82246. /**
  82247. * The world space position of the particle.
  82248. */
  82249. position: Vector3;
  82250. /**
  82251. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82252. */
  82253. rotation: Vector3;
  82254. /**
  82255. * The world space rotation quaternion of the particle.
  82256. */
  82257. rotationQuaternion: Nullable<Quaternion>;
  82258. /**
  82259. * The scaling of the particle.
  82260. */
  82261. scaling: Vector3;
  82262. /**
  82263. * The uvs of the particle.
  82264. */
  82265. uvs: Vector4;
  82266. /**
  82267. * The current speed of the particle.
  82268. */
  82269. velocity: Vector3;
  82270. /**
  82271. * The pivot point in the particle local space.
  82272. */
  82273. pivot: Vector3;
  82274. /**
  82275. * Must the particle be translated from its pivot point in its local space ?
  82276. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  82277. * Default : false
  82278. */
  82279. translateFromPivot: boolean;
  82280. /**
  82281. * Is the particle active or not ?
  82282. */
  82283. alive: boolean;
  82284. /**
  82285. * Is the particle visible or not ?
  82286. */
  82287. isVisible: boolean;
  82288. /**
  82289. * Index of this particle in the global "positions" array (Internal use)
  82290. * @hidden
  82291. */
  82292. _pos: number;
  82293. /**
  82294. * @hidden Index of this particle in the global "indices" array (Internal use)
  82295. */
  82296. _ind: number;
  82297. /**
  82298. * @hidden ModelShape of this particle (Internal use)
  82299. */
  82300. _model: ModelShape;
  82301. /**
  82302. * ModelShape id of this particle
  82303. */
  82304. shapeId: number;
  82305. /**
  82306. * Index of the particle in its shape id (Internal use)
  82307. */
  82308. idxInShape: number;
  82309. /**
  82310. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  82311. */
  82312. _modelBoundingInfo: BoundingInfo;
  82313. /**
  82314. * @hidden Particle BoundingInfo object (Internal use)
  82315. */
  82316. _boundingInfo: BoundingInfo;
  82317. /**
  82318. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  82319. */
  82320. _sps: SolidParticleSystem;
  82321. /**
  82322. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  82323. */
  82324. _stillInvisible: boolean;
  82325. /**
  82326. * @hidden Last computed particle rotation matrix
  82327. */
  82328. _rotationMatrix: number[];
  82329. /**
  82330. * Parent particle Id, if any.
  82331. * Default null.
  82332. */
  82333. parentId: Nullable<number>;
  82334. /**
  82335. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  82336. * The possible values are :
  82337. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82338. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82339. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82340. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82341. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82342. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  82343. * */
  82344. cullingStrategy: number;
  82345. /**
  82346. * @hidden Internal global position in the SPS.
  82347. */
  82348. _globalPosition: Vector3;
  82349. /**
  82350. * Creates a Solid Particle object.
  82351. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  82352. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  82353. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  82354. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  82355. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  82356. * @param shapeId (integer) is the model shape identifier in the SPS.
  82357. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  82358. * @param sps defines the sps it is associated to
  82359. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  82360. */
  82361. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  82362. /**
  82363. * Legacy support, changed scale to scaling
  82364. */
  82365. /**
  82366. * Legacy support, changed scale to scaling
  82367. */
  82368. scale: Vector3;
  82369. /**
  82370. * Legacy support, changed quaternion to rotationQuaternion
  82371. */
  82372. /**
  82373. * Legacy support, changed quaternion to rotationQuaternion
  82374. */
  82375. quaternion: Nullable<Quaternion>;
  82376. /**
  82377. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  82378. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  82379. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  82380. * @returns true if it intersects
  82381. */
  82382. intersectsMesh(target: Mesh | SolidParticle): boolean;
  82383. /**
  82384. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  82385. * A particle is in the frustum if its bounding box intersects the frustum
  82386. * @param frustumPlanes defines the frustum to test
  82387. * @returns true if the particle is in the frustum planes
  82388. */
  82389. isInFrustum(frustumPlanes: Plane[]): boolean;
  82390. /**
  82391. * get the rotation matrix of the particle
  82392. * @hidden
  82393. */
  82394. getRotationMatrix(m: Matrix): void;
  82395. }
  82396. /**
  82397. * Represents the shape of the model used by one particle of a solid particle system.
  82398. * SPS internal tool, don't use it manually.
  82399. */
  82400. export class ModelShape {
  82401. /**
  82402. * The shape id
  82403. * @hidden
  82404. */
  82405. shapeID: number;
  82406. /**
  82407. * flat array of model positions (internal use)
  82408. * @hidden
  82409. */
  82410. _shape: Vector3[];
  82411. /**
  82412. * flat array of model UVs (internal use)
  82413. * @hidden
  82414. */
  82415. _shapeUV: number[];
  82416. /**
  82417. * length of the shape in the model indices array (internal use)
  82418. * @hidden
  82419. */
  82420. _indicesLength: number;
  82421. /**
  82422. * Custom position function (internal use)
  82423. * @hidden
  82424. */
  82425. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  82426. /**
  82427. * Custom vertex function (internal use)
  82428. * @hidden
  82429. */
  82430. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  82431. /**
  82432. * 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.
  82433. * SPS internal tool, don't use it manually.
  82434. * @hidden
  82435. */
  82436. 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>);
  82437. }
  82438. /**
  82439. * Represents a Depth Sorted Particle in the solid particle system.
  82440. */
  82441. export class DepthSortedParticle {
  82442. /**
  82443. * Index of the particle in the "indices" array
  82444. */
  82445. ind: number;
  82446. /**
  82447. * Length of the particle shape in the "indices" array
  82448. */
  82449. indicesLength: number;
  82450. /**
  82451. * Squared distance from the particle to the camera
  82452. */
  82453. sqDistance: number;
  82454. }
  82455. }
  82456. declare module BABYLON {
  82457. /**
  82458. * Class used to store all common mesh properties
  82459. */
  82460. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82461. /** No occlusion */
  82462. static OCCLUSION_TYPE_NONE: number;
  82463. /** Occlusion set to optimisitic */
  82464. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82465. /** Occlusion set to strict */
  82466. static OCCLUSION_TYPE_STRICT: number;
  82467. /** Use an accurante occlusion algorithm */
  82468. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82469. /** Use a conservative occlusion algorithm */
  82470. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82471. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82472. * Test order :
  82473. * Is the bounding sphere outside the frustum ?
  82474. * If not, are the bounding box vertices outside the frustum ?
  82475. * It not, then the cullable object is in the frustum.
  82476. */
  82477. static readonly CULLINGSTRATEGY_STANDARD: number;
  82478. /** Culling strategy : Bounding Sphere Only.
  82479. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82480. * It's also less accurate than the standard because some not visible objects can still be selected.
  82481. * Test : is the bounding sphere outside the frustum ?
  82482. * If not, then the cullable object is in the frustum.
  82483. */
  82484. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82485. /** Culling strategy : Optimistic Inclusion.
  82486. * This in an inclusion test first, then the standard exclusion test.
  82487. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82488. * 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.
  82489. * Anyway, it's as accurate as the standard strategy.
  82490. * Test :
  82491. * Is the cullable object bounding sphere center in the frustum ?
  82492. * If not, apply the default culling strategy.
  82493. */
  82494. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82495. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82496. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82497. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82498. * 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.
  82499. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82500. * Test :
  82501. * Is the cullable object bounding sphere center in the frustum ?
  82502. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82503. */
  82504. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82505. /**
  82506. * No billboard
  82507. */
  82508. static readonly BILLBOARDMODE_NONE: number;
  82509. /** Billboard on X axis */
  82510. static readonly BILLBOARDMODE_X: number;
  82511. /** Billboard on Y axis */
  82512. static readonly BILLBOARDMODE_Y: number;
  82513. /** Billboard on Z axis */
  82514. static readonly BILLBOARDMODE_Z: number;
  82515. /** Billboard on all axes */
  82516. static readonly BILLBOARDMODE_ALL: number;
  82517. private _facetData;
  82518. /**
  82519. * The culling strategy to use to check whether the mesh must be rendered or not.
  82520. * This value can be changed at any time and will be used on the next render mesh selection.
  82521. * The possible values are :
  82522. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82523. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82524. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82525. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82526. * Please read each static variable documentation to get details about the culling process.
  82527. * */
  82528. cullingStrategy: number;
  82529. /**
  82530. * Gets the number of facets in the mesh
  82531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82532. */
  82533. readonly facetNb: number;
  82534. /**
  82535. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82537. */
  82538. partitioningSubdivisions: number;
  82539. /**
  82540. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82541. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82543. */
  82544. partitioningBBoxRatio: number;
  82545. /**
  82546. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82547. * Works only for updatable meshes.
  82548. * Doesn't work with multi-materials
  82549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82550. */
  82551. mustDepthSortFacets: boolean;
  82552. /**
  82553. * The location (Vector3) where the facet depth sort must be computed from.
  82554. * By default, the active camera position.
  82555. * Used only when facet depth sort is enabled
  82556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82557. */
  82558. facetDepthSortFrom: Vector3;
  82559. /**
  82560. * gets a boolean indicating if facetData is enabled
  82561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82562. */
  82563. readonly isFacetDataEnabled: boolean;
  82564. /** @hidden */
  82565. _updateNonUniformScalingState(value: boolean): boolean;
  82566. /**
  82567. * An event triggered when this mesh collides with another one
  82568. */
  82569. onCollideObservable: Observable<AbstractMesh>;
  82570. private _onCollideObserver;
  82571. /** Set a function to call when this mesh collides with another one */
  82572. onCollide: () => void;
  82573. /**
  82574. * An event triggered when the collision's position changes
  82575. */
  82576. onCollisionPositionChangeObservable: Observable<Vector3>;
  82577. private _onCollisionPositionChangeObserver;
  82578. /** Set a function to call when the collision's position changes */
  82579. onCollisionPositionChange: () => void;
  82580. /**
  82581. * An event triggered when material is changed
  82582. */
  82583. onMaterialChangedObservable: Observable<AbstractMesh>;
  82584. /**
  82585. * Gets or sets the orientation for POV movement & rotation
  82586. */
  82587. definedFacingForward: boolean;
  82588. /** @hidden */
  82589. _occlusionQuery: Nullable<WebGLQuery>;
  82590. private _visibility;
  82591. /**
  82592. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82593. */
  82594. /**
  82595. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82596. */
  82597. visibility: number;
  82598. /** Gets or sets the alpha index used to sort transparent meshes
  82599. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82600. */
  82601. alphaIndex: number;
  82602. /**
  82603. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82604. */
  82605. isVisible: boolean;
  82606. /**
  82607. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82608. */
  82609. isPickable: boolean;
  82610. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82611. showSubMeshesBoundingBox: boolean;
  82612. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82613. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82614. */
  82615. isBlocker: boolean;
  82616. /**
  82617. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82618. */
  82619. enablePointerMoveEvents: boolean;
  82620. /**
  82621. * Specifies the rendering group id for this mesh (0 by default)
  82622. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82623. */
  82624. renderingGroupId: number;
  82625. private _material;
  82626. /** Gets or sets current material */
  82627. material: Nullable<Material>;
  82628. private _receiveShadows;
  82629. /**
  82630. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82631. * @see http://doc.babylonjs.com/babylon101/shadows
  82632. */
  82633. receiveShadows: boolean;
  82634. /** Defines color to use when rendering outline */
  82635. outlineColor: Color3;
  82636. /** Define width to use when rendering outline */
  82637. outlineWidth: number;
  82638. /** Defines color to use when rendering overlay */
  82639. overlayColor: Color3;
  82640. /** Defines alpha to use when rendering overlay */
  82641. overlayAlpha: number;
  82642. private _hasVertexAlpha;
  82643. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82644. hasVertexAlpha: boolean;
  82645. private _useVertexColors;
  82646. /** 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) */
  82647. useVertexColors: boolean;
  82648. private _computeBonesUsingShaders;
  82649. /**
  82650. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82651. */
  82652. computeBonesUsingShaders: boolean;
  82653. private _numBoneInfluencers;
  82654. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82655. numBoneInfluencers: number;
  82656. private _applyFog;
  82657. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82658. applyFog: boolean;
  82659. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82660. useOctreeForRenderingSelection: boolean;
  82661. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82662. useOctreeForPicking: boolean;
  82663. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82664. useOctreeForCollisions: boolean;
  82665. private _layerMask;
  82666. /**
  82667. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82668. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82669. */
  82670. layerMask: number;
  82671. /**
  82672. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82673. */
  82674. alwaysSelectAsActiveMesh: boolean;
  82675. /**
  82676. * Gets or sets the current action manager
  82677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82678. */
  82679. actionManager: Nullable<AbstractActionManager>;
  82680. private _checkCollisions;
  82681. private _collisionMask;
  82682. private _collisionGroup;
  82683. /**
  82684. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82686. */
  82687. ellipsoid: Vector3;
  82688. /**
  82689. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82690. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82691. */
  82692. ellipsoidOffset: Vector3;
  82693. private _collider;
  82694. private _oldPositionForCollisions;
  82695. private _diffPositionForCollisions;
  82696. /**
  82697. * Gets or sets a collision mask used to mask collisions (default is -1).
  82698. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82699. */
  82700. collisionMask: number;
  82701. /**
  82702. * Gets or sets the current collision group mask (-1 by default).
  82703. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82704. */
  82705. collisionGroup: number;
  82706. /**
  82707. * Defines edge width used when edgesRenderer is enabled
  82708. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82709. */
  82710. edgesWidth: number;
  82711. /**
  82712. * Defines edge color used when edgesRenderer is enabled
  82713. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82714. */
  82715. edgesColor: Color4;
  82716. /** @hidden */
  82717. _edgesRenderer: Nullable<IEdgesRenderer>;
  82718. /** @hidden */
  82719. _masterMesh: Nullable<AbstractMesh>;
  82720. /** @hidden */
  82721. _boundingInfo: Nullable<BoundingInfo>;
  82722. /** @hidden */
  82723. _renderId: number;
  82724. /**
  82725. * Gets or sets the list of subMeshes
  82726. * @see http://doc.babylonjs.com/how_to/multi_materials
  82727. */
  82728. subMeshes: SubMesh[];
  82729. /** @hidden */
  82730. _intersectionsInProgress: AbstractMesh[];
  82731. /** @hidden */
  82732. _unIndexed: boolean;
  82733. /** @hidden */
  82734. _lightSources: Light[];
  82735. /** @hidden */
  82736. readonly _positions: Nullable<Vector3[]>;
  82737. /** @hidden */
  82738. _waitingActions: any;
  82739. /** @hidden */
  82740. _waitingFreezeWorldMatrix: Nullable<boolean>;
  82741. private _skeleton;
  82742. /** @hidden */
  82743. _bonesTransformMatrices: Nullable<Float32Array>;
  82744. /**
  82745. * Gets or sets a skeleton to apply skining transformations
  82746. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82747. */
  82748. skeleton: Nullable<Skeleton>;
  82749. /**
  82750. * An event triggered when the mesh is rebuilt.
  82751. */
  82752. onRebuildObservable: Observable<AbstractMesh>;
  82753. /**
  82754. * Creates a new AbstractMesh
  82755. * @param name defines the name of the mesh
  82756. * @param scene defines the hosting scene
  82757. */
  82758. constructor(name: string, scene?: Nullable<Scene>);
  82759. /**
  82760. * Returns the string "AbstractMesh"
  82761. * @returns "AbstractMesh"
  82762. */
  82763. getClassName(): string;
  82764. /**
  82765. * Gets a string representation of the current mesh
  82766. * @param fullDetails defines a boolean indicating if full details must be included
  82767. * @returns a string representation of the current mesh
  82768. */
  82769. toString(fullDetails?: boolean): string;
  82770. /** @hidden */
  82771. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82772. /** @hidden */
  82773. _rebuild(): void;
  82774. /** @hidden */
  82775. _resyncLightSources(): void;
  82776. /** @hidden */
  82777. _resyncLighSource(light: Light): void;
  82778. /** @hidden */
  82779. _unBindEffect(): void;
  82780. /** @hidden */
  82781. _removeLightSource(light: Light): void;
  82782. private _markSubMeshesAsDirty;
  82783. /** @hidden */
  82784. _markSubMeshesAsLightDirty(): void;
  82785. /** @hidden */
  82786. _markSubMeshesAsAttributesDirty(): void;
  82787. /** @hidden */
  82788. _markSubMeshesAsMiscDirty(): void;
  82789. /**
  82790. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82791. */
  82792. scaling: Vector3;
  82793. /**
  82794. * Returns true if the mesh is blocked. Implemented by child classes
  82795. */
  82796. readonly isBlocked: boolean;
  82797. /**
  82798. * Returns the mesh itself by default. Implemented by child classes
  82799. * @param camera defines the camera to use to pick the right LOD level
  82800. * @returns the currentAbstractMesh
  82801. */
  82802. getLOD(camera: Camera): Nullable<AbstractMesh>;
  82803. /**
  82804. * Returns 0 by default. Implemented by child classes
  82805. * @returns an integer
  82806. */
  82807. getTotalVertices(): number;
  82808. /**
  82809. * Returns a positive integer : the total number of indices in this mesh geometry.
  82810. * @returns the numner of indices or zero if the mesh has no geometry.
  82811. */
  82812. getTotalIndices(): number;
  82813. /**
  82814. * Returns null by default. Implemented by child classes
  82815. * @returns null
  82816. */
  82817. getIndices(): Nullable<IndicesArray>;
  82818. /**
  82819. * Returns the array of the requested vertex data kind. Implemented by child classes
  82820. * @param kind defines the vertex data kind to use
  82821. * @returns null
  82822. */
  82823. getVerticesData(kind: string): Nullable<FloatArray>;
  82824. /**
  82825. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82826. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82827. * Note that a new underlying VertexBuffer object is created each call.
  82828. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82829. * @param kind defines vertex data kind:
  82830. * * VertexBuffer.PositionKind
  82831. * * VertexBuffer.UVKind
  82832. * * VertexBuffer.UV2Kind
  82833. * * VertexBuffer.UV3Kind
  82834. * * VertexBuffer.UV4Kind
  82835. * * VertexBuffer.UV5Kind
  82836. * * VertexBuffer.UV6Kind
  82837. * * VertexBuffer.ColorKind
  82838. * * VertexBuffer.MatricesIndicesKind
  82839. * * VertexBuffer.MatricesIndicesExtraKind
  82840. * * VertexBuffer.MatricesWeightsKind
  82841. * * VertexBuffer.MatricesWeightsExtraKind
  82842. * @param data defines the data source
  82843. * @param updatable defines if the data must be flagged as updatable (or static)
  82844. * @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
  82845. * @returns the current mesh
  82846. */
  82847. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  82848. /**
  82849. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82850. * If the mesh has no geometry, it is simply returned as it is.
  82851. * @param kind defines vertex data kind:
  82852. * * VertexBuffer.PositionKind
  82853. * * VertexBuffer.UVKind
  82854. * * VertexBuffer.UV2Kind
  82855. * * VertexBuffer.UV3Kind
  82856. * * VertexBuffer.UV4Kind
  82857. * * VertexBuffer.UV5Kind
  82858. * * VertexBuffer.UV6Kind
  82859. * * VertexBuffer.ColorKind
  82860. * * VertexBuffer.MatricesIndicesKind
  82861. * * VertexBuffer.MatricesIndicesExtraKind
  82862. * * VertexBuffer.MatricesWeightsKind
  82863. * * VertexBuffer.MatricesWeightsExtraKind
  82864. * @param data defines the data source
  82865. * @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
  82866. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82867. * @returns the current mesh
  82868. */
  82869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  82870. /**
  82871. * Sets the mesh indices,
  82872. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82873. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82874. * @param totalVertices Defines the total number of vertices
  82875. * @returns the current mesh
  82876. */
  82877. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  82878. /**
  82879. * Gets a boolean indicating if specific vertex data is present
  82880. * @param kind defines the vertex data kind to use
  82881. * @returns true is data kind is present
  82882. */
  82883. isVerticesDataPresent(kind: string): boolean;
  82884. /**
  82885. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82886. * @returns a BoundingInfo
  82887. */
  82888. getBoundingInfo(): BoundingInfo;
  82889. /**
  82890. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82891. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82892. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82893. * @returns the current mesh
  82894. */
  82895. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  82896. /**
  82897. * Overwrite the current bounding info
  82898. * @param boundingInfo defines the new bounding info
  82899. * @returns the current mesh
  82900. */
  82901. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  82902. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82903. readonly useBones: boolean;
  82904. /** @hidden */
  82905. _preActivate(): void;
  82906. /** @hidden */
  82907. _preActivateForIntermediateRendering(renderId: number): void;
  82908. /** @hidden */
  82909. _activate(renderId: number): void;
  82910. /**
  82911. * Gets the current world matrix
  82912. * @returns a Matrix
  82913. */
  82914. getWorldMatrix(): Matrix;
  82915. /** @hidden */
  82916. _getWorldMatrixDeterminant(): number;
  82917. /**
  82918. * Perform relative position change from the point of view of behind the front of the mesh.
  82919. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82920. * Supports definition of mesh facing forward or backward
  82921. * @param amountRight defines the distance on the right axis
  82922. * @param amountUp defines the distance on the up axis
  82923. * @param amountForward defines the distance on the forward axis
  82924. * @returns the current mesh
  82925. */
  82926. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  82927. /**
  82928. * Calculate relative position change from the point of view of behind the front of the mesh.
  82929. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82930. * Supports definition of mesh facing forward or backward
  82931. * @param amountRight defines the distance on the right axis
  82932. * @param amountUp defines the distance on the up axis
  82933. * @param amountForward defines the distance on the forward axis
  82934. * @returns the new displacement vector
  82935. */
  82936. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  82937. /**
  82938. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82939. * Supports definition of mesh facing forward or backward
  82940. * @param flipBack defines the flip
  82941. * @param twirlClockwise defines the twirl
  82942. * @param tiltRight defines the tilt
  82943. * @returns the current mesh
  82944. */
  82945. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  82946. /**
  82947. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82948. * Supports definition of mesh facing forward or backward.
  82949. * @param flipBack defines the flip
  82950. * @param twirlClockwise defines the twirl
  82951. * @param tiltRight defines the tilt
  82952. * @returns the new rotation vector
  82953. */
  82954. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  82955. /**
  82956. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82957. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82958. * @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
  82959. * @returns the new bounding vectors
  82960. */
  82961. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  82962. min: Vector3;
  82963. max: Vector3;
  82964. };
  82965. /**
  82966. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82967. * This means the mesh underlying bounding box and sphere are recomputed.
  82968. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82969. * @returns the current mesh
  82970. */
  82971. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  82972. /** @hidden */
  82973. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  82974. /** @hidden */
  82975. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  82976. /** @hidden */
  82977. _updateBoundingInfo(): AbstractMesh;
  82978. /** @hidden */
  82979. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  82980. /** @hidden */
  82981. protected _afterComputeWorldMatrix(): void;
  82982. /** @hidden */
  82983. readonly _effectiveMesh: AbstractMesh;
  82984. /**
  82985. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82986. * A mesh is in the frustum if its bounding box intersects the frustum
  82987. * @param frustumPlanes defines the frustum to test
  82988. * @returns true if the mesh is in the frustum planes
  82989. */
  82990. isInFrustum(frustumPlanes: Plane[]): boolean;
  82991. /**
  82992. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  82993. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  82994. * @param frustumPlanes defines the frustum to test
  82995. * @returns true if the mesh is completely in the frustum planes
  82996. */
  82997. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82998. /**
  82999. * True if the mesh intersects another mesh or a SolidParticle object
  83000. * @param mesh defines a target mesh or SolidParticle to test
  83001. * @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)
  83002. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83003. * @returns true if there is an intersection
  83004. */
  83005. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83006. /**
  83007. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83008. * @param point defines the point to test
  83009. * @returns true if there is an intersection
  83010. */
  83011. intersectsPoint(point: Vector3): boolean;
  83012. /**
  83013. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83015. */
  83016. checkCollisions: boolean;
  83017. /**
  83018. * Gets Collider object used to compute collisions (not physics)
  83019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83020. */
  83021. readonly collider: Collider;
  83022. /**
  83023. * Move the mesh using collision engine
  83024. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83025. * @param displacement defines the requested displacement vector
  83026. * @returns the current mesh
  83027. */
  83028. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83029. private _onCollisionPositionChange;
  83030. /** @hidden */
  83031. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83032. /** @hidden */
  83033. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83034. /** @hidden */
  83035. _checkCollision(collider: Collider): AbstractMesh;
  83036. /** @hidden */
  83037. _generatePointsArray(): boolean;
  83038. /**
  83039. * Checks if the passed Ray intersects with the mesh
  83040. * @param ray defines the ray to use
  83041. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83042. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83043. * @returns the picking info
  83044. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83045. */
  83046. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83047. /**
  83048. * Clones the current mesh
  83049. * @param name defines the mesh name
  83050. * @param newParent defines the new mesh parent
  83051. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83052. * @returns the new mesh
  83053. */
  83054. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83055. /**
  83056. * Disposes all the submeshes of the current meshnp
  83057. * @returns the current mesh
  83058. */
  83059. releaseSubMeshes(): AbstractMesh;
  83060. /**
  83061. * Releases resources associated with this abstract mesh.
  83062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83064. */
  83065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83066. /**
  83067. * Adds the passed mesh as a child to the current mesh
  83068. * @param mesh defines the child mesh
  83069. * @returns the current mesh
  83070. */
  83071. addChild(mesh: AbstractMesh): AbstractMesh;
  83072. /**
  83073. * Removes the passed mesh from the current mesh children list
  83074. * @param mesh defines the child mesh
  83075. * @returns the current mesh
  83076. */
  83077. removeChild(mesh: AbstractMesh): AbstractMesh;
  83078. /** @hidden */
  83079. private _initFacetData;
  83080. /**
  83081. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83082. * This method can be called within the render loop.
  83083. * 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
  83084. * @returns the current mesh
  83085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83086. */
  83087. updateFacetData(): AbstractMesh;
  83088. /**
  83089. * Returns the facetLocalNormals array.
  83090. * The normals are expressed in the mesh local spac
  83091. * @returns an array of Vector3
  83092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83093. */
  83094. getFacetLocalNormals(): Vector3[];
  83095. /**
  83096. * Returns the facetLocalPositions array.
  83097. * The facet positions are expressed in the mesh local space
  83098. * @returns an array of Vector3
  83099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83100. */
  83101. getFacetLocalPositions(): Vector3[];
  83102. /**
  83103. * Returns the facetLocalPartioning array
  83104. * @returns an array of array of numbers
  83105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83106. */
  83107. getFacetLocalPartitioning(): number[][];
  83108. /**
  83109. * Returns the i-th facet position in the world system.
  83110. * This method allocates a new Vector3 per call
  83111. * @param i defines the facet index
  83112. * @returns a new Vector3
  83113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83114. */
  83115. getFacetPosition(i: number): Vector3;
  83116. /**
  83117. * Sets the reference Vector3 with the i-th facet position in the world system
  83118. * @param i defines the facet index
  83119. * @param ref defines the target vector
  83120. * @returns the current mesh
  83121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83122. */
  83123. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83124. /**
  83125. * Returns the i-th facet normal in the world system.
  83126. * This method allocates a new Vector3 per call
  83127. * @param i defines the facet index
  83128. * @returns a new Vector3
  83129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83130. */
  83131. getFacetNormal(i: number): Vector3;
  83132. /**
  83133. * Sets the reference Vector3 with the i-th facet normal in the world system
  83134. * @param i defines the facet index
  83135. * @param ref defines the target vector
  83136. * @returns the current mesh
  83137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83138. */
  83139. getFacetNormalToRef(i: number, ref: Vector3): this;
  83140. /**
  83141. * 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)
  83142. * @param x defines x coordinate
  83143. * @param y defines y coordinate
  83144. * @param z defines z coordinate
  83145. * @returns the array of facet indexes
  83146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83147. */
  83148. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83149. /**
  83150. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83151. * @param projected sets as the (x,y,z) world projection on the facet
  83152. * @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
  83153. * @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
  83154. * @param x defines x coordinate
  83155. * @param y defines y coordinate
  83156. * @param z defines z coordinate
  83157. * @returns the face index if found (or null instead)
  83158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83159. */
  83160. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83161. /**
  83162. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83163. * @param projected sets as the (x,y,z) local projection on the facet
  83164. * @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
  83165. * @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
  83166. * @param x defines x coordinate
  83167. * @param y defines y coordinate
  83168. * @param z defines z coordinate
  83169. * @returns the face index if found (or null instead)
  83170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83171. */
  83172. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83173. /**
  83174. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83175. * @returns the parameters
  83176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83177. */
  83178. getFacetDataParameters(): any;
  83179. /**
  83180. * Disables the feature FacetData and frees the related memory
  83181. * @returns the current mesh
  83182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83183. */
  83184. disableFacetData(): AbstractMesh;
  83185. /**
  83186. * Updates the AbstractMesh indices array
  83187. * @param indices defines the data source
  83188. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83189. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  83190. * @returns the current mesh
  83191. */
  83192. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83193. /**
  83194. * Creates new normals data for the mesh
  83195. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83196. * @returns the current mesh
  83197. */
  83198. createNormals(updatable: boolean): AbstractMesh;
  83199. /**
  83200. * Align the mesh with a normal
  83201. * @param normal defines the normal to use
  83202. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83203. * @returns the current mesh
  83204. */
  83205. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83206. /** @hidden */
  83207. _checkOcclusionQuery(): boolean;
  83208. }
  83209. }
  83210. declare module BABYLON {
  83211. /**
  83212. * Interface used to define ActionEvent
  83213. */
  83214. export interface IActionEvent {
  83215. /** The mesh or sprite that triggered the action */
  83216. source: any;
  83217. /** The X mouse cursor position at the time of the event */
  83218. pointerX: number;
  83219. /** The Y mouse cursor position at the time of the event */
  83220. pointerY: number;
  83221. /** The mesh that is currently pointed at (can be null) */
  83222. meshUnderPointer: Nullable<AbstractMesh>;
  83223. /** the original (browser) event that triggered the ActionEvent */
  83224. sourceEvent?: any;
  83225. /** additional data for the event */
  83226. additionalData?: any;
  83227. }
  83228. /**
  83229. * ActionEvent is the event being sent when an action is triggered.
  83230. */
  83231. export class ActionEvent implements IActionEvent {
  83232. /** The mesh or sprite that triggered the action */
  83233. source: any;
  83234. /** The X mouse cursor position at the time of the event */
  83235. pointerX: number;
  83236. /** The Y mouse cursor position at the time of the event */
  83237. pointerY: number;
  83238. /** The mesh that is currently pointed at (can be null) */
  83239. meshUnderPointer: Nullable<AbstractMesh>;
  83240. /** the original (browser) event that triggered the ActionEvent */
  83241. sourceEvent?: any;
  83242. /** additional data for the event */
  83243. additionalData?: any;
  83244. /**
  83245. * Creates a new ActionEvent
  83246. * @param source The mesh or sprite that triggered the action
  83247. * @param pointerX The X mouse cursor position at the time of the event
  83248. * @param pointerY The Y mouse cursor position at the time of the event
  83249. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83250. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83251. * @param additionalData additional data for the event
  83252. */
  83253. constructor(
  83254. /** The mesh or sprite that triggered the action */
  83255. source: any,
  83256. /** The X mouse cursor position at the time of the event */
  83257. pointerX: number,
  83258. /** The Y mouse cursor position at the time of the event */
  83259. pointerY: number,
  83260. /** The mesh that is currently pointed at (can be null) */
  83261. meshUnderPointer: Nullable<AbstractMesh>,
  83262. /** the original (browser) event that triggered the ActionEvent */
  83263. sourceEvent?: any,
  83264. /** additional data for the event */
  83265. additionalData?: any);
  83266. /**
  83267. * Helper function to auto-create an ActionEvent from a source mesh.
  83268. * @param source The source mesh that triggered the event
  83269. * @param evt The original (browser) event
  83270. * @param additionalData additional data for the event
  83271. * @returns the new ActionEvent
  83272. */
  83273. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  83274. /**
  83275. * Helper function to auto-create an ActionEvent from a source sprite
  83276. * @param source The source sprite that triggered the event
  83277. * @param scene Scene associated with the sprite
  83278. * @param evt The original (browser) event
  83279. * @param additionalData additional data for the event
  83280. * @returns the new ActionEvent
  83281. */
  83282. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  83283. /**
  83284. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  83285. * @param scene the scene where the event occurred
  83286. * @param evt The original (browser) event
  83287. * @returns the new ActionEvent
  83288. */
  83289. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  83290. /**
  83291. * Helper function to auto-create an ActionEvent from a primitive
  83292. * @param prim defines the target primitive
  83293. * @param pointerPos defines the pointer position
  83294. * @param evt The original (browser) event
  83295. * @param additionalData additional data for the event
  83296. * @returns the new ActionEvent
  83297. */
  83298. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  83299. }
  83300. }
  83301. declare module BABYLON {
  83302. /**
  83303. * Abstract class used to decouple action Manager from scene and meshes.
  83304. * Do not instantiate.
  83305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83306. */
  83307. export abstract class AbstractActionManager implements IDisposable {
  83308. /** Gets the list of active triggers */
  83309. static Triggers: {
  83310. [key: string]: number;
  83311. };
  83312. /** Gets the cursor to use when hovering items */
  83313. hoverCursor: string;
  83314. /** Gets the list of actions */
  83315. actions: IAction[];
  83316. /**
  83317. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  83318. */
  83319. isRecursive: boolean;
  83320. /**
  83321. * Releases all associated resources
  83322. */
  83323. abstract dispose(): void;
  83324. /**
  83325. * Does this action manager has pointer triggers
  83326. */
  83327. abstract readonly hasPointerTriggers: boolean;
  83328. /**
  83329. * Does this action manager has pick triggers
  83330. */
  83331. abstract readonly hasPickTriggers: boolean;
  83332. /**
  83333. * Process a specific trigger
  83334. * @param trigger defines the trigger to process
  83335. * @param evt defines the event details to be processed
  83336. */
  83337. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  83338. /**
  83339. * Does this action manager handles actions of any of the given triggers
  83340. * @param triggers defines the triggers to be tested
  83341. * @return a boolean indicating whether one (or more) of the triggers is handled
  83342. */
  83343. abstract hasSpecificTriggers(triggers: number[]): boolean;
  83344. /**
  83345. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83346. * speed.
  83347. * @param triggerA defines the trigger to be tested
  83348. * @param triggerB defines the trigger to be tested
  83349. * @return a boolean indicating whether one (or more) of the triggers is handled
  83350. */
  83351. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83352. /**
  83353. * Does this action manager handles actions of a given trigger
  83354. * @param trigger defines the trigger to be tested
  83355. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83356. * @return whether the trigger is handled
  83357. */
  83358. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83359. /**
  83360. * Serialize this manager to a JSON object
  83361. * @param name defines the property name to store this manager
  83362. * @returns a JSON representation of this manager
  83363. */
  83364. abstract serialize(name: string): any;
  83365. /**
  83366. * Registers an action to this action manager
  83367. * @param action defines the action to be registered
  83368. * @return the action amended (prepared) after registration
  83369. */
  83370. abstract registerAction(action: IAction): Nullable<IAction>;
  83371. /**
  83372. * Unregisters an action to this action manager
  83373. * @param action defines the action to be unregistered
  83374. * @return a boolean indicating whether the action has been unregistered
  83375. */
  83376. abstract unregisterAction(action: IAction): Boolean;
  83377. /**
  83378. * Does exist one action manager with at least one trigger
  83379. **/
  83380. static readonly HasTriggers: boolean;
  83381. /**
  83382. * Does exist one action manager with at least one pick trigger
  83383. **/
  83384. static readonly HasPickTriggers: boolean;
  83385. /**
  83386. * Does exist one action manager that handles actions of a given trigger
  83387. * @param trigger defines the trigger to be tested
  83388. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  83389. **/
  83390. static HasSpecificTrigger(trigger: number): boolean;
  83391. }
  83392. }
  83393. declare module BABYLON {
  83394. /**
  83395. * Defines how a node can be built from a string name.
  83396. */
  83397. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  83398. /**
  83399. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  83400. */
  83401. export class Node implements IBehaviorAware<Node> {
  83402. /** @hidden */
  83403. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  83404. private static _NodeConstructors;
  83405. /**
  83406. * Add a new node constructor
  83407. * @param type defines the type name of the node to construct
  83408. * @param constructorFunc defines the constructor function
  83409. */
  83410. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  83411. /**
  83412. * Returns a node constructor based on type name
  83413. * @param type defines the type name
  83414. * @param name defines the new node name
  83415. * @param scene defines the hosting scene
  83416. * @param options defines optional options to transmit to constructors
  83417. * @returns the new constructor or null
  83418. */
  83419. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  83420. /**
  83421. * Gets or sets the name of the node
  83422. */
  83423. name: string;
  83424. /**
  83425. * Gets or sets the id of the node
  83426. */
  83427. id: string;
  83428. /**
  83429. * Gets or sets the unique id of the node
  83430. */
  83431. uniqueId: number;
  83432. /**
  83433. * Gets or sets a string used to store user defined state for the node
  83434. */
  83435. state: string;
  83436. /**
  83437. * Gets or sets an object used to store user defined information for the node
  83438. */
  83439. metadata: any;
  83440. /**
  83441. * For internal use only. Please do not use.
  83442. */
  83443. reservedDataStore: any;
  83444. /**
  83445. * List of inspectable custom properties (used by the Inspector)
  83446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83447. */
  83448. inspectableCustomProperties: IInspectable[];
  83449. /**
  83450. * Gets or sets a boolean used to define if the node must be serialized
  83451. */
  83452. doNotSerialize: boolean;
  83453. /** @hidden */
  83454. _isDisposed: boolean;
  83455. /**
  83456. * Gets a list of Animations associated with the node
  83457. */
  83458. animations: Animation[];
  83459. protected _ranges: {
  83460. [name: string]: Nullable<AnimationRange>;
  83461. };
  83462. /**
  83463. * Callback raised when the node is ready to be used
  83464. */
  83465. onReady: (node: Node) => void;
  83466. private _isEnabled;
  83467. private _isParentEnabled;
  83468. private _isReady;
  83469. /** @hidden */
  83470. _currentRenderId: number;
  83471. private _parentRenderId;
  83472. protected _childRenderId: number;
  83473. /** @hidden */
  83474. _waitingParentId: Nullable<string>;
  83475. /** @hidden */
  83476. _scene: Scene;
  83477. /** @hidden */
  83478. _cache: any;
  83479. private _parentNode;
  83480. private _children;
  83481. /** @hidden */
  83482. _worldMatrix: Matrix;
  83483. /** @hidden */
  83484. _worldMatrixDeterminant: number;
  83485. /** @hidden */
  83486. private _sceneRootNodesIndex;
  83487. /**
  83488. * Gets a boolean indicating if the node has been disposed
  83489. * @returns true if the node was disposed
  83490. */
  83491. isDisposed(): boolean;
  83492. /**
  83493. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83494. * @see https://doc.babylonjs.com/how_to/parenting
  83495. */
  83496. parent: Nullable<Node>;
  83497. private addToSceneRootNodes;
  83498. private removeFromSceneRootNodes;
  83499. private _animationPropertiesOverride;
  83500. /**
  83501. * Gets or sets the animation properties override
  83502. */
  83503. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83504. /**
  83505. * Gets a string idenfifying the name of the class
  83506. * @returns "Node" string
  83507. */
  83508. getClassName(): string;
  83509. /** @hidden */
  83510. readonly _isNode: boolean;
  83511. /**
  83512. * An event triggered when the mesh is disposed
  83513. */
  83514. onDisposeObservable: Observable<Node>;
  83515. private _onDisposeObserver;
  83516. /**
  83517. * Sets a callback that will be raised when the node will be disposed
  83518. */
  83519. onDispose: () => void;
  83520. /**
  83521. * Creates a new Node
  83522. * @param name the name and id to be given to this node
  83523. * @param scene the scene this node will be added to
  83524. * @param addToRootNodes the node will be added to scene.rootNodes
  83525. */
  83526. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83527. /**
  83528. * Gets the scene of the node
  83529. * @returns a scene
  83530. */
  83531. getScene(): Scene;
  83532. /**
  83533. * Gets the engine of the node
  83534. * @returns a Engine
  83535. */
  83536. getEngine(): Engine;
  83537. private _behaviors;
  83538. /**
  83539. * Attach a behavior to the node
  83540. * @see http://doc.babylonjs.com/features/behaviour
  83541. * @param behavior defines the behavior to attach
  83542. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83543. * @returns the current Node
  83544. */
  83545. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83546. /**
  83547. * Remove an attached behavior
  83548. * @see http://doc.babylonjs.com/features/behaviour
  83549. * @param behavior defines the behavior to attach
  83550. * @returns the current Node
  83551. */
  83552. removeBehavior(behavior: Behavior<Node>): Node;
  83553. /**
  83554. * Gets the list of attached behaviors
  83555. * @see http://doc.babylonjs.com/features/behaviour
  83556. */
  83557. readonly behaviors: Behavior<Node>[];
  83558. /**
  83559. * Gets an attached behavior by name
  83560. * @param name defines the name of the behavior to look for
  83561. * @see http://doc.babylonjs.com/features/behaviour
  83562. * @returns null if behavior was not found else the requested behavior
  83563. */
  83564. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83565. /**
  83566. * Returns the latest update of the World matrix
  83567. * @returns a Matrix
  83568. */
  83569. getWorldMatrix(): Matrix;
  83570. /** @hidden */
  83571. _getWorldMatrixDeterminant(): number;
  83572. /**
  83573. * Returns directly the latest state of the mesh World matrix.
  83574. * A Matrix is returned.
  83575. */
  83576. readonly worldMatrixFromCache: Matrix;
  83577. /** @hidden */
  83578. _initCache(): void;
  83579. /** @hidden */
  83580. updateCache(force?: boolean): void;
  83581. /** @hidden */
  83582. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83583. /** @hidden */
  83584. _updateCache(ignoreParentClass?: boolean): void;
  83585. /** @hidden */
  83586. _isSynchronized(): boolean;
  83587. /** @hidden */
  83588. _markSyncedWithParent(): void;
  83589. /** @hidden */
  83590. isSynchronizedWithParent(): boolean;
  83591. /** @hidden */
  83592. isSynchronized(): boolean;
  83593. /**
  83594. * Is this node ready to be used/rendered
  83595. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83596. * @return true if the node is ready
  83597. */
  83598. isReady(completeCheck?: boolean): boolean;
  83599. /**
  83600. * Is this node enabled?
  83601. * 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
  83602. * @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
  83603. * @return whether this node (and its parent) is enabled
  83604. */
  83605. isEnabled(checkAncestors?: boolean): boolean;
  83606. /** @hidden */
  83607. protected _syncParentEnabledState(): void;
  83608. /**
  83609. * Set the enabled state of this node
  83610. * @param value defines the new enabled state
  83611. */
  83612. setEnabled(value: boolean): void;
  83613. /**
  83614. * Is this node a descendant of the given node?
  83615. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  83616. * @param ancestor defines the parent node to inspect
  83617. * @returns a boolean indicating if this node is a descendant of the given node
  83618. */
  83619. isDescendantOf(ancestor: Node): boolean;
  83620. /** @hidden */
  83621. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  83622. /**
  83623. * Will return all nodes that have this node as ascendant
  83624. * @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
  83625. * @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
  83626. * @return all children nodes of all types
  83627. */
  83628. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  83629. /**
  83630. * Get all child-meshes of this node
  83631. * @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)
  83632. * @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
  83633. * @returns an array of AbstractMesh
  83634. */
  83635. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  83636. /**
  83637. * Get all direct children of this node
  83638. * @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
  83639. * @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)
  83640. * @returns an array of Node
  83641. */
  83642. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  83643. /** @hidden */
  83644. _setReady(state: boolean): void;
  83645. /**
  83646. * Get an animation by name
  83647. * @param name defines the name of the animation to look for
  83648. * @returns null if not found else the requested animation
  83649. */
  83650. getAnimationByName(name: string): Nullable<Animation>;
  83651. /**
  83652. * Creates an animation range for this node
  83653. * @param name defines the name of the range
  83654. * @param from defines the starting key
  83655. * @param to defines the end key
  83656. */
  83657. createAnimationRange(name: string, from: number, to: number): void;
  83658. /**
  83659. * Delete a specific animation range
  83660. * @param name defines the name of the range to delete
  83661. * @param deleteFrames defines if animation frames from the range must be deleted as well
  83662. */
  83663. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83664. /**
  83665. * Get an animation range by name
  83666. * @param name defines the name of the animation range to look for
  83667. * @returns null if not found else the requested animation range
  83668. */
  83669. getAnimationRange(name: string): Nullable<AnimationRange>;
  83670. /**
  83671. * Gets the list of all animation ranges defined on this node
  83672. * @returns an array
  83673. */
  83674. getAnimationRanges(): Nullable<AnimationRange>[];
  83675. /**
  83676. * Will start the animation sequence
  83677. * @param name defines the range frames for animation sequence
  83678. * @param loop defines if the animation should loop (false by default)
  83679. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  83680. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  83681. * @returns the object created for this animation. If range does not exist, it will return null
  83682. */
  83683. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83684. /**
  83685. * Serialize animation ranges into a JSON compatible object
  83686. * @returns serialization object
  83687. */
  83688. serializeAnimationRanges(): any;
  83689. /**
  83690. * Computes the world matrix of the node
  83691. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83692. * @returns the world matrix
  83693. */
  83694. computeWorldMatrix(force?: boolean): Matrix;
  83695. /**
  83696. * Releases resources associated with this node.
  83697. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83698. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83699. */
  83700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83701. /**
  83702. * Parse animation range data from a serialization object and store them into a given node
  83703. * @param node defines where to store the animation ranges
  83704. * @param parsedNode defines the serialization object to read data from
  83705. * @param scene defines the hosting scene
  83706. */
  83707. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  83708. }
  83709. }
  83710. declare module BABYLON {
  83711. /**
  83712. * Class used to store any kind of animation
  83713. */
  83714. export class Animation {
  83715. /**Name of the animation */
  83716. name: string;
  83717. /**Property to animate */
  83718. targetProperty: string;
  83719. /**The frames per second of the animation */
  83720. framePerSecond: number;
  83721. /**The data type of the animation */
  83722. dataType: number;
  83723. /**The loop mode of the animation */
  83724. loopMode?: number | undefined;
  83725. /**Specifies if blending should be enabled */
  83726. enableBlending?: boolean | undefined;
  83727. /**
  83728. * Use matrix interpolation instead of using direct key value when animating matrices
  83729. */
  83730. static AllowMatricesInterpolation: boolean;
  83731. /**
  83732. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  83733. */
  83734. static AllowMatrixDecomposeForInterpolation: boolean;
  83735. /**
  83736. * Stores the key frames of the animation
  83737. */
  83738. private _keys;
  83739. /**
  83740. * Stores the easing function of the animation
  83741. */
  83742. private _easingFunction;
  83743. /**
  83744. * @hidden Internal use only
  83745. */
  83746. _runtimeAnimations: RuntimeAnimation[];
  83747. /**
  83748. * The set of event that will be linked to this animation
  83749. */
  83750. private _events;
  83751. /**
  83752. * Stores an array of target property paths
  83753. */
  83754. targetPropertyPath: string[];
  83755. /**
  83756. * Stores the blending speed of the animation
  83757. */
  83758. blendingSpeed: number;
  83759. /**
  83760. * Stores the animation ranges for the animation
  83761. */
  83762. private _ranges;
  83763. /**
  83764. * @hidden Internal use
  83765. */
  83766. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  83767. /**
  83768. * Sets up an animation
  83769. * @param property The property to animate
  83770. * @param animationType The animation type to apply
  83771. * @param framePerSecond The frames per second of the animation
  83772. * @param easingFunction The easing function used in the animation
  83773. * @returns The created animation
  83774. */
  83775. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  83776. /**
  83777. * Create and start an animation on a node
  83778. * @param name defines the name of the global animation that will be run on all nodes
  83779. * @param node defines the root node where the animation will take place
  83780. * @param targetProperty defines property to animate
  83781. * @param framePerSecond defines the number of frame per second yo use
  83782. * @param totalFrame defines the number of frames in total
  83783. * @param from defines the initial value
  83784. * @param to defines the final value
  83785. * @param loopMode defines which loop mode you want to use (off by default)
  83786. * @param easingFunction defines the easing function to use (linear by default)
  83787. * @param onAnimationEnd defines the callback to call when animation end
  83788. * @returns the animatable created for this animation
  83789. */
  83790. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83791. /**
  83792. * Create and start an animation on a node and its descendants
  83793. * @param name defines the name of the global animation that will be run on all nodes
  83794. * @param node defines the root node where the animation will take place
  83795. * @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
  83796. * @param targetProperty defines property to animate
  83797. * @param framePerSecond defines the number of frame per second to use
  83798. * @param totalFrame defines the number of frames in total
  83799. * @param from defines the initial value
  83800. * @param to defines the final value
  83801. * @param loopMode defines which loop mode you want to use (off by default)
  83802. * @param easingFunction defines the easing function to use (linear by default)
  83803. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83804. * @returns the list of animatables created for all nodes
  83805. * @example https://www.babylonjs-playground.com/#MH0VLI
  83806. */
  83807. 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[]>;
  83808. /**
  83809. * Creates a new animation, merges it with the existing animations and starts it
  83810. * @param name Name of the animation
  83811. * @param node Node which contains the scene that begins the animations
  83812. * @param targetProperty Specifies which property to animate
  83813. * @param framePerSecond The frames per second of the animation
  83814. * @param totalFrame The total number of frames
  83815. * @param from The frame at the beginning of the animation
  83816. * @param to The frame at the end of the animation
  83817. * @param loopMode Specifies the loop mode of the animation
  83818. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  83819. * @param onAnimationEnd Callback to run once the animation is complete
  83820. * @returns Nullable animation
  83821. */
  83822. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83823. /**
  83824. * Transition property of an host to the target Value
  83825. * @param property The property to transition
  83826. * @param targetValue The target Value of the property
  83827. * @param host The object where the property to animate belongs
  83828. * @param scene Scene used to run the animation
  83829. * @param frameRate Framerate (in frame/s) to use
  83830. * @param transition The transition type we want to use
  83831. * @param duration The duration of the animation, in milliseconds
  83832. * @param onAnimationEnd Callback trigger at the end of the animation
  83833. * @returns Nullable animation
  83834. */
  83835. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  83836. /**
  83837. * Return the array of runtime animations currently using this animation
  83838. */
  83839. readonly runtimeAnimations: RuntimeAnimation[];
  83840. /**
  83841. * Specifies if any of the runtime animations are currently running
  83842. */
  83843. readonly hasRunningRuntimeAnimations: boolean;
  83844. /**
  83845. * Initializes the animation
  83846. * @param name Name of the animation
  83847. * @param targetProperty Property to animate
  83848. * @param framePerSecond The frames per second of the animation
  83849. * @param dataType The data type of the animation
  83850. * @param loopMode The loop mode of the animation
  83851. * @param enableBlending Specifies if blending should be enabled
  83852. */
  83853. constructor(
  83854. /**Name of the animation */
  83855. name: string,
  83856. /**Property to animate */
  83857. targetProperty: string,
  83858. /**The frames per second of the animation */
  83859. framePerSecond: number,
  83860. /**The data type of the animation */
  83861. dataType: number,
  83862. /**The loop mode of the animation */
  83863. loopMode?: number | undefined,
  83864. /**Specifies if blending should be enabled */
  83865. enableBlending?: boolean | undefined);
  83866. /**
  83867. * Converts the animation to a string
  83868. * @param fullDetails support for multiple levels of logging within scene loading
  83869. * @returns String form of the animation
  83870. */
  83871. toString(fullDetails?: boolean): string;
  83872. /**
  83873. * Add an event to this animation
  83874. * @param event Event to add
  83875. */
  83876. addEvent(event: AnimationEvent): void;
  83877. /**
  83878. * Remove all events found at the given frame
  83879. * @param frame The frame to remove events from
  83880. */
  83881. removeEvents(frame: number): void;
  83882. /**
  83883. * Retrieves all the events from the animation
  83884. * @returns Events from the animation
  83885. */
  83886. getEvents(): AnimationEvent[];
  83887. /**
  83888. * Creates an animation range
  83889. * @param name Name of the animation range
  83890. * @param from Starting frame of the animation range
  83891. * @param to Ending frame of the animation
  83892. */
  83893. createRange(name: string, from: number, to: number): void;
  83894. /**
  83895. * Deletes an animation range by name
  83896. * @param name Name of the animation range to delete
  83897. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  83898. */
  83899. deleteRange(name: string, deleteFrames?: boolean): void;
  83900. /**
  83901. * Gets the animation range by name, or null if not defined
  83902. * @param name Name of the animation range
  83903. * @returns Nullable animation range
  83904. */
  83905. getRange(name: string): Nullable<AnimationRange>;
  83906. /**
  83907. * Gets the key frames from the animation
  83908. * @returns The key frames of the animation
  83909. */
  83910. getKeys(): Array<IAnimationKey>;
  83911. /**
  83912. * Gets the highest frame rate of the animation
  83913. * @returns Highest frame rate of the animation
  83914. */
  83915. getHighestFrame(): number;
  83916. /**
  83917. * Gets the easing function of the animation
  83918. * @returns Easing function of the animation
  83919. */
  83920. getEasingFunction(): IEasingFunction;
  83921. /**
  83922. * Sets the easing function of the animation
  83923. * @param easingFunction A custom mathematical formula for animation
  83924. */
  83925. setEasingFunction(easingFunction: EasingFunction): void;
  83926. /**
  83927. * Interpolates a scalar linearly
  83928. * @param startValue Start value of the animation curve
  83929. * @param endValue End value of the animation curve
  83930. * @param gradient Scalar amount to interpolate
  83931. * @returns Interpolated scalar value
  83932. */
  83933. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  83934. /**
  83935. * Interpolates a scalar cubically
  83936. * @param startValue Start value of the animation curve
  83937. * @param outTangent End tangent of the animation
  83938. * @param endValue End value of the animation curve
  83939. * @param inTangent Start tangent of the animation curve
  83940. * @param gradient Scalar amount to interpolate
  83941. * @returns Interpolated scalar value
  83942. */
  83943. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  83944. /**
  83945. * Interpolates a quaternion using a spherical linear interpolation
  83946. * @param startValue Start value of the animation curve
  83947. * @param endValue End value of the animation curve
  83948. * @param gradient Scalar amount to interpolate
  83949. * @returns Interpolated quaternion value
  83950. */
  83951. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  83952. /**
  83953. * Interpolates a quaternion cubically
  83954. * @param startValue Start value of the animation curve
  83955. * @param outTangent End tangent of the animation curve
  83956. * @param endValue End value of the animation curve
  83957. * @param inTangent Start tangent of the animation curve
  83958. * @param gradient Scalar amount to interpolate
  83959. * @returns Interpolated quaternion value
  83960. */
  83961. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  83962. /**
  83963. * Interpolates a Vector3 linearl
  83964. * @param startValue Start value of the animation curve
  83965. * @param endValue End value of the animation curve
  83966. * @param gradient Scalar amount to interpolate
  83967. * @returns Interpolated scalar value
  83968. */
  83969. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  83970. /**
  83971. * Interpolates a Vector3 cubically
  83972. * @param startValue Start value of the animation curve
  83973. * @param outTangent End tangent of the animation
  83974. * @param endValue End value of the animation curve
  83975. * @param inTangent Start tangent of the animation curve
  83976. * @param gradient Scalar amount to interpolate
  83977. * @returns InterpolatedVector3 value
  83978. */
  83979. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  83980. /**
  83981. * Interpolates a Vector2 linearly
  83982. * @param startValue Start value of the animation curve
  83983. * @param endValue End value of the animation curve
  83984. * @param gradient Scalar amount to interpolate
  83985. * @returns Interpolated Vector2 value
  83986. */
  83987. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  83988. /**
  83989. * Interpolates a Vector2 cubically
  83990. * @param startValue Start value of the animation curve
  83991. * @param outTangent End tangent of the animation
  83992. * @param endValue End value of the animation curve
  83993. * @param inTangent Start tangent of the animation curve
  83994. * @param gradient Scalar amount to interpolate
  83995. * @returns Interpolated Vector2 value
  83996. */
  83997. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  83998. /**
  83999. * Interpolates a size linearly
  84000. * @param startValue Start value of the animation curve
  84001. * @param endValue End value of the animation curve
  84002. * @param gradient Scalar amount to interpolate
  84003. * @returns Interpolated Size value
  84004. */
  84005. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84006. /**
  84007. * Interpolates a Color3 linearly
  84008. * @param startValue Start value of the animation curve
  84009. * @param endValue End value of the animation curve
  84010. * @param gradient Scalar amount to interpolate
  84011. * @returns Interpolated Color3 value
  84012. */
  84013. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84014. /**
  84015. * @hidden Internal use only
  84016. */
  84017. _getKeyValue(value: any): any;
  84018. /**
  84019. * @hidden Internal use only
  84020. */
  84021. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84022. /**
  84023. * Defines the function to use to interpolate matrices
  84024. * @param startValue defines the start matrix
  84025. * @param endValue defines the end matrix
  84026. * @param gradient defines the gradient between both matrices
  84027. * @param result defines an optional target matrix where to store the interpolation
  84028. * @returns the interpolated matrix
  84029. */
  84030. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84031. /**
  84032. * Makes a copy of the animation
  84033. * @returns Cloned animation
  84034. */
  84035. clone(): Animation;
  84036. /**
  84037. * Sets the key frames of the animation
  84038. * @param values The animation key frames to set
  84039. */
  84040. setKeys(values: Array<IAnimationKey>): void;
  84041. /**
  84042. * Serializes the animation to an object
  84043. * @returns Serialized object
  84044. */
  84045. serialize(): any;
  84046. /**
  84047. * Float animation type
  84048. */
  84049. private static _ANIMATIONTYPE_FLOAT;
  84050. /**
  84051. * Vector3 animation type
  84052. */
  84053. private static _ANIMATIONTYPE_VECTOR3;
  84054. /**
  84055. * Quaternion animation type
  84056. */
  84057. private static _ANIMATIONTYPE_QUATERNION;
  84058. /**
  84059. * Matrix animation type
  84060. */
  84061. private static _ANIMATIONTYPE_MATRIX;
  84062. /**
  84063. * Color3 animation type
  84064. */
  84065. private static _ANIMATIONTYPE_COLOR3;
  84066. /**
  84067. * Vector2 animation type
  84068. */
  84069. private static _ANIMATIONTYPE_VECTOR2;
  84070. /**
  84071. * Size animation type
  84072. */
  84073. private static _ANIMATIONTYPE_SIZE;
  84074. /**
  84075. * Relative Loop Mode
  84076. */
  84077. private static _ANIMATIONLOOPMODE_RELATIVE;
  84078. /**
  84079. * Cycle Loop Mode
  84080. */
  84081. private static _ANIMATIONLOOPMODE_CYCLE;
  84082. /**
  84083. * Constant Loop Mode
  84084. */
  84085. private static _ANIMATIONLOOPMODE_CONSTANT;
  84086. /**
  84087. * Get the float animation type
  84088. */
  84089. static readonly ANIMATIONTYPE_FLOAT: number;
  84090. /**
  84091. * Get the Vector3 animation type
  84092. */
  84093. static readonly ANIMATIONTYPE_VECTOR3: number;
  84094. /**
  84095. * Get the Vector2 animation type
  84096. */
  84097. static readonly ANIMATIONTYPE_VECTOR2: number;
  84098. /**
  84099. * Get the Size animation type
  84100. */
  84101. static readonly ANIMATIONTYPE_SIZE: number;
  84102. /**
  84103. * Get the Quaternion animation type
  84104. */
  84105. static readonly ANIMATIONTYPE_QUATERNION: number;
  84106. /**
  84107. * Get the Matrix animation type
  84108. */
  84109. static readonly ANIMATIONTYPE_MATRIX: number;
  84110. /**
  84111. * Get the Color3 animation type
  84112. */
  84113. static readonly ANIMATIONTYPE_COLOR3: number;
  84114. /**
  84115. * Get the Relative Loop Mode
  84116. */
  84117. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84118. /**
  84119. * Get the Cycle Loop Mode
  84120. */
  84121. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84122. /**
  84123. * Get the Constant Loop Mode
  84124. */
  84125. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84126. /** @hidden */
  84127. static _UniversalLerp(left: any, right: any, amount: number): any;
  84128. /**
  84129. * Parses an animation object and creates an animation
  84130. * @param parsedAnimation Parsed animation object
  84131. * @returns Animation object
  84132. */
  84133. static Parse(parsedAnimation: any): Animation;
  84134. /**
  84135. * Appends the serialized animations from the source animations
  84136. * @param source Source containing the animations
  84137. * @param destination Target to store the animations
  84138. */
  84139. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84140. }
  84141. }
  84142. declare module BABYLON {
  84143. /**
  84144. * Base class of all the textures in babylon.
  84145. * It groups all the common properties the materials, post process, lights... might need
  84146. * in order to make a correct use of the texture.
  84147. */
  84148. export class BaseTexture implements IAnimatable {
  84149. /**
  84150. * Default anisotropic filtering level for the application.
  84151. * It is set to 4 as a good tradeoff between perf and quality.
  84152. */
  84153. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84154. /**
  84155. * Gets or sets the unique id of the texture
  84156. */
  84157. uniqueId: number;
  84158. /**
  84159. * Define the name of the texture.
  84160. */
  84161. name: string;
  84162. /**
  84163. * Gets or sets an object used to store user defined information.
  84164. */
  84165. metadata: any;
  84166. /**
  84167. * For internal use only. Please do not use.
  84168. */
  84169. reservedDataStore: any;
  84170. private _hasAlpha;
  84171. /**
  84172. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84173. */
  84174. hasAlpha: boolean;
  84175. /**
  84176. * Defines if the alpha value should be determined via the rgb values.
  84177. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84178. */
  84179. getAlphaFromRGB: boolean;
  84180. /**
  84181. * Intensity or strength of the texture.
  84182. * It is commonly used by materials to fine tune the intensity of the texture
  84183. */
  84184. level: number;
  84185. /**
  84186. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84187. * This is part of the texture as textures usually maps to one uv set.
  84188. */
  84189. coordinatesIndex: number;
  84190. private _coordinatesMode;
  84191. /**
  84192. * How a texture is mapped.
  84193. *
  84194. * | Value | Type | Description |
  84195. * | ----- | ----------------------------------- | ----------- |
  84196. * | 0 | EXPLICIT_MODE | |
  84197. * | 1 | SPHERICAL_MODE | |
  84198. * | 2 | PLANAR_MODE | |
  84199. * | 3 | CUBIC_MODE | |
  84200. * | 4 | PROJECTION_MODE | |
  84201. * | 5 | SKYBOX_MODE | |
  84202. * | 6 | INVCUBIC_MODE | |
  84203. * | 7 | EQUIRECTANGULAR_MODE | |
  84204. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84205. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84206. */
  84207. coordinatesMode: number;
  84208. /**
  84209. * | Value | Type | Description |
  84210. * | ----- | ------------------ | ----------- |
  84211. * | 0 | CLAMP_ADDRESSMODE | |
  84212. * | 1 | WRAP_ADDRESSMODE | |
  84213. * | 2 | MIRROR_ADDRESSMODE | |
  84214. */
  84215. wrapU: number;
  84216. /**
  84217. * | Value | Type | Description |
  84218. * | ----- | ------------------ | ----------- |
  84219. * | 0 | CLAMP_ADDRESSMODE | |
  84220. * | 1 | WRAP_ADDRESSMODE | |
  84221. * | 2 | MIRROR_ADDRESSMODE | |
  84222. */
  84223. wrapV: number;
  84224. /**
  84225. * | Value | Type | Description |
  84226. * | ----- | ------------------ | ----------- |
  84227. * | 0 | CLAMP_ADDRESSMODE | |
  84228. * | 1 | WRAP_ADDRESSMODE | |
  84229. * | 2 | MIRROR_ADDRESSMODE | |
  84230. */
  84231. wrapR: number;
  84232. /**
  84233. * With compliant hardware and browser (supporting anisotropic filtering)
  84234. * this defines the level of anisotropic filtering in the texture.
  84235. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84236. */
  84237. anisotropicFilteringLevel: number;
  84238. /**
  84239. * Define if the texture is a cube texture or if false a 2d texture.
  84240. */
  84241. isCube: boolean;
  84242. /**
  84243. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84244. */
  84245. is3D: boolean;
  84246. /**
  84247. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84248. * HDR texture are usually stored in linear space.
  84249. * This only impacts the PBR and Background materials
  84250. */
  84251. gammaSpace: boolean;
  84252. /**
  84253. * Gets whether or not the texture contains RGBD data.
  84254. */
  84255. readonly isRGBD: boolean;
  84256. /**
  84257. * Is Z inverted in the texture (useful in a cube texture).
  84258. */
  84259. invertZ: boolean;
  84260. /**
  84261. * Are mip maps generated for this texture or not.
  84262. */
  84263. readonly noMipmap: boolean;
  84264. /**
  84265. * @hidden
  84266. */
  84267. lodLevelInAlpha: boolean;
  84268. /**
  84269. * With prefiltered texture, defined the offset used during the prefiltering steps.
  84270. */
  84271. lodGenerationOffset: number;
  84272. /**
  84273. * With prefiltered texture, defined the scale used during the prefiltering steps.
  84274. */
  84275. lodGenerationScale: number;
  84276. /**
  84277. * Define if the texture is a render target.
  84278. */
  84279. isRenderTarget: boolean;
  84280. /**
  84281. * Define the unique id of the texture in the scene.
  84282. */
  84283. readonly uid: string;
  84284. /**
  84285. * Return a string representation of the texture.
  84286. * @returns the texture as a string
  84287. */
  84288. toString(): string;
  84289. /**
  84290. * Get the class name of the texture.
  84291. * @returns "BaseTexture"
  84292. */
  84293. getClassName(): string;
  84294. /**
  84295. * Define the list of animation attached to the texture.
  84296. */
  84297. animations: Animation[];
  84298. /**
  84299. * An event triggered when the texture is disposed.
  84300. */
  84301. onDisposeObservable: Observable<BaseTexture>;
  84302. private _onDisposeObserver;
  84303. /**
  84304. * Callback triggered when the texture has been disposed.
  84305. * Kept for back compatibility, you can use the onDisposeObservable instead.
  84306. */
  84307. onDispose: () => void;
  84308. /**
  84309. * Define the current state of the loading sequence when in delayed load mode.
  84310. */
  84311. delayLoadState: number;
  84312. private _scene;
  84313. /** @hidden */
  84314. _texture: Nullable<InternalTexture>;
  84315. private _uid;
  84316. /**
  84317. * Define if the texture is preventinga material to render or not.
  84318. * If not and the texture is not ready, the engine will use a default black texture instead.
  84319. */
  84320. readonly isBlocking: boolean;
  84321. /**
  84322. * Instantiates a new BaseTexture.
  84323. * Base class of all the textures in babylon.
  84324. * It groups all the common properties the materials, post process, lights... might need
  84325. * in order to make a correct use of the texture.
  84326. * @param scene Define the scene the texture blongs to
  84327. */
  84328. constructor(scene: Nullable<Scene>);
  84329. /**
  84330. * Get the scene the texture belongs to.
  84331. * @returns the scene or null if undefined
  84332. */
  84333. getScene(): Nullable<Scene>;
  84334. /**
  84335. * Get the texture transform matrix used to offset tile the texture for istance.
  84336. * @returns the transformation matrix
  84337. */
  84338. getTextureMatrix(): Matrix;
  84339. /**
  84340. * Get the texture reflection matrix used to rotate/transform the reflection.
  84341. * @returns the reflection matrix
  84342. */
  84343. getReflectionTextureMatrix(): Matrix;
  84344. /**
  84345. * Get the underlying lower level texture from Babylon.
  84346. * @returns the insternal texture
  84347. */
  84348. getInternalTexture(): Nullable<InternalTexture>;
  84349. /**
  84350. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  84351. * @returns true if ready or not blocking
  84352. */
  84353. isReadyOrNotBlocking(): boolean;
  84354. /**
  84355. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  84356. * @returns true if fully ready
  84357. */
  84358. isReady(): boolean;
  84359. private _cachedSize;
  84360. /**
  84361. * Get the size of the texture.
  84362. * @returns the texture size.
  84363. */
  84364. getSize(): ISize;
  84365. /**
  84366. * Get the base size of the texture.
  84367. * It can be different from the size if the texture has been resized for POT for instance
  84368. * @returns the base size
  84369. */
  84370. getBaseSize(): ISize;
  84371. /**
  84372. * Update the sampling mode of the texture.
  84373. * Default is Trilinear mode.
  84374. *
  84375. * | Value | Type | Description |
  84376. * | ----- | ------------------ | ----------- |
  84377. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  84378. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  84379. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  84380. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  84381. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  84382. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  84383. * | 7 | NEAREST_LINEAR | |
  84384. * | 8 | NEAREST_NEAREST | |
  84385. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  84386. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  84387. * | 11 | LINEAR_LINEAR | |
  84388. * | 12 | LINEAR_NEAREST | |
  84389. *
  84390. * > _mag_: magnification filter (close to the viewer)
  84391. * > _min_: minification filter (far from the viewer)
  84392. * > _mip_: filter used between mip map levels
  84393. *@param samplingMode Define the new sampling mode of the texture
  84394. */
  84395. updateSamplingMode(samplingMode: number): void;
  84396. /**
  84397. * Scales the texture if is `canRescale()`
  84398. * @param ratio the resize factor we want to use to rescale
  84399. */
  84400. scale(ratio: number): void;
  84401. /**
  84402. * Get if the texture can rescale.
  84403. */
  84404. readonly canRescale: boolean;
  84405. /** @hidden */
  84406. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  84407. /** @hidden */
  84408. _rebuild(): void;
  84409. /**
  84410. * Triggers the load sequence in delayed load mode.
  84411. */
  84412. delayLoad(): void;
  84413. /**
  84414. * Clones the texture.
  84415. * @returns the cloned texture
  84416. */
  84417. clone(): Nullable<BaseTexture>;
  84418. /**
  84419. * Get the texture underlying type (INT, FLOAT...)
  84420. */
  84421. readonly textureType: number;
  84422. /**
  84423. * Get the texture underlying format (RGB, RGBA...)
  84424. */
  84425. readonly textureFormat: number;
  84426. /**
  84427. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  84428. * This will returns an RGBA array buffer containing either in values (0-255) or
  84429. * float values (0-1) depending of the underlying buffer type.
  84430. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  84431. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  84432. * @param buffer defines a user defined buffer to fill with data (can be null)
  84433. * @returns The Array buffer containing the pixels data.
  84434. */
  84435. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  84436. /**
  84437. * Release and destroy the underlying lower level texture aka internalTexture.
  84438. */
  84439. releaseInternalTexture(): void;
  84440. /**
  84441. * Get the polynomial representation of the texture data.
  84442. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84443. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84444. */
  84445. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84446. /** @hidden */
  84447. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84448. /** @hidden */
  84449. readonly _lodTextureMid: Nullable<BaseTexture>;
  84450. /** @hidden */
  84451. readonly _lodTextureLow: Nullable<BaseTexture>;
  84452. /**
  84453. * Dispose the texture and release its associated resources.
  84454. */
  84455. dispose(): void;
  84456. /**
  84457. * Serialize the texture into a JSON representation that can be parsed later on.
  84458. * @returns the JSON representation of the texture
  84459. */
  84460. serialize(): any;
  84461. /**
  84462. * Helper function to be called back once a list of texture contains only ready textures.
  84463. * @param textures Define the list of textures to wait for
  84464. * @param callback Define the callback triggered once the entire list will be ready
  84465. */
  84466. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84467. }
  84468. }
  84469. declare module BABYLON {
  84470. /**
  84471. * Uniform buffer objects.
  84472. *
  84473. * Handles blocks of uniform on the GPU.
  84474. *
  84475. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84476. *
  84477. * For more information, please refer to :
  84478. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84479. */
  84480. export class UniformBuffer {
  84481. private _engine;
  84482. private _buffer;
  84483. private _data;
  84484. private _bufferData;
  84485. private _dynamic?;
  84486. private _uniformLocations;
  84487. private _uniformSizes;
  84488. private _uniformLocationPointer;
  84489. private _needSync;
  84490. private _noUBO;
  84491. private _currentEffect;
  84492. private static _MAX_UNIFORM_SIZE;
  84493. private static _tempBuffer;
  84494. /**
  84495. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84496. * This is dynamic to allow compat with webgl 1 and 2.
  84497. * You will need to pass the name of the uniform as well as the value.
  84498. */
  84499. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84500. /**
  84501. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84502. * This is dynamic to allow compat with webgl 1 and 2.
  84503. * You will need to pass the name of the uniform as well as the value.
  84504. */
  84505. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84506. /**
  84507. * Lambda to Update a single float in a uniform buffer.
  84508. * This is dynamic to allow compat with webgl 1 and 2.
  84509. * You will need to pass the name of the uniform as well as the value.
  84510. */
  84511. updateFloat: (name: string, x: number) => void;
  84512. /**
  84513. * Lambda to Update a vec2 of float in a uniform buffer.
  84514. * This is dynamic to allow compat with webgl 1 and 2.
  84515. * You will need to pass the name of the uniform as well as the value.
  84516. */
  84517. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84518. /**
  84519. * Lambda to Update a vec3 of float in a uniform buffer.
  84520. * This is dynamic to allow compat with webgl 1 and 2.
  84521. * You will need to pass the name of the uniform as well as the value.
  84522. */
  84523. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84524. /**
  84525. * Lambda to Update a vec4 of float in a uniform buffer.
  84526. * This is dynamic to allow compat with webgl 1 and 2.
  84527. * You will need to pass the name of the uniform as well as the value.
  84528. */
  84529. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84530. /**
  84531. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84532. * This is dynamic to allow compat with webgl 1 and 2.
  84533. * You will need to pass the name of the uniform as well as the value.
  84534. */
  84535. updateMatrix: (name: string, mat: Matrix) => void;
  84536. /**
  84537. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84538. * This is dynamic to allow compat with webgl 1 and 2.
  84539. * You will need to pass the name of the uniform as well as the value.
  84540. */
  84541. updateVector3: (name: string, vector: Vector3) => void;
  84542. /**
  84543. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84544. * This is dynamic to allow compat with webgl 1 and 2.
  84545. * You will need to pass the name of the uniform as well as the value.
  84546. */
  84547. updateVector4: (name: string, vector: Vector4) => void;
  84548. /**
  84549. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84550. * This is dynamic to allow compat with webgl 1 and 2.
  84551. * You will need to pass the name of the uniform as well as the value.
  84552. */
  84553. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84554. /**
  84555. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84556. * This is dynamic to allow compat with webgl 1 and 2.
  84557. * You will need to pass the name of the uniform as well as the value.
  84558. */
  84559. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84560. /**
  84561. * Instantiates a new Uniform buffer objects.
  84562. *
  84563. * Handles blocks of uniform on the GPU.
  84564. *
  84565. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84566. *
  84567. * For more information, please refer to :
  84568. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84569. * @param engine Define the engine the buffer is associated with
  84570. * @param data Define the data contained in the buffer
  84571. * @param dynamic Define if the buffer is updatable
  84572. */
  84573. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84574. /**
  84575. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84576. * or just falling back on setUniformXXX calls.
  84577. */
  84578. readonly useUbo: boolean;
  84579. /**
  84580. * Indicates if the WebGL underlying uniform buffer is in sync
  84581. * with the javascript cache data.
  84582. */
  84583. readonly isSync: boolean;
  84584. /**
  84585. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84586. * Also, a dynamic UniformBuffer will disable cache verification and always
  84587. * update the underlying WebGL uniform buffer to the GPU.
  84588. * @returns if Dynamic, otherwise false
  84589. */
  84590. isDynamic(): boolean;
  84591. /**
  84592. * The data cache on JS side.
  84593. * @returns the underlying data as a float array
  84594. */
  84595. getData(): Float32Array;
  84596. /**
  84597. * The underlying WebGL Uniform buffer.
  84598. * @returns the webgl buffer
  84599. */
  84600. getBuffer(): Nullable<WebGLBuffer>;
  84601. /**
  84602. * std140 layout specifies how to align data within an UBO structure.
  84603. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84604. * for specs.
  84605. */
  84606. private _fillAlignment;
  84607. /**
  84608. * Adds an uniform in the buffer.
  84609. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84610. * for the layout to be correct !
  84611. * @param name Name of the uniform, as used in the uniform block in the shader.
  84612. * @param size Data size, or data directly.
  84613. */
  84614. addUniform(name: string, size: number | number[]): void;
  84615. /**
  84616. * Adds a Matrix 4x4 to the uniform buffer.
  84617. * @param name Name of the uniform, as used in the uniform block in the shader.
  84618. * @param mat A 4x4 matrix.
  84619. */
  84620. addMatrix(name: string, mat: Matrix): void;
  84621. /**
  84622. * Adds a vec2 to the uniform buffer.
  84623. * @param name Name of the uniform, as used in the uniform block in the shader.
  84624. * @param x Define the x component value of the vec2
  84625. * @param y Define the y component value of the vec2
  84626. */
  84627. addFloat2(name: string, x: number, y: number): void;
  84628. /**
  84629. * Adds a vec3 to the uniform buffer.
  84630. * @param name Name of the uniform, as used in the uniform block in the shader.
  84631. * @param x Define the x component value of the vec3
  84632. * @param y Define the y component value of the vec3
  84633. * @param z Define the z component value of the vec3
  84634. */
  84635. addFloat3(name: string, x: number, y: number, z: number): void;
  84636. /**
  84637. * Adds a vec3 to the uniform buffer.
  84638. * @param name Name of the uniform, as used in the uniform block in the shader.
  84639. * @param color Define the vec3 from a Color
  84640. */
  84641. addColor3(name: string, color: Color3): void;
  84642. /**
  84643. * Adds a vec4 to the uniform buffer.
  84644. * @param name Name of the uniform, as used in the uniform block in the shader.
  84645. * @param color Define the rgb components from a Color
  84646. * @param alpha Define the a component of the vec4
  84647. */
  84648. addColor4(name: string, color: Color3, alpha: number): void;
  84649. /**
  84650. * Adds a vec3 to the uniform buffer.
  84651. * @param name Name of the uniform, as used in the uniform block in the shader.
  84652. * @param vector Define the vec3 components from a Vector
  84653. */
  84654. addVector3(name: string, vector: Vector3): void;
  84655. /**
  84656. * Adds a Matrix 3x3 to the uniform buffer.
  84657. * @param name Name of the uniform, as used in the uniform block in the shader.
  84658. */
  84659. addMatrix3x3(name: string): void;
  84660. /**
  84661. * Adds a Matrix 2x2 to the uniform buffer.
  84662. * @param name Name of the uniform, as used in the uniform block in the shader.
  84663. */
  84664. addMatrix2x2(name: string): void;
  84665. /**
  84666. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84667. */
  84668. create(): void;
  84669. /** @hidden */
  84670. _rebuild(): void;
  84671. /**
  84672. * Updates the WebGL Uniform Buffer on the GPU.
  84673. * If the `dynamic` flag is set to true, no cache comparison is done.
  84674. * Otherwise, the buffer will be updated only if the cache differs.
  84675. */
  84676. update(): void;
  84677. /**
  84678. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84679. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84680. * @param data Define the flattened data
  84681. * @param size Define the size of the data.
  84682. */
  84683. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84684. private _updateMatrix3x3ForUniform;
  84685. private _updateMatrix3x3ForEffect;
  84686. private _updateMatrix2x2ForEffect;
  84687. private _updateMatrix2x2ForUniform;
  84688. private _updateFloatForEffect;
  84689. private _updateFloatForUniform;
  84690. private _updateFloat2ForEffect;
  84691. private _updateFloat2ForUniform;
  84692. private _updateFloat3ForEffect;
  84693. private _updateFloat3ForUniform;
  84694. private _updateFloat4ForEffect;
  84695. private _updateFloat4ForUniform;
  84696. private _updateMatrixForEffect;
  84697. private _updateMatrixForUniform;
  84698. private _updateVector3ForEffect;
  84699. private _updateVector3ForUniform;
  84700. private _updateVector4ForEffect;
  84701. private _updateVector4ForUniform;
  84702. private _updateColor3ForEffect;
  84703. private _updateColor3ForUniform;
  84704. private _updateColor4ForEffect;
  84705. private _updateColor4ForUniform;
  84706. /**
  84707. * Sets a sampler uniform on the effect.
  84708. * @param name Define the name of the sampler.
  84709. * @param texture Define the texture to set in the sampler
  84710. */
  84711. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84712. /**
  84713. * Directly updates the value of the uniform in the cache AND on the GPU.
  84714. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84715. * @param data Define the flattened data
  84716. */
  84717. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84718. /**
  84719. * Binds this uniform buffer to an effect.
  84720. * @param effect Define the effect to bind the buffer to
  84721. * @param name Name of the uniform block in the shader.
  84722. */
  84723. bindToEffect(effect: Effect, name: string): void;
  84724. /**
  84725. * Disposes the uniform buffer.
  84726. */
  84727. dispose(): void;
  84728. }
  84729. }
  84730. declare module BABYLON {
  84731. /**
  84732. * This represents the required contract to create a new type of texture loader.
  84733. */
  84734. export interface IInternalTextureLoader {
  84735. /**
  84736. * Defines wether the loader supports cascade loading the different faces.
  84737. */
  84738. supportCascades: boolean;
  84739. /**
  84740. * This returns if the loader support the current file information.
  84741. * @param extension defines the file extension of the file being loaded
  84742. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84743. * @param fallback defines the fallback internal texture if any
  84744. * @param isBase64 defines whether the texture is encoded as a base64
  84745. * @param isBuffer defines whether the texture data are stored as a buffer
  84746. * @returns true if the loader can load the specified file
  84747. */
  84748. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  84749. /**
  84750. * Transform the url before loading if required.
  84751. * @param rootUrl the url of the texture
  84752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84753. * @returns the transformed texture
  84754. */
  84755. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  84756. /**
  84757. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  84758. * @param rootUrl the url of the texture
  84759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84760. * @returns the fallback texture
  84761. */
  84762. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  84763. /**
  84764. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  84765. * @param data contains the texture data
  84766. * @param texture defines the BabylonJS internal texture
  84767. * @param createPolynomials will be true if polynomials have been requested
  84768. * @param onLoad defines the callback to trigger once the texture is ready
  84769. * @param onError defines the callback to trigger in case of error
  84770. */
  84771. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  84772. /**
  84773. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  84774. * @param data contains the texture data
  84775. * @param texture defines the BabylonJS internal texture
  84776. * @param callback defines the method to call once ready to upload
  84777. */
  84778. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  84779. }
  84780. }
  84781. declare module BABYLON {
  84782. /**
  84783. * Creation options of the multi render target texture.
  84784. */
  84785. export interface IMultiRenderTargetOptions {
  84786. /**
  84787. * Define if the texture needs to create mip maps after render.
  84788. */
  84789. generateMipMaps?: boolean;
  84790. /**
  84791. * Define the types of all the draw buffers we want to create
  84792. */
  84793. types?: number[];
  84794. /**
  84795. * Define the sampling modes of all the draw buffers we want to create
  84796. */
  84797. samplingModes?: number[];
  84798. /**
  84799. * Define if a depth buffer is required
  84800. */
  84801. generateDepthBuffer?: boolean;
  84802. /**
  84803. * Define if a stencil buffer is required
  84804. */
  84805. generateStencilBuffer?: boolean;
  84806. /**
  84807. * Define if a depth texture is required instead of a depth buffer
  84808. */
  84809. generateDepthTexture?: boolean;
  84810. /**
  84811. * Define the number of desired draw buffers
  84812. */
  84813. textureCount?: number;
  84814. /**
  84815. * Define if aspect ratio should be adapted to the texture or stay the scene one
  84816. */
  84817. doNotChangeAspectRatio?: boolean;
  84818. /**
  84819. * Define the default type of the buffers we are creating
  84820. */
  84821. defaultType?: number;
  84822. }
  84823. /**
  84824. * A multi render target, like a render target provides the ability to render to a texture.
  84825. * Unlike the render target, it can render to several draw buffers in one draw.
  84826. * This is specially interesting in deferred rendering or for any effects requiring more than
  84827. * just one color from a single pass.
  84828. */
  84829. export class MultiRenderTarget extends RenderTargetTexture {
  84830. private _internalTextures;
  84831. private _textures;
  84832. private _multiRenderTargetOptions;
  84833. /**
  84834. * Get if draw buffers are currently supported by the used hardware and browser.
  84835. */
  84836. readonly isSupported: boolean;
  84837. /**
  84838. * Get the list of textures generated by the multi render target.
  84839. */
  84840. readonly textures: Texture[];
  84841. /**
  84842. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  84843. */
  84844. readonly depthTexture: Texture;
  84845. /**
  84846. * Set the wrapping mode on U of all the textures we are rendering to.
  84847. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84848. */
  84849. wrapU: number;
  84850. /**
  84851. * Set the wrapping mode on V of all the textures we are rendering to.
  84852. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84853. */
  84854. wrapV: number;
  84855. /**
  84856. * Instantiate a new multi render target texture.
  84857. * A multi render target, like a render target provides the ability to render to a texture.
  84858. * Unlike the render target, it can render to several draw buffers in one draw.
  84859. * This is specially interesting in deferred rendering or for any effects requiring more than
  84860. * just one color from a single pass.
  84861. * @param name Define the name of the texture
  84862. * @param size Define the size of the buffers to render to
  84863. * @param count Define the number of target we are rendering into
  84864. * @param scene Define the scene the texture belongs to
  84865. * @param options Define the options used to create the multi render target
  84866. */
  84867. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  84868. /** @hidden */
  84869. _rebuild(): void;
  84870. private _createInternalTextures;
  84871. private _createTextures;
  84872. /**
  84873. * Define the number of samples used if MSAA is enabled.
  84874. */
  84875. samples: number;
  84876. /**
  84877. * Resize all the textures in the multi render target.
  84878. * Be carrefull as it will recreate all the data in the new texture.
  84879. * @param size Define the new size
  84880. */
  84881. resize(size: any): void;
  84882. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84883. /**
  84884. * Dispose the render targets and their associated resources
  84885. */
  84886. dispose(): void;
  84887. /**
  84888. * Release all the underlying texture used as draw buffers.
  84889. */
  84890. releaseInternalTextures(): void;
  84891. }
  84892. }
  84893. declare module BABYLON {
  84894. /**
  84895. * Class used to work with sound analyzer using fast fourier transform (FFT)
  84896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84897. */
  84898. export class Analyser {
  84899. /**
  84900. * Gets or sets the smoothing
  84901. * @ignorenaming
  84902. */
  84903. SMOOTHING: number;
  84904. /**
  84905. * Gets or sets the FFT table size
  84906. * @ignorenaming
  84907. */
  84908. FFT_SIZE: number;
  84909. /**
  84910. * Gets or sets the bar graph amplitude
  84911. * @ignorenaming
  84912. */
  84913. BARGRAPHAMPLITUDE: number;
  84914. /**
  84915. * Gets or sets the position of the debug canvas
  84916. * @ignorenaming
  84917. */
  84918. DEBUGCANVASPOS: {
  84919. x: number;
  84920. y: number;
  84921. };
  84922. /**
  84923. * Gets or sets the debug canvas size
  84924. * @ignorenaming
  84925. */
  84926. DEBUGCANVASSIZE: {
  84927. width: number;
  84928. height: number;
  84929. };
  84930. private _byteFreqs;
  84931. private _byteTime;
  84932. private _floatFreqs;
  84933. private _webAudioAnalyser;
  84934. private _debugCanvas;
  84935. private _debugCanvasContext;
  84936. private _scene;
  84937. private _registerFunc;
  84938. private _audioEngine;
  84939. /**
  84940. * Creates a new analyser
  84941. * @param scene defines hosting scene
  84942. */
  84943. constructor(scene: Scene);
  84944. /**
  84945. * Get the number of data values you will have to play with for the visualization
  84946. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  84947. * @returns a number
  84948. */
  84949. getFrequencyBinCount(): number;
  84950. /**
  84951. * Gets the current frequency data as a byte array
  84952. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84953. * @returns a Uint8Array
  84954. */
  84955. getByteFrequencyData(): Uint8Array;
  84956. /**
  84957. * Gets the current waveform as a byte array
  84958. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  84959. * @returns a Uint8Array
  84960. */
  84961. getByteTimeDomainData(): Uint8Array;
  84962. /**
  84963. * Gets the current frequency data as a float array
  84964. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84965. * @returns a Float32Array
  84966. */
  84967. getFloatFrequencyData(): Float32Array;
  84968. /**
  84969. * Renders the debug canvas
  84970. */
  84971. drawDebugCanvas(): void;
  84972. /**
  84973. * Stops rendering the debug canvas and removes it
  84974. */
  84975. stopDebugCanvas(): void;
  84976. /**
  84977. * Connects two audio nodes
  84978. * @param inputAudioNode defines first node to connect
  84979. * @param outputAudioNode defines second node to connect
  84980. */
  84981. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  84982. /**
  84983. * Releases all associated resources
  84984. */
  84985. dispose(): void;
  84986. }
  84987. }
  84988. declare module BABYLON {
  84989. /**
  84990. * This represents an audio engine and it is responsible
  84991. * to play, synchronize and analyse sounds throughout the application.
  84992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84993. */
  84994. export interface IAudioEngine extends IDisposable {
  84995. /**
  84996. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84997. */
  84998. readonly canUseWebAudio: boolean;
  84999. /**
  85000. * Gets the current AudioContext if available.
  85001. */
  85002. readonly audioContext: Nullable<AudioContext>;
  85003. /**
  85004. * The master gain node defines the global audio volume of your audio engine.
  85005. */
  85006. readonly masterGain: GainNode;
  85007. /**
  85008. * Gets whether or not mp3 are supported by your browser.
  85009. */
  85010. readonly isMP3supported: boolean;
  85011. /**
  85012. * Gets whether or not ogg are supported by your browser.
  85013. */
  85014. readonly isOGGsupported: boolean;
  85015. /**
  85016. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85017. * @ignoreNaming
  85018. */
  85019. WarnedWebAudioUnsupported: boolean;
  85020. /**
  85021. * Defines if the audio engine relies on a custom unlocked button.
  85022. * In this case, the embedded button will not be displayed.
  85023. */
  85024. useCustomUnlockedButton: boolean;
  85025. /**
  85026. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85027. */
  85028. readonly unlocked: boolean;
  85029. /**
  85030. * Event raised when audio has been unlocked on the browser.
  85031. */
  85032. onAudioUnlockedObservable: Observable<AudioEngine>;
  85033. /**
  85034. * Event raised when audio has been locked on the browser.
  85035. */
  85036. onAudioLockedObservable: Observable<AudioEngine>;
  85037. /**
  85038. * Flags the audio engine in Locked state.
  85039. * This happens due to new browser policies preventing audio to autoplay.
  85040. */
  85041. lock(): void;
  85042. /**
  85043. * Unlocks the audio engine once a user action has been done on the dom.
  85044. * This is helpful to resume play once browser policies have been satisfied.
  85045. */
  85046. unlock(): void;
  85047. }
  85048. /**
  85049. * This represents the default audio engine used in babylon.
  85050. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85052. */
  85053. export class AudioEngine implements IAudioEngine {
  85054. private _audioContext;
  85055. private _audioContextInitialized;
  85056. private _muteButton;
  85057. private _hostElement;
  85058. /**
  85059. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85060. */
  85061. canUseWebAudio: boolean;
  85062. /**
  85063. * The master gain node defines the global audio volume of your audio engine.
  85064. */
  85065. masterGain: GainNode;
  85066. /**
  85067. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85068. * @ignoreNaming
  85069. */
  85070. WarnedWebAudioUnsupported: boolean;
  85071. /**
  85072. * Gets whether or not mp3 are supported by your browser.
  85073. */
  85074. isMP3supported: boolean;
  85075. /**
  85076. * Gets whether or not ogg are supported by your browser.
  85077. */
  85078. isOGGsupported: boolean;
  85079. /**
  85080. * Gets whether audio has been unlocked on the device.
  85081. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85082. * a user interaction has happened.
  85083. */
  85084. unlocked: boolean;
  85085. /**
  85086. * Defines if the audio engine relies on a custom unlocked button.
  85087. * In this case, the embedded button will not be displayed.
  85088. */
  85089. useCustomUnlockedButton: boolean;
  85090. /**
  85091. * Event raised when audio has been unlocked on the browser.
  85092. */
  85093. onAudioUnlockedObservable: Observable<AudioEngine>;
  85094. /**
  85095. * Event raised when audio has been locked on the browser.
  85096. */
  85097. onAudioLockedObservable: Observable<AudioEngine>;
  85098. /**
  85099. * Gets the current AudioContext if available.
  85100. */
  85101. readonly audioContext: Nullable<AudioContext>;
  85102. private _connectedAnalyser;
  85103. /**
  85104. * Instantiates a new audio engine.
  85105. *
  85106. * There should be only one per page as some browsers restrict the number
  85107. * of audio contexts you can create.
  85108. * @param hostElement defines the host element where to display the mute icon if necessary
  85109. */
  85110. constructor(hostElement?: Nullable<HTMLElement>);
  85111. /**
  85112. * Flags the audio engine in Locked state.
  85113. * This happens due to new browser policies preventing audio to autoplay.
  85114. */
  85115. lock(): void;
  85116. /**
  85117. * Unlocks the audio engine once a user action has been done on the dom.
  85118. * This is helpful to resume play once browser policies have been satisfied.
  85119. */
  85120. unlock(): void;
  85121. private _resumeAudioContext;
  85122. private _initializeAudioContext;
  85123. private _tryToRun;
  85124. private _triggerRunningState;
  85125. private _triggerSuspendedState;
  85126. private _displayMuteButton;
  85127. private _moveButtonToTopLeft;
  85128. private _onResize;
  85129. private _hideMuteButton;
  85130. /**
  85131. * Destroy and release the resources associated with the audio ccontext.
  85132. */
  85133. dispose(): void;
  85134. /**
  85135. * Gets the global volume sets on the master gain.
  85136. * @returns the global volume if set or -1 otherwise
  85137. */
  85138. getGlobalVolume(): number;
  85139. /**
  85140. * Sets the global volume of your experience (sets on the master gain).
  85141. * @param newVolume Defines the new global volume of the application
  85142. */
  85143. setGlobalVolume(newVolume: number): void;
  85144. /**
  85145. * Connect the audio engine to an audio analyser allowing some amazing
  85146. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85148. * @param analyser The analyser to connect to the engine
  85149. */
  85150. connectToAnalyser(analyser: Analyser): void;
  85151. }
  85152. }
  85153. declare module BABYLON {
  85154. /**
  85155. * Interface used to present a loading screen while loading a scene
  85156. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85157. */
  85158. export interface ILoadingScreen {
  85159. /**
  85160. * Function called to display the loading screen
  85161. */
  85162. displayLoadingUI: () => void;
  85163. /**
  85164. * Function called to hide the loading screen
  85165. */
  85166. hideLoadingUI: () => void;
  85167. /**
  85168. * Gets or sets the color to use for the background
  85169. */
  85170. loadingUIBackgroundColor: string;
  85171. /**
  85172. * Gets or sets the text to display while loading
  85173. */
  85174. loadingUIText: string;
  85175. }
  85176. /**
  85177. * Class used for the default loading screen
  85178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85179. */
  85180. export class DefaultLoadingScreen implements ILoadingScreen {
  85181. private _renderingCanvas;
  85182. private _loadingText;
  85183. private _loadingDivBackgroundColor;
  85184. private _loadingDiv;
  85185. private _loadingTextDiv;
  85186. /**
  85187. * Creates a new default loading screen
  85188. * @param _renderingCanvas defines the canvas used to render the scene
  85189. * @param _loadingText defines the default text to display
  85190. * @param _loadingDivBackgroundColor defines the default background color
  85191. */
  85192. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85193. /**
  85194. * Function called to display the loading screen
  85195. */
  85196. displayLoadingUI(): void;
  85197. /**
  85198. * Function called to hide the loading screen
  85199. */
  85200. hideLoadingUI(): void;
  85201. /**
  85202. * Gets or sets the text to display while loading
  85203. */
  85204. loadingUIText: string;
  85205. /**
  85206. * Gets or sets the color to use for the background
  85207. */
  85208. loadingUIBackgroundColor: string;
  85209. private _resizeLoadingUI;
  85210. }
  85211. }
  85212. declare module BABYLON {
  85213. /**
  85214. * Settings for finer control over video usage
  85215. */
  85216. export interface VideoTextureSettings {
  85217. /**
  85218. * Applies `autoplay` to video, if specified
  85219. */
  85220. autoPlay?: boolean;
  85221. /**
  85222. * Applies `loop` to video, if specified
  85223. */
  85224. loop?: boolean;
  85225. /**
  85226. * Automatically updates internal texture from video at every frame in the render loop
  85227. */
  85228. autoUpdateTexture: boolean;
  85229. /**
  85230. * Image src displayed during the video loading or until the user interacts with the video.
  85231. */
  85232. poster?: string;
  85233. }
  85234. /**
  85235. * If you want to display a video in your scene, this is the special texture for that.
  85236. * This special texture works similar to other textures, with the exception of a few parameters.
  85237. * @see https://doc.babylonjs.com/how_to/video_texture
  85238. */
  85239. export class VideoTexture extends Texture {
  85240. /**
  85241. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85242. */
  85243. readonly autoUpdateTexture: boolean;
  85244. /**
  85245. * The video instance used by the texture internally
  85246. */
  85247. readonly video: HTMLVideoElement;
  85248. private _onUserActionRequestedObservable;
  85249. /**
  85250. * Event triggerd when a dom action is required by the user to play the video.
  85251. * This happens due to recent changes in browser policies preventing video to auto start.
  85252. */
  85253. readonly onUserActionRequestedObservable: Observable<Texture>;
  85254. private _generateMipMaps;
  85255. private _engine;
  85256. private _stillImageCaptured;
  85257. private _displayingPosterTexture;
  85258. private _settings;
  85259. private _createInternalTextureOnEvent;
  85260. /**
  85261. * Creates a video texture.
  85262. * If you want to display a video in your scene, this is the special texture for that.
  85263. * This special texture works similar to other textures, with the exception of a few parameters.
  85264. * @see https://doc.babylonjs.com/how_to/video_texture
  85265. * @param name optional name, will detect from video source, if not defined
  85266. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  85267. * @param scene is obviously the current scene.
  85268. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  85269. * @param invertY is false by default but can be used to invert video on Y axis
  85270. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  85271. * @param settings allows finer control over video usage
  85272. */
  85273. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  85274. private _getName;
  85275. private _getVideo;
  85276. private _createInternalTexture;
  85277. private reset;
  85278. /**
  85279. * @hidden Internal method to initiate `update`.
  85280. */
  85281. _rebuild(): void;
  85282. /**
  85283. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  85284. */
  85285. update(): void;
  85286. /**
  85287. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  85288. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  85289. */
  85290. updateTexture(isVisible: boolean): void;
  85291. protected _updateInternalTexture: () => void;
  85292. /**
  85293. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  85294. * @param url New url.
  85295. */
  85296. updateURL(url: string): void;
  85297. /**
  85298. * Dispose the texture and release its associated resources.
  85299. */
  85300. dispose(): void;
  85301. /**
  85302. * Creates a video texture straight from a stream.
  85303. * @param scene Define the scene the texture should be created in
  85304. * @param stream Define the stream the texture should be created from
  85305. * @returns The created video texture as a promise
  85306. */
  85307. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  85308. /**
  85309. * Creates a video texture straight from your WebCam video feed.
  85310. * @param scene Define the scene the texture should be created in
  85311. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85312. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85313. * @returns The created video texture as a promise
  85314. */
  85315. static CreateFromWebCamAsync(scene: Scene, constraints: {
  85316. minWidth: number;
  85317. maxWidth: number;
  85318. minHeight: number;
  85319. maxHeight: number;
  85320. deviceId: string;
  85321. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  85322. /**
  85323. * Creates a video texture straight from your WebCam video feed.
  85324. * @param scene Define the scene the texture should be created in
  85325. * @param onReady Define a callback to triggered once the texture will be ready
  85326. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85327. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85328. */
  85329. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  85330. minWidth: number;
  85331. maxWidth: number;
  85332. minHeight: number;
  85333. maxHeight: number;
  85334. deviceId: string;
  85335. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  85336. }
  85337. }
  85338. declare module BABYLON {
  85339. /**
  85340. * Interface for attribute information associated with buffer instanciation
  85341. */
  85342. export class InstancingAttributeInfo {
  85343. /**
  85344. * Index/offset of the attribute in the vertex shader
  85345. */
  85346. index: number;
  85347. /**
  85348. * size of the attribute, 1, 2, 3 or 4
  85349. */
  85350. attributeSize: number;
  85351. /**
  85352. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  85353. * default is FLOAT
  85354. */
  85355. attribyteType: number;
  85356. /**
  85357. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  85358. */
  85359. normalized: boolean;
  85360. /**
  85361. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  85362. */
  85363. offset: number;
  85364. /**
  85365. * Name of the GLSL attribute, for debugging purpose only
  85366. */
  85367. attributeName: string;
  85368. }
  85369. /**
  85370. * Define options used to create a depth texture
  85371. */
  85372. export class DepthTextureCreationOptions {
  85373. /** Specifies whether or not a stencil should be allocated in the texture */
  85374. generateStencil?: boolean;
  85375. /** Specifies whether or not bilinear filtering is enable on the texture */
  85376. bilinearFiltering?: boolean;
  85377. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85378. comparisonFunction?: number;
  85379. /** Specifies if the created texture is a cube texture */
  85380. isCube?: boolean;
  85381. }
  85382. /**
  85383. * Class used to describe the capabilities of the engine relatively to the current browser
  85384. */
  85385. export class EngineCapabilities {
  85386. /** Maximum textures units per fragment shader */
  85387. maxTexturesImageUnits: number;
  85388. /** Maximum texture units per vertex shader */
  85389. maxVertexTextureImageUnits: number;
  85390. /** Maximum textures units in the entire pipeline */
  85391. maxCombinedTexturesImageUnits: number;
  85392. /** Maximum texture size */
  85393. maxTextureSize: number;
  85394. /** Maximum cube texture size */
  85395. maxCubemapTextureSize: number;
  85396. /** Maximum render texture size */
  85397. maxRenderTextureSize: number;
  85398. /** Maximum number of vertex attributes */
  85399. maxVertexAttribs: number;
  85400. /** Maximum number of varyings */
  85401. maxVaryingVectors: number;
  85402. /** Maximum number of uniforms per vertex shader */
  85403. maxVertexUniformVectors: number;
  85404. /** Maximum number of uniforms per fragment shader */
  85405. maxFragmentUniformVectors: number;
  85406. /** Defines if standard derivates (dx/dy) are supported */
  85407. standardDerivatives: boolean;
  85408. /** Defines if s3tc texture compression is supported */
  85409. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  85410. /** Defines if pvrtc texture compression is supported */
  85411. pvrtc: any;
  85412. /** Defines if etc1 texture compression is supported */
  85413. etc1: any;
  85414. /** Defines if etc2 texture compression is supported */
  85415. etc2: any;
  85416. /** Defines if astc texture compression is supported */
  85417. astc: any;
  85418. /** Defines if float textures are supported */
  85419. textureFloat: boolean;
  85420. /** Defines if vertex array objects are supported */
  85421. vertexArrayObject: boolean;
  85422. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  85423. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  85424. /** Gets the maximum level of anisotropy supported */
  85425. maxAnisotropy: number;
  85426. /** Defines if instancing is supported */
  85427. instancedArrays: boolean;
  85428. /** Defines if 32 bits indices are supported */
  85429. uintIndices: boolean;
  85430. /** Defines if high precision shaders are supported */
  85431. highPrecisionShaderSupported: boolean;
  85432. /** Defines if depth reading in the fragment shader is supported */
  85433. fragmentDepthSupported: boolean;
  85434. /** Defines if float texture linear filtering is supported*/
  85435. textureFloatLinearFiltering: boolean;
  85436. /** Defines if rendering to float textures is supported */
  85437. textureFloatRender: boolean;
  85438. /** Defines if half float textures are supported*/
  85439. textureHalfFloat: boolean;
  85440. /** Defines if half float texture linear filtering is supported*/
  85441. textureHalfFloatLinearFiltering: boolean;
  85442. /** Defines if rendering to half float textures is supported */
  85443. textureHalfFloatRender: boolean;
  85444. /** Defines if textureLOD shader command is supported */
  85445. textureLOD: boolean;
  85446. /** Defines if draw buffers extension is supported */
  85447. drawBuffersExtension: boolean;
  85448. /** Defines if depth textures are supported */
  85449. depthTextureExtension: boolean;
  85450. /** Defines if float color buffer are supported */
  85451. colorBufferFloat: boolean;
  85452. /** Gets disjoint timer query extension (null if not supported) */
  85453. timerQuery: EXT_disjoint_timer_query;
  85454. /** Defines if timestamp can be used with timer query */
  85455. canUseTimestampForTimerQuery: boolean;
  85456. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  85457. multiview: any;
  85458. /** Function used to let the system compiles shaders in background */
  85459. parallelShaderCompile: {
  85460. COMPLETION_STATUS_KHR: number;
  85461. };
  85462. }
  85463. /** Interface defining initialization parameters for Engine class */
  85464. export interface EngineOptions extends WebGLContextAttributes {
  85465. /**
  85466. * Defines if the engine should no exceed a specified device ratio
  85467. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85468. */
  85469. limitDeviceRatio?: number;
  85470. /**
  85471. * Defines if webvr should be enabled automatically
  85472. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85473. */
  85474. autoEnableWebVR?: boolean;
  85475. /**
  85476. * Defines if webgl2 should be turned off even if supported
  85477. * @see http://doc.babylonjs.com/features/webgl2
  85478. */
  85479. disableWebGL2Support?: boolean;
  85480. /**
  85481. * Defines if webaudio should be initialized as well
  85482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85483. */
  85484. audioEngine?: boolean;
  85485. /**
  85486. * Defines if animations should run using a deterministic lock step
  85487. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85488. */
  85489. deterministicLockstep?: boolean;
  85490. /** Defines the maximum steps to use with deterministic lock step mode */
  85491. lockstepMaxSteps?: number;
  85492. /**
  85493. * Defines that engine should ignore context lost events
  85494. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85495. */
  85496. doNotHandleContextLost?: boolean;
  85497. /**
  85498. * Defines that engine should ignore modifying touch action attribute and style
  85499. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85500. */
  85501. doNotHandleTouchAction?: boolean;
  85502. /**
  85503. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85504. */
  85505. useHighPrecisionFloats?: boolean;
  85506. }
  85507. /**
  85508. * Defines the interface used by display changed events
  85509. */
  85510. export interface IDisplayChangedEventArgs {
  85511. /** Gets the vrDisplay object (if any) */
  85512. vrDisplay: Nullable<any>;
  85513. /** Gets a boolean indicating if webVR is supported */
  85514. vrSupported: boolean;
  85515. }
  85516. /**
  85517. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85518. */
  85519. export class Engine {
  85520. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85521. static ExceptionList: ({
  85522. key: string;
  85523. capture: string;
  85524. captureConstraint: number;
  85525. targets: string[];
  85526. } | {
  85527. key: string;
  85528. capture: null;
  85529. captureConstraint: null;
  85530. targets: string[];
  85531. })[];
  85532. /** Gets the list of created engines */
  85533. static readonly Instances: Engine[];
  85534. /**
  85535. * Gets the latest created engine
  85536. */
  85537. static readonly LastCreatedEngine: Nullable<Engine>;
  85538. /**
  85539. * Gets the latest created scene
  85540. */
  85541. static readonly LastCreatedScene: Nullable<Scene>;
  85542. /**
  85543. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85544. * @param flag defines which part of the materials must be marked as dirty
  85545. * @param predicate defines a predicate used to filter which materials should be affected
  85546. */
  85547. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85548. /**
  85549. * Hidden
  85550. */
  85551. static _TextureLoaders: IInternalTextureLoader[];
  85552. /** Defines that alpha blending is disabled */
  85553. static readonly ALPHA_DISABLE: number;
  85554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  85555. static readonly ALPHA_ADD: number;
  85556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85557. static readonly ALPHA_COMBINE: number;
  85558. /** Defines that alpha blending to DEST - SRC * DEST */
  85559. static readonly ALPHA_SUBTRACT: number;
  85560. /** Defines that alpha blending to SRC * DEST */
  85561. static readonly ALPHA_MULTIPLY: number;
  85562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  85563. static readonly ALPHA_MAXIMIZED: number;
  85564. /** Defines that alpha blending to SRC + DEST */
  85565. static readonly ALPHA_ONEONE: number;
  85566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  85567. static readonly ALPHA_PREMULTIPLIED: number;
  85568. /**
  85569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  85570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85571. */
  85572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  85574. static readonly ALPHA_INTERPOLATE: number;
  85575. /**
  85576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  85577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85578. */
  85579. static readonly ALPHA_SCREENMODE: number;
  85580. /** Defines that the ressource is not delayed*/
  85581. static readonly DELAYLOADSTATE_NONE: number;
  85582. /** Defines that the ressource was successfully delay loaded */
  85583. static readonly DELAYLOADSTATE_LOADED: number;
  85584. /** Defines that the ressource is currently delay loading */
  85585. static readonly DELAYLOADSTATE_LOADING: number;
  85586. /** Defines that the ressource is delayed and has not started loading */
  85587. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85588. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85589. static readonly NEVER: number;
  85590. /** 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 */
  85591. static readonly ALWAYS: number;
  85592. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85593. static readonly LESS: number;
  85594. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85595. static readonly EQUAL: number;
  85596. /** 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 */
  85597. static readonly LEQUAL: number;
  85598. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85599. static readonly GREATER: number;
  85600. /** 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 */
  85601. static readonly GEQUAL: number;
  85602. /** 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 */
  85603. static readonly NOTEQUAL: number;
  85604. /** Passed to stencilOperation to specify that stencil value must be kept */
  85605. static readonly KEEP: number;
  85606. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85607. static readonly REPLACE: number;
  85608. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85609. static readonly INCR: number;
  85610. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85611. static readonly DECR: number;
  85612. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85613. static readonly INVERT: number;
  85614. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85615. static readonly INCR_WRAP: number;
  85616. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85617. static readonly DECR_WRAP: number;
  85618. /** Texture is not repeating outside of 0..1 UVs */
  85619. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85620. /** Texture is repeating outside of 0..1 UVs */
  85621. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85622. /** Texture is repeating and mirrored */
  85623. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85624. /** ALPHA */
  85625. static readonly TEXTUREFORMAT_ALPHA: number;
  85626. /** LUMINANCE */
  85627. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85628. /** LUMINANCE_ALPHA */
  85629. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85630. /** RGB */
  85631. static readonly TEXTUREFORMAT_RGB: number;
  85632. /** RGBA */
  85633. static readonly TEXTUREFORMAT_RGBA: number;
  85634. /** RED */
  85635. static readonly TEXTUREFORMAT_RED: number;
  85636. /** RED (2nd reference) */
  85637. static readonly TEXTUREFORMAT_R: number;
  85638. /** RG */
  85639. static readonly TEXTUREFORMAT_RG: number;
  85640. /** RED_INTEGER */
  85641. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85642. /** RED_INTEGER (2nd reference) */
  85643. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85644. /** RG_INTEGER */
  85645. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85646. /** RGB_INTEGER */
  85647. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85648. /** RGBA_INTEGER */
  85649. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85650. /** UNSIGNED_BYTE */
  85651. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85652. /** UNSIGNED_BYTE (2nd reference) */
  85653. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85654. /** FLOAT */
  85655. static readonly TEXTURETYPE_FLOAT: number;
  85656. /** HALF_FLOAT */
  85657. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85658. /** BYTE */
  85659. static readonly TEXTURETYPE_BYTE: number;
  85660. /** SHORT */
  85661. static readonly TEXTURETYPE_SHORT: number;
  85662. /** UNSIGNED_SHORT */
  85663. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85664. /** INT */
  85665. static readonly TEXTURETYPE_INT: number;
  85666. /** UNSIGNED_INT */
  85667. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85668. /** UNSIGNED_SHORT_4_4_4_4 */
  85669. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85670. /** UNSIGNED_SHORT_5_5_5_1 */
  85671. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85672. /** UNSIGNED_SHORT_5_6_5 */
  85673. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85674. /** UNSIGNED_INT_2_10_10_10_REV */
  85675. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85676. /** UNSIGNED_INT_24_8 */
  85677. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85678. /** UNSIGNED_INT_10F_11F_11F_REV */
  85679. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85680. /** UNSIGNED_INT_5_9_9_9_REV */
  85681. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85682. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85683. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85684. /** nearest is mag = nearest and min = nearest and mip = linear */
  85685. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85686. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85687. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85688. /** Trilinear is mag = linear and min = linear and mip = linear */
  85689. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85690. /** nearest is mag = nearest and min = nearest and mip = linear */
  85691. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85692. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85693. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85694. /** Trilinear is mag = linear and min = linear and mip = linear */
  85695. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85696. /** mag = nearest and min = nearest and mip = nearest */
  85697. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85698. /** mag = nearest and min = linear and mip = nearest */
  85699. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85700. /** mag = nearest and min = linear and mip = linear */
  85701. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85702. /** mag = nearest and min = linear and mip = none */
  85703. static readonly TEXTURE_NEAREST_LINEAR: number;
  85704. /** mag = nearest and min = nearest and mip = none */
  85705. static readonly TEXTURE_NEAREST_NEAREST: number;
  85706. /** mag = linear and min = nearest and mip = nearest */
  85707. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85708. /** mag = linear and min = nearest and mip = linear */
  85709. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85710. /** mag = linear and min = linear and mip = none */
  85711. static readonly TEXTURE_LINEAR_LINEAR: number;
  85712. /** mag = linear and min = nearest and mip = none */
  85713. static readonly TEXTURE_LINEAR_NEAREST: number;
  85714. /** Explicit coordinates mode */
  85715. static readonly TEXTURE_EXPLICIT_MODE: number;
  85716. /** Spherical coordinates mode */
  85717. static readonly TEXTURE_SPHERICAL_MODE: number;
  85718. /** Planar coordinates mode */
  85719. static readonly TEXTURE_PLANAR_MODE: number;
  85720. /** Cubic coordinates mode */
  85721. static readonly TEXTURE_CUBIC_MODE: number;
  85722. /** Projection coordinates mode */
  85723. static readonly TEXTURE_PROJECTION_MODE: number;
  85724. /** Skybox coordinates mode */
  85725. static readonly TEXTURE_SKYBOX_MODE: number;
  85726. /** Inverse Cubic coordinates mode */
  85727. static readonly TEXTURE_INVCUBIC_MODE: number;
  85728. /** Equirectangular coordinates mode */
  85729. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85730. /** Equirectangular Fixed coordinates mode */
  85731. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85732. /** Equirectangular Fixed Mirrored coordinates mode */
  85733. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85734. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85735. static readonly SCALEMODE_FLOOR: number;
  85736. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85737. static readonly SCALEMODE_NEAREST: number;
  85738. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85739. static readonly SCALEMODE_CEILING: number;
  85740. /**
  85741. * Returns the current npm package of the sdk
  85742. */
  85743. static readonly NpmPackage: string;
  85744. /**
  85745. * Returns the current version of the framework
  85746. */
  85747. static readonly Version: string;
  85748. /**
  85749. * Returns a string describing the current engine
  85750. */
  85751. readonly description: string;
  85752. /**
  85753. * Gets or sets the epsilon value used by collision engine
  85754. */
  85755. static CollisionsEpsilon: number;
  85756. /**
  85757. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85758. */
  85759. static ShadersRepository: string;
  85760. /**
  85761. * Method called to create the default loading screen.
  85762. * This can be overriden in your own app.
  85763. * @param canvas The rendering canvas element
  85764. * @returns The loading screen
  85765. */
  85766. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  85767. /**
  85768. * Method called to create the default rescale post process on each engine.
  85769. */
  85770. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  85771. /**
  85772. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  85773. */
  85774. forcePOTTextures: boolean;
  85775. /**
  85776. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  85777. */
  85778. isFullscreen: boolean;
  85779. /**
  85780. * Gets a boolean indicating if the pointer is currently locked
  85781. */
  85782. isPointerLock: boolean;
  85783. /**
  85784. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  85785. */
  85786. cullBackFaces: boolean;
  85787. /**
  85788. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  85789. */
  85790. renderEvenInBackground: boolean;
  85791. /**
  85792. * Gets or sets a boolean indicating that cache can be kept between frames
  85793. */
  85794. preventCacheWipeBetweenFrames: boolean;
  85795. /**
  85796. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  85797. **/
  85798. enableOfflineSupport: boolean;
  85799. /**
  85800. * 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)
  85801. **/
  85802. disableManifestCheck: boolean;
  85803. /**
  85804. * Gets the list of created scenes
  85805. */
  85806. scenes: Scene[];
  85807. /**
  85808. * Event raised when a new scene is created
  85809. */
  85810. onNewSceneAddedObservable: Observable<Scene>;
  85811. /**
  85812. * Gets the list of created postprocesses
  85813. */
  85814. postProcesses: PostProcess[];
  85815. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  85816. validateShaderPrograms: boolean;
  85817. /**
  85818. * Observable event triggered each time the rendering canvas is resized
  85819. */
  85820. onResizeObservable: Observable<Engine>;
  85821. /**
  85822. * Observable event triggered each time the canvas loses focus
  85823. */
  85824. onCanvasBlurObservable: Observable<Engine>;
  85825. /**
  85826. * Observable event triggered each time the canvas gains focus
  85827. */
  85828. onCanvasFocusObservable: Observable<Engine>;
  85829. /**
  85830. * Observable event triggered each time the canvas receives pointerout event
  85831. */
  85832. onCanvasPointerOutObservable: Observable<PointerEvent>;
  85833. /**
  85834. * Observable event triggered before each texture is initialized
  85835. */
  85836. onBeforeTextureInitObservable: Observable<Texture>;
  85837. private _vrDisplay;
  85838. private _vrSupported;
  85839. private _oldSize;
  85840. private _oldHardwareScaleFactor;
  85841. private _vrExclusivePointerMode;
  85842. private _webVRInitPromise;
  85843. /**
  85844. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85845. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85846. */
  85847. readonly isInVRExclusivePointerMode: boolean;
  85848. /**
  85849. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  85850. */
  85851. disableUniformBuffers: boolean;
  85852. /** @hidden */
  85853. _uniformBuffers: UniformBuffer[];
  85854. /**
  85855. * Gets a boolean indicating that the engine supports uniform buffers
  85856. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85857. */
  85858. readonly supportsUniformBuffers: boolean;
  85859. /**
  85860. * Observable raised when the engine begins a new frame
  85861. */
  85862. onBeginFrameObservable: Observable<Engine>;
  85863. /**
  85864. * If set, will be used to request the next animation frame for the render loop
  85865. */
  85866. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  85867. /**
  85868. * Observable raised when the engine ends the current frame
  85869. */
  85870. onEndFrameObservable: Observable<Engine>;
  85871. /**
  85872. * Observable raised when the engine is about to compile a shader
  85873. */
  85874. onBeforeShaderCompilationObservable: Observable<Engine>;
  85875. /**
  85876. * Observable raised when the engine has jsut compiled a shader
  85877. */
  85878. onAfterShaderCompilationObservable: Observable<Engine>;
  85879. /** @hidden */
  85880. _gl: WebGLRenderingContext;
  85881. private _renderingCanvas;
  85882. private _windowIsBackground;
  85883. private _webGLVersion;
  85884. protected _highPrecisionShadersAllowed: boolean;
  85885. /** @hidden */
  85886. readonly _shouldUseHighPrecisionShader: boolean;
  85887. /**
  85888. * Gets a boolean indicating that only power of 2 textures are supported
  85889. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  85890. */
  85891. readonly needPOTTextures: boolean;
  85892. /** @hidden */
  85893. _badOS: boolean;
  85894. /** @hidden */
  85895. _badDesktopOS: boolean;
  85896. /**
  85897. * Gets or sets a value indicating if we want to disable texture binding optimization.
  85898. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  85899. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  85900. */
  85901. disableTextureBindingOptimization: boolean;
  85902. /**
  85903. * Gets the audio engine
  85904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85905. * @ignorenaming
  85906. */
  85907. static audioEngine: IAudioEngine;
  85908. /**
  85909. * Default AudioEngine factory responsible of creating the Audio Engine.
  85910. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  85911. */
  85912. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  85913. /**
  85914. * Default offline support factory responsible of creating a tool used to store data locally.
  85915. * By default, this will create a Database object if the workload has been embedded.
  85916. */
  85917. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  85918. private _onFocus;
  85919. private _onBlur;
  85920. private _onCanvasPointerOut;
  85921. private _onCanvasBlur;
  85922. private _onCanvasFocus;
  85923. private _onFullscreenChange;
  85924. private _onPointerLockChange;
  85925. private _onVRDisplayPointerRestricted;
  85926. private _onVRDisplayPointerUnrestricted;
  85927. private _onVrDisplayConnect;
  85928. private _onVrDisplayDisconnect;
  85929. private _onVrDisplayPresentChange;
  85930. /**
  85931. * Observable signaled when VR display mode changes
  85932. */
  85933. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85934. /**
  85935. * Observable signaled when VR request present is complete
  85936. */
  85937. onVRRequestPresentComplete: Observable<boolean>;
  85938. /**
  85939. * Observable signaled when VR request present starts
  85940. */
  85941. onVRRequestPresentStart: Observable<Engine>;
  85942. private _hardwareScalingLevel;
  85943. /** @hidden */
  85944. protected _caps: EngineCapabilities;
  85945. private _pointerLockRequested;
  85946. private _isStencilEnable;
  85947. private _colorWrite;
  85948. private _loadingScreen;
  85949. /** @hidden */
  85950. _drawCalls: PerfCounter;
  85951. /** @hidden */
  85952. _textureCollisions: PerfCounter;
  85953. private _glVersion;
  85954. private _glRenderer;
  85955. private _glVendor;
  85956. private _videoTextureSupported;
  85957. private _renderingQueueLaunched;
  85958. private _activeRenderLoops;
  85959. private _deterministicLockstep;
  85960. private _lockstepMaxSteps;
  85961. /**
  85962. * Observable signaled when a context lost event is raised
  85963. */
  85964. onContextLostObservable: Observable<Engine>;
  85965. /**
  85966. * Observable signaled when a context restored event is raised
  85967. */
  85968. onContextRestoredObservable: Observable<Engine>;
  85969. private _onContextLost;
  85970. private _onContextRestored;
  85971. private _contextWasLost;
  85972. private _doNotHandleContextLost;
  85973. /**
  85974. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  85975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  85976. */
  85977. doNotHandleContextLost: boolean;
  85978. private _performanceMonitor;
  85979. private _fps;
  85980. private _deltaTime;
  85981. /**
  85982. * Turn this value on if you want to pause FPS computation when in background
  85983. */
  85984. disablePerformanceMonitorInBackground: boolean;
  85985. /**
  85986. * Gets the performance monitor attached to this engine
  85987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  85988. */
  85989. readonly performanceMonitor: PerformanceMonitor;
  85990. /** @hidden */
  85991. protected _depthCullingState: _DepthCullingState;
  85992. /** @hidden */
  85993. protected _stencilState: _StencilState;
  85994. /** @hidden */
  85995. protected _alphaState: _AlphaState;
  85996. /** @hidden */
  85997. protected _alphaMode: number;
  85998. protected _internalTexturesCache: InternalTexture[];
  85999. /** @hidden */
  86000. protected _activeChannel: number;
  86001. private _currentTextureChannel;
  86002. /** @hidden */
  86003. protected _boundTexturesCache: {
  86004. [key: string]: Nullable<InternalTexture>;
  86005. };
  86006. /** @hidden */
  86007. protected _currentEffect: Nullable<Effect>;
  86008. /** @hidden */
  86009. protected _currentProgram: Nullable<WebGLProgram>;
  86010. private _compiledEffects;
  86011. private _vertexAttribArraysEnabled;
  86012. /** @hidden */
  86013. protected _cachedViewport: Nullable<Viewport>;
  86014. private _cachedVertexArrayObject;
  86015. /** @hidden */
  86016. protected _cachedVertexBuffers: any;
  86017. /** @hidden */
  86018. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86019. /** @hidden */
  86020. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86021. /** @hidden */
  86022. protected _currentRenderTarget: Nullable<InternalTexture>;
  86023. private _uintIndicesCurrentlySet;
  86024. private _currentBoundBuffer;
  86025. /** @hidden */
  86026. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86027. private _currentBufferPointers;
  86028. private _currentInstanceLocations;
  86029. private _currentInstanceBuffers;
  86030. private _textureUnits;
  86031. private _firstBoundInternalTextureTracker;
  86032. private _lastBoundInternalTextureTracker;
  86033. private _workingCanvas;
  86034. private _workingContext;
  86035. private _rescalePostProcess;
  86036. private _dummyFramebuffer;
  86037. private _externalData;
  86038. private _bindedRenderFunction;
  86039. private _vaoRecordInProgress;
  86040. private _mustWipeVertexAttributes;
  86041. private _emptyTexture;
  86042. private _emptyCubeTexture;
  86043. private _emptyTexture3D;
  86044. /** @hidden */
  86045. _frameHandler: number;
  86046. private _nextFreeTextureSlots;
  86047. private _maxSimultaneousTextures;
  86048. private _activeRequests;
  86049. private _texturesSupported;
  86050. private _textureFormatInUse;
  86051. /**
  86052. * Gets the list of texture formats supported
  86053. */
  86054. readonly texturesSupported: Array<string>;
  86055. /**
  86056. * Gets the list of texture formats in use
  86057. */
  86058. readonly textureFormatInUse: Nullable<string>;
  86059. /**
  86060. * Gets the current viewport
  86061. */
  86062. readonly currentViewport: Nullable<Viewport>;
  86063. /**
  86064. * Gets the default empty texture
  86065. */
  86066. readonly emptyTexture: InternalTexture;
  86067. /**
  86068. * Gets the default empty 3D texture
  86069. */
  86070. readonly emptyTexture3D: InternalTexture;
  86071. /**
  86072. * Gets the default empty cube texture
  86073. */
  86074. readonly emptyCubeTexture: InternalTexture;
  86075. /**
  86076. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86077. */
  86078. readonly premultipliedAlpha: boolean;
  86079. /**
  86080. * Creates a new engine
  86081. * @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
  86082. * @param antialias defines enable antialiasing (default: false)
  86083. * @param options defines further options to be sent to the getContext() function
  86084. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86085. */
  86086. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86087. private _disableTouchAction;
  86088. private _rebuildInternalTextures;
  86089. private _rebuildEffects;
  86090. /**
  86091. * Gets a boolean indicating if all created effects are ready
  86092. * @returns true if all effects are ready
  86093. */
  86094. areAllEffectsReady(): boolean;
  86095. private _rebuildBuffers;
  86096. private _initGLContext;
  86097. /**
  86098. * Gets version of the current webGL context
  86099. */
  86100. readonly webGLVersion: number;
  86101. /**
  86102. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86103. */
  86104. readonly isStencilEnable: boolean;
  86105. private _prepareWorkingCanvas;
  86106. /**
  86107. * Reset the texture cache to empty state
  86108. */
  86109. resetTextureCache(): void;
  86110. /**
  86111. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86112. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86113. * @returns true if engine is in deterministic lock step mode
  86114. */
  86115. isDeterministicLockStep(): boolean;
  86116. /**
  86117. * Gets the max steps when engine is running in deterministic lock step
  86118. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86119. * @returns the max steps
  86120. */
  86121. getLockstepMaxSteps(): number;
  86122. /**
  86123. * Gets an object containing information about the current webGL context
  86124. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86125. */
  86126. getGlInfo(): {
  86127. vendor: string;
  86128. renderer: string;
  86129. version: string;
  86130. };
  86131. /**
  86132. * Gets current aspect ratio
  86133. * @param camera defines the camera to use to get the aspect ratio
  86134. * @param useScreen defines if screen size must be used (or the current render target if any)
  86135. * @returns a number defining the aspect ratio
  86136. */
  86137. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86138. /**
  86139. * Gets current screen aspect ratio
  86140. * @returns a number defining the aspect ratio
  86141. */
  86142. getScreenAspectRatio(): number;
  86143. /**
  86144. * Gets the current render width
  86145. * @param useScreen defines if screen size must be used (or the current render target if any)
  86146. * @returns a number defining the current render width
  86147. */
  86148. getRenderWidth(useScreen?: boolean): number;
  86149. /**
  86150. * Gets the current render height
  86151. * @param useScreen defines if screen size must be used (or the current render target if any)
  86152. * @returns a number defining the current render height
  86153. */
  86154. getRenderHeight(useScreen?: boolean): number;
  86155. /**
  86156. * Gets the HTML canvas attached with the current webGL context
  86157. * @returns a HTML canvas
  86158. */
  86159. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86160. /**
  86161. * Gets the client rect of the HTML canvas attached with the current webGL context
  86162. * @returns a client rectanglee
  86163. */
  86164. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86165. /**
  86166. * Defines the hardware scaling level.
  86167. * By default the hardware scaling level is computed from the window device ratio.
  86168. * 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.
  86169. * @param level defines the level to use
  86170. */
  86171. setHardwareScalingLevel(level: number): void;
  86172. /**
  86173. * Gets the current hardware scaling level.
  86174. * By default the hardware scaling level is computed from the window device ratio.
  86175. * 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.
  86176. * @returns a number indicating the current hardware scaling level
  86177. */
  86178. getHardwareScalingLevel(): number;
  86179. /**
  86180. * Gets the list of loaded textures
  86181. * @returns an array containing all loaded textures
  86182. */
  86183. getLoadedTexturesCache(): InternalTexture[];
  86184. /**
  86185. * Gets the object containing all engine capabilities
  86186. * @returns the EngineCapabilities object
  86187. */
  86188. getCaps(): EngineCapabilities;
  86189. /**
  86190. * Gets the current depth function
  86191. * @returns a number defining the depth function
  86192. */
  86193. getDepthFunction(): Nullable<number>;
  86194. /**
  86195. * Sets the current depth function
  86196. * @param depthFunc defines the function to use
  86197. */
  86198. setDepthFunction(depthFunc: number): void;
  86199. /**
  86200. * Sets the current depth function to GREATER
  86201. */
  86202. setDepthFunctionToGreater(): void;
  86203. /**
  86204. * Sets the current depth function to GEQUAL
  86205. */
  86206. setDepthFunctionToGreaterOrEqual(): void;
  86207. /**
  86208. * Sets the current depth function to LESS
  86209. */
  86210. setDepthFunctionToLess(): void;
  86211. private _cachedStencilBuffer;
  86212. private _cachedStencilFunction;
  86213. private _cachedStencilMask;
  86214. private _cachedStencilOperationPass;
  86215. private _cachedStencilOperationFail;
  86216. private _cachedStencilOperationDepthFail;
  86217. private _cachedStencilReference;
  86218. /**
  86219. * Caches the the state of the stencil buffer
  86220. */
  86221. cacheStencilState(): void;
  86222. /**
  86223. * Restores the state of the stencil buffer
  86224. */
  86225. restoreStencilState(): void;
  86226. /**
  86227. * Sets the current depth function to LEQUAL
  86228. */
  86229. setDepthFunctionToLessOrEqual(): void;
  86230. /**
  86231. * Gets a boolean indicating if stencil buffer is enabled
  86232. * @returns the current stencil buffer state
  86233. */
  86234. getStencilBuffer(): boolean;
  86235. /**
  86236. * Enable or disable the stencil buffer
  86237. * @param enable defines if the stencil buffer must be enabled or disabled
  86238. */
  86239. setStencilBuffer(enable: boolean): void;
  86240. /**
  86241. * Gets the current stencil mask
  86242. * @returns a number defining the new stencil mask to use
  86243. */
  86244. getStencilMask(): number;
  86245. /**
  86246. * Sets the current stencil mask
  86247. * @param mask defines the new stencil mask to use
  86248. */
  86249. setStencilMask(mask: number): void;
  86250. /**
  86251. * Gets the current stencil function
  86252. * @returns a number defining the stencil function to use
  86253. */
  86254. getStencilFunction(): number;
  86255. /**
  86256. * Gets the current stencil reference value
  86257. * @returns a number defining the stencil reference value to use
  86258. */
  86259. getStencilFunctionReference(): number;
  86260. /**
  86261. * Gets the current stencil mask
  86262. * @returns a number defining the stencil mask to use
  86263. */
  86264. getStencilFunctionMask(): number;
  86265. /**
  86266. * Sets the current stencil function
  86267. * @param stencilFunc defines the new stencil function to use
  86268. */
  86269. setStencilFunction(stencilFunc: number): void;
  86270. /**
  86271. * Sets the current stencil reference
  86272. * @param reference defines the new stencil reference to use
  86273. */
  86274. setStencilFunctionReference(reference: number): void;
  86275. /**
  86276. * Sets the current stencil mask
  86277. * @param mask defines the new stencil mask to use
  86278. */
  86279. setStencilFunctionMask(mask: number): void;
  86280. /**
  86281. * Gets the current stencil operation when stencil fails
  86282. * @returns a number defining stencil operation to use when stencil fails
  86283. */
  86284. getStencilOperationFail(): number;
  86285. /**
  86286. * Gets the current stencil operation when depth fails
  86287. * @returns a number defining stencil operation to use when depth fails
  86288. */
  86289. getStencilOperationDepthFail(): number;
  86290. /**
  86291. * Gets the current stencil operation when stencil passes
  86292. * @returns a number defining stencil operation to use when stencil passes
  86293. */
  86294. getStencilOperationPass(): number;
  86295. /**
  86296. * Sets the stencil operation to use when stencil fails
  86297. * @param operation defines the stencil operation to use when stencil fails
  86298. */
  86299. setStencilOperationFail(operation: number): void;
  86300. /**
  86301. * Sets the stencil operation to use when depth fails
  86302. * @param operation defines the stencil operation to use when depth fails
  86303. */
  86304. setStencilOperationDepthFail(operation: number): void;
  86305. /**
  86306. * Sets the stencil operation to use when stencil passes
  86307. * @param operation defines the stencil operation to use when stencil passes
  86308. */
  86309. setStencilOperationPass(operation: number): void;
  86310. /**
  86311. * Sets a boolean indicating if the dithering state is enabled or disabled
  86312. * @param value defines the dithering state
  86313. */
  86314. setDitheringState(value: boolean): void;
  86315. /**
  86316. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  86317. * @param value defines the rasterizer state
  86318. */
  86319. setRasterizerState(value: boolean): void;
  86320. /**
  86321. * stop executing a render loop function and remove it from the execution array
  86322. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  86323. */
  86324. stopRenderLoop(renderFunction?: () => void): void;
  86325. /** @hidden */
  86326. _renderLoop(): void;
  86327. /**
  86328. * Register and execute a render loop. The engine can have more than one render function
  86329. * @param renderFunction defines the function to continuously execute
  86330. */
  86331. runRenderLoop(renderFunction: () => void): void;
  86332. /**
  86333. * Toggle full screen mode
  86334. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86335. */
  86336. switchFullscreen(requestPointerLock: boolean): void;
  86337. /**
  86338. * Enters full screen mode
  86339. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86340. */
  86341. enterFullscreen(requestPointerLock: boolean): void;
  86342. /**
  86343. * Exits full screen mode
  86344. */
  86345. exitFullscreen(): void;
  86346. /**
  86347. * Clear the current render buffer or the current render target (if any is set up)
  86348. * @param color defines the color to use
  86349. * @param backBuffer defines if the back buffer must be cleared
  86350. * @param depth defines if the depth buffer must be cleared
  86351. * @param stencil defines if the stencil buffer must be cleared
  86352. */
  86353. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  86354. /**
  86355. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  86356. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86357. * @param y defines the y-coordinate of the corner of the clear rectangle
  86358. * @param width defines the width of the clear rectangle
  86359. * @param height defines the height of the clear rectangle
  86360. * @param clearColor defines the clear color
  86361. */
  86362. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  86363. /**
  86364. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  86365. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86366. * @param y defines the y-coordinate of the corner of the clear rectangle
  86367. * @param width defines the width of the clear rectangle
  86368. * @param height defines the height of the clear rectangle
  86369. */
  86370. enableScissor(x: number, y: number, width: number, height: number): void;
  86371. /**
  86372. * Disable previously set scissor test rectangle
  86373. */
  86374. disableScissor(): void;
  86375. private _viewportCached;
  86376. /** @hidden */
  86377. _viewport(x: number, y: number, width: number, height: number): void;
  86378. /**
  86379. * Set the WebGL's viewport
  86380. * @param viewport defines the viewport element to be used
  86381. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  86382. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  86383. */
  86384. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  86385. /**
  86386. * Directly set the WebGL Viewport
  86387. * @param x defines the x coordinate of the viewport (in screen space)
  86388. * @param y defines the y coordinate of the viewport (in screen space)
  86389. * @param width defines the width of the viewport (in screen space)
  86390. * @param height defines the height of the viewport (in screen space)
  86391. * @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
  86392. */
  86393. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  86394. /**
  86395. * Begin a new frame
  86396. */
  86397. beginFrame(): void;
  86398. /**
  86399. * Enf the current frame
  86400. */
  86401. endFrame(): void;
  86402. /**
  86403. * Resize the view according to the canvas' size
  86404. */
  86405. resize(): void;
  86406. /**
  86407. * Force a specific size of the canvas
  86408. * @param width defines the new canvas' width
  86409. * @param height defines the new canvas' height
  86410. */
  86411. setSize(width: number, height: number): void;
  86412. /**
  86413. * Gets a boolean indicating if a webVR device was detected
  86414. * @returns true if a webVR device was detected
  86415. */
  86416. isVRDevicePresent(): boolean;
  86417. /**
  86418. * Gets the current webVR device
  86419. * @returns the current webVR device (or null)
  86420. */
  86421. getVRDevice(): any;
  86422. /**
  86423. * Initializes a webVR display and starts listening to display change events
  86424. * The onVRDisplayChangedObservable will be notified upon these changes
  86425. * @returns The onVRDisplayChangedObservable
  86426. */
  86427. initWebVR(): Observable<IDisplayChangedEventArgs>;
  86428. /**
  86429. * Initializes a webVR display and starts listening to display change events
  86430. * The onVRDisplayChangedObservable will be notified upon these changes
  86431. * @returns A promise containing a VRDisplay and if vr is supported
  86432. */
  86433. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86434. /**
  86435. * Call this function to switch to webVR mode
  86436. * Will do nothing if webVR is not supported or if there is no webVR device
  86437. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86438. */
  86439. enableVR(): void;
  86440. /**
  86441. * Call this function to leave webVR mode
  86442. * Will do nothing if webVR is not supported or if there is no webVR device
  86443. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86444. */
  86445. disableVR(): void;
  86446. private _onVRFullScreenTriggered;
  86447. private _getVRDisplaysAsync;
  86448. /**
  86449. * Binds the frame buffer to the specified texture.
  86450. * @param texture The texture to render to or null for the default canvas
  86451. * @param faceIndex The face of the texture to render to in case of cube texture
  86452. * @param requiredWidth The width of the target to render to
  86453. * @param requiredHeight The height of the target to render to
  86454. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  86455. * @param depthStencilTexture The depth stencil texture to use to render
  86456. * @param lodLevel defines le lod level to bind to the frame buffer
  86457. */
  86458. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86459. private bindUnboundFramebuffer;
  86460. /**
  86461. * Unbind the current render target texture from the webGL context
  86462. * @param texture defines the render target texture to unbind
  86463. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86464. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86465. */
  86466. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86467. /**
  86468. * Unbind a list of render target textures from the webGL context
  86469. * This is used only when drawBuffer extension or webGL2 are active
  86470. * @param textures defines the render target textures to unbind
  86471. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86472. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86473. */
  86474. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86475. /**
  86476. * Force the mipmap generation for the given render target texture
  86477. * @param texture defines the render target texture to use
  86478. */
  86479. generateMipMapsForCubemap(texture: InternalTexture): void;
  86480. /**
  86481. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86482. */
  86483. flushFramebuffer(): void;
  86484. /**
  86485. * Unbind the current render target and bind the default framebuffer
  86486. */
  86487. restoreDefaultFramebuffer(): void;
  86488. /**
  86489. * Create an uniform buffer
  86490. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86491. * @param elements defines the content of the uniform buffer
  86492. * @returns the webGL uniform buffer
  86493. */
  86494. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86495. /**
  86496. * Create a dynamic uniform buffer
  86497. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86498. * @param elements defines the content of the uniform buffer
  86499. * @returns the webGL uniform buffer
  86500. */
  86501. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86502. /**
  86503. * Update an existing uniform buffer
  86504. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86505. * @param uniformBuffer defines the target uniform buffer
  86506. * @param elements defines the content to update
  86507. * @param offset defines the offset in the uniform buffer where update should start
  86508. * @param count defines the size of the data to update
  86509. */
  86510. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86511. private _resetVertexBufferBinding;
  86512. /**
  86513. * Creates a vertex buffer
  86514. * @param data the data for the vertex buffer
  86515. * @returns the new WebGL static buffer
  86516. */
  86517. createVertexBuffer(data: DataArray): WebGLBuffer;
  86518. /**
  86519. * Creates a dynamic vertex buffer
  86520. * @param data the data for the dynamic vertex buffer
  86521. * @returns the new WebGL dynamic buffer
  86522. */
  86523. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86524. /**
  86525. * Update a dynamic index buffer
  86526. * @param indexBuffer defines the target index buffer
  86527. * @param indices defines the data to update
  86528. * @param offset defines the offset in the target index buffer where update should start
  86529. */
  86530. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86531. /**
  86532. * Updates a dynamic vertex buffer.
  86533. * @param vertexBuffer the vertex buffer to update
  86534. * @param data the data used to update the vertex buffer
  86535. * @param byteOffset the byte offset of the data
  86536. * @param byteLength the byte length of the data
  86537. */
  86538. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86539. private _resetIndexBufferBinding;
  86540. /**
  86541. * Creates a new index buffer
  86542. * @param indices defines the content of the index buffer
  86543. * @param updatable defines if the index buffer must be updatable
  86544. * @returns a new webGL buffer
  86545. */
  86546. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86547. /**
  86548. * Bind a webGL buffer to the webGL context
  86549. * @param buffer defines the buffer to bind
  86550. */
  86551. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86552. /**
  86553. * Bind an uniform buffer to the current webGL context
  86554. * @param buffer defines the buffer to bind
  86555. */
  86556. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86557. /**
  86558. * Bind a buffer to the current webGL context at a given location
  86559. * @param buffer defines the buffer to bind
  86560. * @param location defines the index where to bind the buffer
  86561. */
  86562. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86563. /**
  86564. * Bind a specific block at a given index in a specific shader program
  86565. * @param shaderProgram defines the shader program
  86566. * @param blockName defines the block name
  86567. * @param index defines the index where to bind the block
  86568. */
  86569. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  86570. private bindIndexBuffer;
  86571. private bindBuffer;
  86572. /**
  86573. * update the bound buffer with the given data
  86574. * @param data defines the data to update
  86575. */
  86576. updateArrayBuffer(data: Float32Array): void;
  86577. private _vertexAttribPointer;
  86578. private _bindIndexBufferWithCache;
  86579. private _bindVertexBuffersAttributes;
  86580. /**
  86581. * Records a vertex array object
  86582. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86583. * @param vertexBuffers defines the list of vertex buffers to store
  86584. * @param indexBuffer defines the index buffer to store
  86585. * @param effect defines the effect to store
  86586. * @returns the new vertex array object
  86587. */
  86588. recordVertexArrayObject(vertexBuffers: {
  86589. [key: string]: VertexBuffer;
  86590. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  86591. /**
  86592. * Bind a specific vertex array object
  86593. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86594. * @param vertexArrayObject defines the vertex array object to bind
  86595. * @param indexBuffer defines the index buffer to bind
  86596. */
  86597. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  86598. /**
  86599. * Bind webGl buffers directly to the webGL context
  86600. * @param vertexBuffer defines the vertex buffer to bind
  86601. * @param indexBuffer defines the index buffer to bind
  86602. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  86603. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  86604. * @param effect defines the effect associated with the vertex buffer
  86605. */
  86606. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  86607. private _unbindVertexArrayObject;
  86608. /**
  86609. * Bind a list of vertex buffers to the webGL context
  86610. * @param vertexBuffers defines the list of vertex buffers to bind
  86611. * @param indexBuffer defines the index buffer to bind
  86612. * @param effect defines the effect associated with the vertex buffers
  86613. */
  86614. bindBuffers(vertexBuffers: {
  86615. [key: string]: Nullable<VertexBuffer>;
  86616. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  86617. /**
  86618. * Unbind all instance attributes
  86619. */
  86620. unbindInstanceAttributes(): void;
  86621. /**
  86622. * Release and free the memory of a vertex array object
  86623. * @param vao defines the vertex array object to delete
  86624. */
  86625. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  86626. /** @hidden */
  86627. _releaseBuffer(buffer: WebGLBuffer): boolean;
  86628. /**
  86629. * Creates a webGL buffer to use with instanciation
  86630. * @param capacity defines the size of the buffer
  86631. * @returns the webGL buffer
  86632. */
  86633. createInstancesBuffer(capacity: number): WebGLBuffer;
  86634. /**
  86635. * Delete a webGL buffer used with instanciation
  86636. * @param buffer defines the webGL buffer to delete
  86637. */
  86638. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  86639. /**
  86640. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  86641. * @param instancesBuffer defines the webGL buffer to update and bind
  86642. * @param data defines the data to store in the buffer
  86643. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  86644. */
  86645. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  86646. /**
  86647. * Apply all cached states (depth, culling, stencil and alpha)
  86648. */
  86649. applyStates(): void;
  86650. /**
  86651. * Send a draw order
  86652. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86653. * @param indexStart defines the starting index
  86654. * @param indexCount defines the number of index to draw
  86655. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86656. */
  86657. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  86658. /**
  86659. * Draw a list of points
  86660. * @param verticesStart defines the index of first vertex to draw
  86661. * @param verticesCount defines the count of vertices to draw
  86662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86663. */
  86664. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86665. /**
  86666. * Draw a list of unindexed primitives
  86667. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86668. * @param verticesStart defines the index of first vertex to draw
  86669. * @param verticesCount defines the count of vertices to draw
  86670. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86671. */
  86672. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86673. /**
  86674. * Draw a list of indexed primitives
  86675. * @param fillMode defines the primitive to use
  86676. * @param indexStart defines the starting index
  86677. * @param indexCount defines the number of index to draw
  86678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86679. */
  86680. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  86681. /**
  86682. * Draw a list of unindexed primitives
  86683. * @param fillMode defines the primitive to use
  86684. * @param verticesStart defines the index of first vertex to draw
  86685. * @param verticesCount defines the count of vertices to draw
  86686. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86687. */
  86688. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86689. private _drawMode;
  86690. /** @hidden */
  86691. _releaseEffect(effect: Effect): void;
  86692. /** @hidden */
  86693. _deleteProgram(program: WebGLProgram): void;
  86694. /**
  86695. * Create a new effect (used to store vertex/fragment shaders)
  86696. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  86697. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  86698. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  86699. * @param samplers defines an array of string used to represent textures
  86700. * @param defines defines the string containing the defines to use to compile the shaders
  86701. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  86702. * @param onCompiled defines a function to call when the effect creation is successful
  86703. * @param onError defines a function to call when the effect creation has failed
  86704. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  86705. * @returns the new Effect
  86706. */
  86707. 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;
  86708. private _compileShader;
  86709. private _compileRawShader;
  86710. /**
  86711. * Directly creates a webGL program
  86712. * @param vertexCode defines the vertex shader code to use
  86713. * @param fragmentCode defines the fragment shader code to use
  86714. * @param context defines the webGL context to use (if not set, the current one will be used)
  86715. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86716. * @returns the new webGL program
  86717. */
  86718. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86719. /**
  86720. * Creates a webGL program
  86721. * @param vertexCode defines the vertex shader code to use
  86722. * @param fragmentCode defines the fragment shader code to use
  86723. * @param defines defines the string containing the defines to use to compile the shaders
  86724. * @param context defines the webGL context to use (if not set, the current one will be used)
  86725. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86726. * @returns the new webGL program
  86727. */
  86728. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86729. private _createShaderProgram;
  86730. private _finalizeProgram;
  86731. /** @hidden */
  86732. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  86733. /** @hidden */
  86734. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  86735. /**
  86736. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  86737. * @param shaderProgram defines the webGL program to use
  86738. * @param uniformsNames defines the list of uniform names
  86739. * @returns an array of webGL uniform locations
  86740. */
  86741. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  86742. /**
  86743. * Gets the lsit of active attributes for a given webGL program
  86744. * @param shaderProgram defines the webGL program to use
  86745. * @param attributesNames defines the list of attribute names to get
  86746. * @returns an array of indices indicating the offset of each attribute
  86747. */
  86748. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  86749. /**
  86750. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  86751. * @param effect defines the effect to activate
  86752. */
  86753. enableEffect(effect: Nullable<Effect>): void;
  86754. /**
  86755. * Set the value of an uniform to an array of int32
  86756. * @param uniform defines the webGL uniform location where to store the value
  86757. * @param array defines the array of int32 to store
  86758. */
  86759. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86760. /**
  86761. * Set the value of an uniform to an array of int32 (stored as vec2)
  86762. * @param uniform defines the webGL uniform location where to store the value
  86763. * @param array defines the array of int32 to store
  86764. */
  86765. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86766. /**
  86767. * Set the value of an uniform to an array of int32 (stored as vec3)
  86768. * @param uniform defines the webGL uniform location where to store the value
  86769. * @param array defines the array of int32 to store
  86770. */
  86771. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86772. /**
  86773. * Set the value of an uniform to an array of int32 (stored as vec4)
  86774. * @param uniform defines the webGL uniform location where to store the value
  86775. * @param array defines the array of int32 to store
  86776. */
  86777. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86778. /**
  86779. * Set the value of an uniform to an array of float32
  86780. * @param uniform defines the webGL uniform location where to store the value
  86781. * @param array defines the array of float32 to store
  86782. */
  86783. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86784. /**
  86785. * Set the value of an uniform to an array of float32 (stored as vec2)
  86786. * @param uniform defines the webGL uniform location where to store the value
  86787. * @param array defines the array of float32 to store
  86788. */
  86789. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86790. /**
  86791. * Set the value of an uniform to an array of float32 (stored as vec3)
  86792. * @param uniform defines the webGL uniform location where to store the value
  86793. * @param array defines the array of float32 to store
  86794. */
  86795. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86796. /**
  86797. * Set the value of an uniform to an array of float32 (stored as vec4)
  86798. * @param uniform defines the webGL uniform location where to store the value
  86799. * @param array defines the array of float32 to store
  86800. */
  86801. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86802. /**
  86803. * Set the value of an uniform to an array of number
  86804. * @param uniform defines the webGL uniform location where to store the value
  86805. * @param array defines the array of number to store
  86806. */
  86807. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86808. /**
  86809. * Set the value of an uniform to an array of number (stored as vec2)
  86810. * @param uniform defines the webGL uniform location where to store the value
  86811. * @param array defines the array of number to store
  86812. */
  86813. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86814. /**
  86815. * Set the value of an uniform to an array of number (stored as vec3)
  86816. * @param uniform defines the webGL uniform location where to store the value
  86817. * @param array defines the array of number to store
  86818. */
  86819. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86820. /**
  86821. * Set the value of an uniform to an array of number (stored as vec4)
  86822. * @param uniform defines the webGL uniform location where to store the value
  86823. * @param array defines the array of number to store
  86824. */
  86825. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86826. /**
  86827. * Set the value of an uniform to an array of float32 (stored as matrices)
  86828. * @param uniform defines the webGL uniform location where to store the value
  86829. * @param matrices defines the array of float32 to store
  86830. */
  86831. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  86832. /**
  86833. * Set the value of an uniform to a matrix
  86834. * @param uniform defines the webGL uniform location where to store the value
  86835. * @param matrix defines the matrix to store
  86836. */
  86837. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  86838. /**
  86839. * Set the value of an uniform to a matrix (3x3)
  86840. * @param uniform defines the webGL uniform location where to store the value
  86841. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  86842. */
  86843. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86844. /**
  86845. * Set the value of an uniform to a matrix (2x2)
  86846. * @param uniform defines the webGL uniform location where to store the value
  86847. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  86848. */
  86849. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86850. /**
  86851. * Set the value of an uniform to a number (int)
  86852. * @param uniform defines the webGL uniform location where to store the value
  86853. * @param value defines the int number to store
  86854. */
  86855. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86856. /**
  86857. * Set the value of an uniform to a number (float)
  86858. * @param uniform defines the webGL uniform location where to store the value
  86859. * @param value defines the float number to store
  86860. */
  86861. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86862. /**
  86863. * Set the value of an uniform to a vec2
  86864. * @param uniform defines the webGL uniform location where to store the value
  86865. * @param x defines the 1st component of the value
  86866. * @param y defines the 2nd component of the value
  86867. */
  86868. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  86869. /**
  86870. * Set the value of an uniform to a vec3
  86871. * @param uniform defines the webGL uniform location where to store the value
  86872. * @param x defines the 1st component of the value
  86873. * @param y defines the 2nd component of the value
  86874. * @param z defines the 3rd component of the value
  86875. */
  86876. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  86877. /**
  86878. * Set the value of an uniform to a boolean
  86879. * @param uniform defines the webGL uniform location where to store the value
  86880. * @param bool defines the boolean to store
  86881. */
  86882. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  86883. /**
  86884. * Set the value of an uniform to a vec4
  86885. * @param uniform defines the webGL uniform location where to store the value
  86886. * @param x defines the 1st component of the value
  86887. * @param y defines the 2nd component of the value
  86888. * @param z defines the 3rd component of the value
  86889. * @param w defines the 4th component of the value
  86890. */
  86891. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  86892. /**
  86893. * Set the value of an uniform to a Color3
  86894. * @param uniform defines the webGL uniform location where to store the value
  86895. * @param color3 defines the color to store
  86896. */
  86897. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  86898. /**
  86899. * Set the value of an uniform to a Color3 and an alpha value
  86900. * @param uniform defines the webGL uniform location where to store the value
  86901. * @param color3 defines the color to store
  86902. * @param alpha defines the alpha component to store
  86903. */
  86904. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  86905. /**
  86906. * Sets a Color4 on a uniform variable
  86907. * @param uniform defines the uniform location
  86908. * @param color4 defines the value to be set
  86909. */
  86910. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  86911. /**
  86912. * Set various states to the webGL context
  86913. * @param culling defines backface culling state
  86914. * @param zOffset defines the value to apply to zOffset (0 by default)
  86915. * @param force defines if states must be applied even if cache is up to date
  86916. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  86917. */
  86918. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  86919. /**
  86920. * Set the z offset to apply to current rendering
  86921. * @param value defines the offset to apply
  86922. */
  86923. setZOffset(value: number): void;
  86924. /**
  86925. * Gets the current value of the zOffset
  86926. * @returns the current zOffset state
  86927. */
  86928. getZOffset(): number;
  86929. /**
  86930. * Enable or disable depth buffering
  86931. * @param enable defines the state to set
  86932. */
  86933. setDepthBuffer(enable: boolean): void;
  86934. /**
  86935. * Gets a boolean indicating if depth writing is enabled
  86936. * @returns the current depth writing state
  86937. */
  86938. getDepthWrite(): boolean;
  86939. /**
  86940. * Enable or disable depth writing
  86941. * @param enable defines the state to set
  86942. */
  86943. setDepthWrite(enable: boolean): void;
  86944. /**
  86945. * Enable or disable color writing
  86946. * @param enable defines the state to set
  86947. */
  86948. setColorWrite(enable: boolean): void;
  86949. /**
  86950. * Gets a boolean indicating if color writing is enabled
  86951. * @returns the current color writing state
  86952. */
  86953. getColorWrite(): boolean;
  86954. /**
  86955. * Sets alpha constants used by some alpha blending modes
  86956. * @param r defines the red component
  86957. * @param g defines the green component
  86958. * @param b defines the blue component
  86959. * @param a defines the alpha component
  86960. */
  86961. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  86962. /**
  86963. * Sets the current alpha mode
  86964. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  86965. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  86966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86967. */
  86968. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  86969. /**
  86970. * Gets the current alpha mode
  86971. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86972. * @returns the current alpha mode
  86973. */
  86974. getAlphaMode(): number;
  86975. /**
  86976. * Clears the list of texture accessible through engine.
  86977. * This can help preventing texture load conflict due to name collision.
  86978. */
  86979. clearInternalTexturesCache(): void;
  86980. /**
  86981. * Force the entire cache to be cleared
  86982. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  86983. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  86984. */
  86985. wipeCaches(bruteForce?: boolean): void;
  86986. /**
  86987. * Set the compressed texture format to use, based on the formats you have, and the formats
  86988. * supported by the hardware / browser.
  86989. *
  86990. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  86991. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  86992. * to API arguments needed to compressed textures. This puts the burden on the container
  86993. * generator to house the arcane code for determining these for current & future formats.
  86994. *
  86995. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  86996. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  86997. *
  86998. * Note: The result of this call is not taken into account when a texture is base64.
  86999. *
  87000. * @param formatsAvailable defines the list of those format families you have created
  87001. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87002. *
  87003. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87004. * @returns The extension selected.
  87005. */
  87006. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87007. private _getSamplingParameters;
  87008. private _partialLoadImg;
  87009. private _cascadeLoadImgs;
  87010. /** @hidden */
  87011. _createTexture(): WebGLTexture;
  87012. /**
  87013. * Usually called from Texture.ts.
  87014. * Passed information to create a WebGLTexture
  87015. * @param urlArg defines a value which contains one of the following:
  87016. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87017. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87018. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87019. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87020. * @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)
  87021. * @param scene needed for loading to the correct scene
  87022. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87023. * @param onLoad optional callback to be called upon successful completion
  87024. * @param onError optional callback to be called upon failure
  87025. * @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
  87026. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87027. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87028. * @param forcedExtension defines the extension to use to pick the right loader
  87029. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87030. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87031. */
  87032. 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;
  87033. private _rescaleTexture;
  87034. /**
  87035. * Update a raw texture
  87036. * @param texture defines the texture to update
  87037. * @param data defines the data to store in the texture
  87038. * @param format defines the format of the data
  87039. * @param invertY defines if data must be stored with Y axis inverted
  87040. * @param compression defines the compression used (null by default)
  87041. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87042. */
  87043. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87044. /**
  87045. * Creates a raw texture
  87046. * @param data defines the data to store in the texture
  87047. * @param width defines the width of the texture
  87048. * @param height defines the height of the texture
  87049. * @param format defines the format of the data
  87050. * @param generateMipMaps defines if the engine should generate the mip levels
  87051. * @param invertY defines if data must be stored with Y axis inverted
  87052. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87053. * @param compression defines the compression used (null by default)
  87054. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87055. * @returns the raw texture inside an InternalTexture
  87056. */
  87057. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87058. private _unpackFlipYCached;
  87059. /**
  87060. * In case you are sharing the context with other applications, it might
  87061. * be interested to not cache the unpack flip y state to ensure a consistent
  87062. * value would be set.
  87063. */
  87064. enableUnpackFlipYCached: boolean;
  87065. /** @hidden */
  87066. _unpackFlipY(value: boolean): void;
  87067. /** @hidden */
  87068. _getUnpackAlignement(): number;
  87069. /**
  87070. * Creates a dynamic texture
  87071. * @param width defines the width of the texture
  87072. * @param height defines the height of the texture
  87073. * @param generateMipMaps defines if the engine should generate the mip levels
  87074. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87075. * @returns the dynamic texture inside an InternalTexture
  87076. */
  87077. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87078. /**
  87079. * Update the sampling mode of a given texture
  87080. * @param samplingMode defines the required sampling mode
  87081. * @param texture defines the texture to update
  87082. */
  87083. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87084. /**
  87085. * Update the content of a dynamic texture
  87086. * @param texture defines the texture to update
  87087. * @param canvas defines the canvas containing the source
  87088. * @param invertY defines if data must be stored with Y axis inverted
  87089. * @param premulAlpha defines if alpha is stored as premultiplied
  87090. * @param format defines the format of the data
  87091. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87092. */
  87093. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87094. /**
  87095. * Update a video texture
  87096. * @param texture defines the texture to update
  87097. * @param video defines the video element to use
  87098. * @param invertY defines if data must be stored with Y axis inverted
  87099. */
  87100. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87101. /**
  87102. * Updates a depth texture Comparison Mode and Function.
  87103. * If the comparison Function is equal to 0, the mode will be set to none.
  87104. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87105. * @param texture The texture to set the comparison function for
  87106. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87107. */
  87108. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87109. private _setupDepthStencilTexture;
  87110. /**
  87111. * Creates a depth stencil texture.
  87112. * This is only available in WebGL 2 or with the depth texture extension available.
  87113. * @param size The size of face edge in the texture.
  87114. * @param options The options defining the texture.
  87115. * @returns The texture
  87116. */
  87117. createDepthStencilTexture(size: number | {
  87118. width: number;
  87119. height: number;
  87120. }, options: DepthTextureCreationOptions): InternalTexture;
  87121. /**
  87122. * Creates a depth stencil texture.
  87123. * This is only available in WebGL 2 or with the depth texture extension available.
  87124. * @param size The size of face edge in the texture.
  87125. * @param options The options defining the texture.
  87126. * @returns The texture
  87127. */
  87128. private _createDepthStencilTexture;
  87129. /**
  87130. * Creates a depth stencil cube texture.
  87131. * This is only available in WebGL 2.
  87132. * @param size The size of face edge in the cube texture.
  87133. * @param options The options defining the cube texture.
  87134. * @returns The cube texture
  87135. */
  87136. private _createDepthStencilCubeTexture;
  87137. /**
  87138. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87139. * @param renderTarget The render target to set the frame buffer for
  87140. */
  87141. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87142. /**
  87143. * Creates a new render target texture
  87144. * @param size defines the size of the texture
  87145. * @param options defines the options used to create the texture
  87146. * @returns a new render target texture stored in an InternalTexture
  87147. */
  87148. createRenderTargetTexture(size: number | {
  87149. width: number;
  87150. height: number;
  87151. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87152. /**
  87153. * Create a multi render target texture
  87154. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87155. * @param size defines the size of the texture
  87156. * @param options defines the creation options
  87157. * @returns the cube texture as an InternalTexture
  87158. */
  87159. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87160. private _setupFramebufferDepthAttachments;
  87161. /**
  87162. * Updates the sample count of a render target texture
  87163. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87164. * @param texture defines the texture to update
  87165. * @param samples defines the sample count to set
  87166. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87167. */
  87168. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87169. /**
  87170. * Update the sample count for a given multiple render target texture
  87171. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87172. * @param textures defines the textures to update
  87173. * @param samples defines the sample count to set
  87174. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87175. */
  87176. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87177. /** @hidden */
  87178. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87179. /** @hidden */
  87180. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87181. /** @hidden */
  87182. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87183. /** @hidden */
  87184. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87185. /**
  87186. * Creates a new multiview render target
  87187. * @param width defines the width of the texture
  87188. * @param height defines the height of the texture
  87189. * @returns the created multiview texture
  87190. */
  87191. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  87192. /**
  87193. * Binds a multiview framebuffer to be drawn to
  87194. * @param multiviewTexture texture to bind
  87195. */
  87196. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  87197. /**
  87198. * Creates a new render target cube texture
  87199. * @param size defines the size of the texture
  87200. * @param options defines the options used to create the texture
  87201. * @returns a new render target cube texture stored in an InternalTexture
  87202. */
  87203. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87204. /**
  87205. * Creates a cube texture
  87206. * @param rootUrl defines the url where the files to load is located
  87207. * @param scene defines the current scene
  87208. * @param files defines the list of files to load (1 per face)
  87209. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87210. * @param onLoad defines an optional callback raised when the texture is loaded
  87211. * @param onError defines an optional callback raised if there is an issue to load the texture
  87212. * @param format defines the format of the data
  87213. * @param forcedExtension defines the extension to use to pick the right loader
  87214. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87215. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87216. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87217. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87218. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87219. * @returns the cube texture as an InternalTexture
  87220. */
  87221. 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;
  87222. /**
  87223. * @hidden
  87224. */
  87225. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87226. /**
  87227. * Update a raw cube texture
  87228. * @param texture defines the texture to udpdate
  87229. * @param data defines the data to store
  87230. * @param format defines the data format
  87231. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87232. * @param invertY defines if data must be stored with Y axis inverted
  87233. * @param compression defines the compression used (null by default)
  87234. * @param level defines which level of the texture to update
  87235. */
  87236. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87237. /**
  87238. * Creates a new raw cube texture
  87239. * @param data defines the array of data to use to create each face
  87240. * @param size defines the size of the textures
  87241. * @param format defines the format of the data
  87242. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87243. * @param generateMipMaps defines if the engine should generate the mip levels
  87244. * @param invertY defines if data must be stored with Y axis inverted
  87245. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87246. * @param compression defines the compression used (null by default)
  87247. * @returns the cube texture as an InternalTexture
  87248. */
  87249. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87250. /**
  87251. * Creates a new raw cube texture from a specified url
  87252. * @param url defines the url where the data is located
  87253. * @param scene defines the current scene
  87254. * @param size defines the size of the textures
  87255. * @param format defines the format of the data
  87256. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87257. * @param noMipmap defines if the engine should avoid generating the mip levels
  87258. * @param callback defines a callback used to extract texture data from loaded data
  87259. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87260. * @param onLoad defines a callback called when texture is loaded
  87261. * @param onError defines a callback called if there is an error
  87262. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87263. * @param invertY defines if data must be stored with Y axis inverted
  87264. * @returns the cube texture as an InternalTexture
  87265. */
  87266. 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;
  87267. /**
  87268. * Update a raw 3D texture
  87269. * @param texture defines the texture to update
  87270. * @param data defines the data to store
  87271. * @param format defines the data format
  87272. * @param invertY defines if data must be stored with Y axis inverted
  87273. * @param compression defines the used compression (can be null)
  87274. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  87275. */
  87276. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  87277. /**
  87278. * Creates a new raw 3D texture
  87279. * @param data defines the data used to create the texture
  87280. * @param width defines the width of the texture
  87281. * @param height defines the height of the texture
  87282. * @param depth defines the depth of the texture
  87283. * @param format defines the format of the texture
  87284. * @param generateMipMaps defines if the engine must generate mip levels
  87285. * @param invertY defines if data must be stored with Y axis inverted
  87286. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87287. * @param compression defines the compressed used (can be null)
  87288. * @param textureType defines the compressed used (can be null)
  87289. * @returns a new raw 3D texture (stored in an InternalTexture)
  87290. */
  87291. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  87292. private _prepareWebGLTextureContinuation;
  87293. private _prepareWebGLTexture;
  87294. private _convertRGBtoRGBATextureData;
  87295. /** @hidden */
  87296. _releaseFramebufferObjects(texture: InternalTexture): void;
  87297. /** @hidden */
  87298. _releaseTexture(texture: InternalTexture): void;
  87299. private setProgram;
  87300. private _boundUniforms;
  87301. /**
  87302. * Binds an effect to the webGL context
  87303. * @param effect defines the effect to bind
  87304. */
  87305. bindSamplers(effect: Effect): void;
  87306. private _moveBoundTextureOnTop;
  87307. private _getCorrectTextureChannel;
  87308. private _linkTrackers;
  87309. private _removeDesignatedSlot;
  87310. private _activateCurrentTexture;
  87311. /** @hidden */
  87312. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  87313. /** @hidden */
  87314. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  87315. /**
  87316. * Sets a texture to the webGL context from a postprocess
  87317. * @param channel defines the channel to use
  87318. * @param postProcess defines the source postprocess
  87319. */
  87320. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  87321. /**
  87322. * Binds the output of the passed in post process to the texture channel specified
  87323. * @param channel The channel the texture should be bound to
  87324. * @param postProcess The post process which's output should be bound
  87325. */
  87326. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  87327. /**
  87328. * Unbind all textures from the webGL context
  87329. */
  87330. unbindAllTextures(): void;
  87331. /**
  87332. * Sets a texture to the according uniform.
  87333. * @param channel The texture channel
  87334. * @param uniform The uniform to set
  87335. * @param texture The texture to apply
  87336. */
  87337. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  87338. /**
  87339. * Sets a depth stencil texture from a render target to the according uniform.
  87340. * @param channel The texture channel
  87341. * @param uniform The uniform to set
  87342. * @param texture The render target texture containing the depth stencil texture to apply
  87343. */
  87344. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  87345. private _bindSamplerUniformToChannel;
  87346. private _getTextureWrapMode;
  87347. private _setTexture;
  87348. /**
  87349. * Sets an array of texture to the webGL context
  87350. * @param channel defines the channel where the texture array must be set
  87351. * @param uniform defines the associated uniform location
  87352. * @param textures defines the array of textures to bind
  87353. */
  87354. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  87355. /** @hidden */
  87356. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  87357. private _setTextureParameterFloat;
  87358. private _setTextureParameterInteger;
  87359. /**
  87360. * Reads pixels from the current frame buffer. Please note that this function can be slow
  87361. * @param x defines the x coordinate of the rectangle where pixels must be read
  87362. * @param y defines the y coordinate of the rectangle where pixels must be read
  87363. * @param width defines the width of the rectangle where pixels must be read
  87364. * @param height defines the height of the rectangle where pixels must be read
  87365. * @returns a Uint8Array containing RGBA colors
  87366. */
  87367. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  87368. /**
  87369. * Add an externaly attached data from its key.
  87370. * This method call will fail and return false, if such key already exists.
  87371. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  87372. * @param key the unique key that identifies the data
  87373. * @param data the data object to associate to the key for this Engine instance
  87374. * @return true if no such key were already present and the data was added successfully, false otherwise
  87375. */
  87376. addExternalData<T>(key: string, data: T): boolean;
  87377. /**
  87378. * Get an externaly attached data from its key
  87379. * @param key the unique key that identifies the data
  87380. * @return the associated data, if present (can be null), or undefined if not present
  87381. */
  87382. getExternalData<T>(key: string): T;
  87383. /**
  87384. * Get an externaly attached data from its key, create it using a factory if it's not already present
  87385. * @param key the unique key that identifies the data
  87386. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  87387. * @return the associated data, can be null if the factory returned null.
  87388. */
  87389. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  87390. /**
  87391. * Remove an externaly attached data from the Engine instance
  87392. * @param key the unique key that identifies the data
  87393. * @return true if the data was successfully removed, false if it doesn't exist
  87394. */
  87395. removeExternalData(key: string): boolean;
  87396. /**
  87397. * Unbind all vertex attributes from the webGL context
  87398. */
  87399. unbindAllAttributes(): void;
  87400. /**
  87401. * 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
  87402. */
  87403. releaseEffects(): void;
  87404. /**
  87405. * Dispose and release all associated resources
  87406. */
  87407. dispose(): void;
  87408. /**
  87409. * Display the loading screen
  87410. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87411. */
  87412. displayLoadingUI(): void;
  87413. /**
  87414. * Hide the loading screen
  87415. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87416. */
  87417. hideLoadingUI(): void;
  87418. /**
  87419. * Gets the current loading screen object
  87420. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87421. */
  87422. /**
  87423. * Sets the current loading screen object
  87424. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87425. */
  87426. loadingScreen: ILoadingScreen;
  87427. /**
  87428. * Sets the current loading screen text
  87429. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87430. */
  87431. loadingUIText: string;
  87432. /**
  87433. * Sets the current loading screen background color
  87434. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87435. */
  87436. loadingUIBackgroundColor: string;
  87437. /**
  87438. * Attach a new callback raised when context lost event is fired
  87439. * @param callback defines the callback to call
  87440. */
  87441. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87442. /**
  87443. * Attach a new callback raised when context restored event is fired
  87444. * @param callback defines the callback to call
  87445. */
  87446. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87447. /**
  87448. * Gets the source code of the vertex shader associated with a specific webGL program
  87449. * @param program defines the program to use
  87450. * @returns a string containing the source code of the vertex shader associated with the program
  87451. */
  87452. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  87453. /**
  87454. * Gets the source code of the fragment shader associated with a specific webGL program
  87455. * @param program defines the program to use
  87456. * @returns a string containing the source code of the fragment shader associated with the program
  87457. */
  87458. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  87459. /**
  87460. * Get the current error code of the webGL context
  87461. * @returns the error code
  87462. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  87463. */
  87464. getError(): number;
  87465. /**
  87466. * Gets the current framerate
  87467. * @returns a number representing the framerate
  87468. */
  87469. getFps(): number;
  87470. /**
  87471. * Gets the time spent between current and previous frame
  87472. * @returns a number representing the delta time in ms
  87473. */
  87474. getDeltaTime(): number;
  87475. private _measureFps;
  87476. /** @hidden */
  87477. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87478. private _canRenderToFloatFramebuffer;
  87479. private _canRenderToHalfFloatFramebuffer;
  87480. private _canRenderToFramebuffer;
  87481. /** @hidden */
  87482. _getWebGLTextureType(type: number): number;
  87483. private _getInternalFormat;
  87484. /** @hidden */
  87485. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87486. /** @hidden */
  87487. _getRGBAMultiSampleBufferFormat(type: number): number;
  87488. /** @hidden */
  87489. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  87490. /** @hidden */
  87491. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87492. private _partialLoadFile;
  87493. private _cascadeLoadFiles;
  87494. /**
  87495. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87496. * @returns true if the engine can be created
  87497. * @ignorenaming
  87498. */
  87499. static isSupported(): boolean;
  87500. }
  87501. }
  87502. declare module BABYLON {
  87503. /**
  87504. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87505. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87506. */
  87507. export class EffectFallbacks {
  87508. private _defines;
  87509. private _currentRank;
  87510. private _maxRank;
  87511. private _mesh;
  87512. /**
  87513. * Removes the fallback from the bound mesh.
  87514. */
  87515. unBindMesh(): void;
  87516. /**
  87517. * Adds a fallback on the specified property.
  87518. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87519. * @param define The name of the define in the shader
  87520. */
  87521. addFallback(rank: number, define: string): void;
  87522. /**
  87523. * Sets the mesh to use CPU skinning when needing to fallback.
  87524. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87525. * @param mesh The mesh to use the fallbacks.
  87526. */
  87527. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87528. /**
  87529. * Checks to see if more fallbacks are still availible.
  87530. */
  87531. readonly isMoreFallbacks: boolean;
  87532. /**
  87533. * Removes the defines that shoould be removed when falling back.
  87534. * @param currentDefines defines the current define statements for the shader.
  87535. * @param effect defines the current effect we try to compile
  87536. * @returns The resulting defines with defines of the current rank removed.
  87537. */
  87538. reduce(currentDefines: string, effect: Effect): string;
  87539. }
  87540. /**
  87541. * Options to be used when creating an effect.
  87542. */
  87543. export class EffectCreationOptions {
  87544. /**
  87545. * Atrributes that will be used in the shader.
  87546. */
  87547. attributes: string[];
  87548. /**
  87549. * Uniform varible names that will be set in the shader.
  87550. */
  87551. uniformsNames: string[];
  87552. /**
  87553. * Uniform buffer varible names that will be set in the shader.
  87554. */
  87555. uniformBuffersNames: string[];
  87556. /**
  87557. * Sampler texture variable names that will be set in the shader.
  87558. */
  87559. samplers: string[];
  87560. /**
  87561. * Define statements that will be set in the shader.
  87562. */
  87563. defines: any;
  87564. /**
  87565. * Possible fallbacks for this effect to improve performance when needed.
  87566. */
  87567. fallbacks: Nullable<EffectFallbacks>;
  87568. /**
  87569. * Callback that will be called when the shader is compiled.
  87570. */
  87571. onCompiled: Nullable<(effect: Effect) => void>;
  87572. /**
  87573. * Callback that will be called if an error occurs during shader compilation.
  87574. */
  87575. onError: Nullable<(effect: Effect, errors: string) => void>;
  87576. /**
  87577. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87578. */
  87579. indexParameters: any;
  87580. /**
  87581. * Max number of lights that can be used in the shader.
  87582. */
  87583. maxSimultaneousLights: number;
  87584. /**
  87585. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  87586. */
  87587. transformFeedbackVaryings: Nullable<string[]>;
  87588. }
  87589. /**
  87590. * Effect containing vertex and fragment shader that can be executed on an object.
  87591. */
  87592. export class Effect {
  87593. /**
  87594. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87595. */
  87596. static ShadersRepository: string;
  87597. /**
  87598. * Name of the effect.
  87599. */
  87600. name: any;
  87601. /**
  87602. * String container all the define statements that should be set on the shader.
  87603. */
  87604. defines: string;
  87605. /**
  87606. * Callback that will be called when the shader is compiled.
  87607. */
  87608. onCompiled: Nullable<(effect: Effect) => void>;
  87609. /**
  87610. * Callback that will be called if an error occurs during shader compilation.
  87611. */
  87612. onError: Nullable<(effect: Effect, errors: string) => void>;
  87613. /**
  87614. * Callback that will be called when effect is bound.
  87615. */
  87616. onBind: Nullable<(effect: Effect) => void>;
  87617. /**
  87618. * Unique ID of the effect.
  87619. */
  87620. uniqueId: number;
  87621. /**
  87622. * Observable that will be called when the shader is compiled.
  87623. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  87624. */
  87625. onCompileObservable: Observable<Effect>;
  87626. /**
  87627. * Observable that will be called if an error occurs during shader compilation.
  87628. */
  87629. onErrorObservable: Observable<Effect>;
  87630. /** @hidden */
  87631. _onBindObservable: Nullable<Observable<Effect>>;
  87632. /**
  87633. * Observable that will be called when effect is bound.
  87634. */
  87635. readonly onBindObservable: Observable<Effect>;
  87636. /** @hidden */
  87637. _bonesComputationForcedToCPU: boolean;
  87638. private static _uniqueIdSeed;
  87639. private _engine;
  87640. private _uniformBuffersNames;
  87641. private _uniformsNames;
  87642. private _samplers;
  87643. private _isReady;
  87644. private _compilationError;
  87645. private _attributesNames;
  87646. private _attributes;
  87647. private _uniforms;
  87648. /**
  87649. * Key for the effect.
  87650. * @hidden
  87651. */
  87652. _key: string;
  87653. private _indexParameters;
  87654. private _fallbacks;
  87655. private _vertexSourceCode;
  87656. private _fragmentSourceCode;
  87657. private _vertexSourceCodeOverride;
  87658. private _fragmentSourceCodeOverride;
  87659. private _transformFeedbackVaryings;
  87660. /**
  87661. * Compiled shader to webGL program.
  87662. * @hidden
  87663. */
  87664. _program: WebGLProgram;
  87665. private _valueCache;
  87666. private static _baseCache;
  87667. /**
  87668. * Instantiates an effect.
  87669. * An effect can be used to create/manage/execute vertex and fragment shaders.
  87670. * @param baseName Name of the effect.
  87671. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  87672. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  87673. * @param samplers List of sampler variables that will be passed to the shader.
  87674. * @param engine Engine to be used to render the effect
  87675. * @param defines Define statements to be added to the shader.
  87676. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  87677. * @param onCompiled Callback that will be called when the shader is compiled.
  87678. * @param onError Callback that will be called if an error occurs during shader compilation.
  87679. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87680. */
  87681. 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);
  87682. /**
  87683. * Unique key for this effect
  87684. */
  87685. readonly key: string;
  87686. /**
  87687. * If the effect has been compiled and prepared.
  87688. * @returns if the effect is compiled and prepared.
  87689. */
  87690. isReady(): boolean;
  87691. /**
  87692. * The engine the effect was initialized with.
  87693. * @returns the engine.
  87694. */
  87695. getEngine(): Engine;
  87696. /**
  87697. * The compiled webGL program for the effect
  87698. * @returns the webGL program.
  87699. */
  87700. getProgram(): WebGLProgram;
  87701. /**
  87702. * The set of names of attribute variables for the shader.
  87703. * @returns An array of attribute names.
  87704. */
  87705. getAttributesNames(): string[];
  87706. /**
  87707. * Returns the attribute at the given index.
  87708. * @param index The index of the attribute.
  87709. * @returns The location of the attribute.
  87710. */
  87711. getAttributeLocation(index: number): number;
  87712. /**
  87713. * Returns the attribute based on the name of the variable.
  87714. * @param name of the attribute to look up.
  87715. * @returns the attribute location.
  87716. */
  87717. getAttributeLocationByName(name: string): number;
  87718. /**
  87719. * The number of attributes.
  87720. * @returns the numnber of attributes.
  87721. */
  87722. getAttributesCount(): number;
  87723. /**
  87724. * Gets the index of a uniform variable.
  87725. * @param uniformName of the uniform to look up.
  87726. * @returns the index.
  87727. */
  87728. getUniformIndex(uniformName: string): number;
  87729. /**
  87730. * Returns the attribute based on the name of the variable.
  87731. * @param uniformName of the uniform to look up.
  87732. * @returns the location of the uniform.
  87733. */
  87734. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  87735. /**
  87736. * Returns an array of sampler variable names
  87737. * @returns The array of sampler variable neames.
  87738. */
  87739. getSamplers(): string[];
  87740. /**
  87741. * The error from the last compilation.
  87742. * @returns the error string.
  87743. */
  87744. getCompilationError(): string;
  87745. /**
  87746. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  87747. * @param func The callback to be used.
  87748. */
  87749. executeWhenCompiled(func: (effect: Effect) => void): void;
  87750. private _checkIsReady;
  87751. /** @hidden */
  87752. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  87753. /** @hidden */
  87754. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  87755. /** @hidden */
  87756. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  87757. private _processShaderConversion;
  87758. private _processIncludes;
  87759. private _processPrecision;
  87760. /**
  87761. * Recompiles the webGL program
  87762. * @param vertexSourceCode The source code for the vertex shader.
  87763. * @param fragmentSourceCode The source code for the fragment shader.
  87764. * @param onCompiled Callback called when completed.
  87765. * @param onError Callback called on error.
  87766. * @hidden
  87767. */
  87768. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  87769. /**
  87770. * Gets the uniform locations of the the specified variable names
  87771. * @param names THe names of the variables to lookup.
  87772. * @returns Array of locations in the same order as variable names.
  87773. */
  87774. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  87775. /**
  87776. * Prepares the effect
  87777. * @hidden
  87778. */
  87779. _prepareEffect(): void;
  87780. /**
  87781. * Checks if the effect is supported. (Must be called after compilation)
  87782. */
  87783. readonly isSupported: boolean;
  87784. /**
  87785. * Binds a texture to the engine to be used as output of the shader.
  87786. * @param channel Name of the output variable.
  87787. * @param texture Texture to bind.
  87788. * @hidden
  87789. */
  87790. _bindTexture(channel: string, texture: InternalTexture): void;
  87791. /**
  87792. * Sets a texture on the engine to be used in the shader.
  87793. * @param channel Name of the sampler variable.
  87794. * @param texture Texture to set.
  87795. */
  87796. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  87797. /**
  87798. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  87799. * @param channel Name of the sampler variable.
  87800. * @param texture Texture to set.
  87801. */
  87802. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  87803. /**
  87804. * Sets an array of textures on the engine to be used in the shader.
  87805. * @param channel Name of the variable.
  87806. * @param textures Textures to set.
  87807. */
  87808. setTextureArray(channel: string, textures: BaseTexture[]): void;
  87809. /**
  87810. * 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)
  87811. * @param channel Name of the sampler variable.
  87812. * @param postProcess Post process to get the input texture from.
  87813. */
  87814. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  87815. /**
  87816. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  87817. * 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)
  87818. * @param channel Name of the sampler variable.
  87819. * @param postProcess Post process to get the output texture from.
  87820. */
  87821. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  87822. /** @hidden */
  87823. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  87824. /** @hidden */
  87825. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  87826. /** @hidden */
  87827. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  87828. /** @hidden */
  87829. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  87830. /**
  87831. * Binds a buffer to a uniform.
  87832. * @param buffer Buffer to bind.
  87833. * @param name Name of the uniform variable to bind to.
  87834. */
  87835. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  87836. /**
  87837. * Binds block to a uniform.
  87838. * @param blockName Name of the block to bind.
  87839. * @param index Index to bind.
  87840. */
  87841. bindUniformBlock(blockName: string, index: number): void;
  87842. /**
  87843. * Sets an interger value on a uniform variable.
  87844. * @param uniformName Name of the variable.
  87845. * @param value Value to be set.
  87846. * @returns this effect.
  87847. */
  87848. setInt(uniformName: string, value: number): Effect;
  87849. /**
  87850. * Sets an int array on a uniform variable.
  87851. * @param uniformName Name of the variable.
  87852. * @param array array to be set.
  87853. * @returns this effect.
  87854. */
  87855. setIntArray(uniformName: string, array: Int32Array): Effect;
  87856. /**
  87857. * 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)
  87858. * @param uniformName Name of the variable.
  87859. * @param array array to be set.
  87860. * @returns this effect.
  87861. */
  87862. setIntArray2(uniformName: string, array: Int32Array): Effect;
  87863. /**
  87864. * 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)
  87865. * @param uniformName Name of the variable.
  87866. * @param array array to be set.
  87867. * @returns this effect.
  87868. */
  87869. setIntArray3(uniformName: string, array: Int32Array): Effect;
  87870. /**
  87871. * 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)
  87872. * @param uniformName Name of the variable.
  87873. * @param array array to be set.
  87874. * @returns this effect.
  87875. */
  87876. setIntArray4(uniformName: string, array: Int32Array): Effect;
  87877. /**
  87878. * Sets an float array on a uniform variable.
  87879. * @param uniformName Name of the variable.
  87880. * @param array array to be set.
  87881. * @returns this effect.
  87882. */
  87883. setFloatArray(uniformName: string, array: Float32Array): Effect;
  87884. /**
  87885. * 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)
  87886. * @param uniformName Name of the variable.
  87887. * @param array array to be set.
  87888. * @returns this effect.
  87889. */
  87890. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  87891. /**
  87892. * 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)
  87893. * @param uniformName Name of the variable.
  87894. * @param array array to be set.
  87895. * @returns this effect.
  87896. */
  87897. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  87898. /**
  87899. * 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)
  87900. * @param uniformName Name of the variable.
  87901. * @param array array to be set.
  87902. * @returns this effect.
  87903. */
  87904. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  87905. /**
  87906. * Sets an array on a uniform variable.
  87907. * @param uniformName Name of the variable.
  87908. * @param array array to be set.
  87909. * @returns this effect.
  87910. */
  87911. setArray(uniformName: string, array: number[]): Effect;
  87912. /**
  87913. * 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)
  87914. * @param uniformName Name of the variable.
  87915. * @param array array to be set.
  87916. * @returns this effect.
  87917. */
  87918. setArray2(uniformName: string, array: number[]): Effect;
  87919. /**
  87920. * 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)
  87921. * @param uniformName Name of the variable.
  87922. * @param array array to be set.
  87923. * @returns this effect.
  87924. */
  87925. setArray3(uniformName: string, array: number[]): Effect;
  87926. /**
  87927. * 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)
  87928. * @param uniformName Name of the variable.
  87929. * @param array array to be set.
  87930. * @returns this effect.
  87931. */
  87932. setArray4(uniformName: string, array: number[]): Effect;
  87933. /**
  87934. * Sets matrices on a uniform variable.
  87935. * @param uniformName Name of the variable.
  87936. * @param matrices matrices to be set.
  87937. * @returns this effect.
  87938. */
  87939. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  87940. /**
  87941. * Sets matrix on a uniform variable.
  87942. * @param uniformName Name of the variable.
  87943. * @param matrix matrix to be set.
  87944. * @returns this effect.
  87945. */
  87946. setMatrix(uniformName: string, matrix: Matrix): Effect;
  87947. /**
  87948. * 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)
  87949. * @param uniformName Name of the variable.
  87950. * @param matrix matrix to be set.
  87951. * @returns this effect.
  87952. */
  87953. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  87954. /**
  87955. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  87956. * @param uniformName Name of the variable.
  87957. * @param matrix matrix to be set.
  87958. * @returns this effect.
  87959. */
  87960. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  87961. /**
  87962. * Sets a float on a uniform variable.
  87963. * @param uniformName Name of the variable.
  87964. * @param value value to be set.
  87965. * @returns this effect.
  87966. */
  87967. setFloat(uniformName: string, value: number): Effect;
  87968. /**
  87969. * Sets a boolean on a uniform variable.
  87970. * @param uniformName Name of the variable.
  87971. * @param bool value to be set.
  87972. * @returns this effect.
  87973. */
  87974. setBool(uniformName: string, bool: boolean): Effect;
  87975. /**
  87976. * Sets a Vector2 on a uniform variable.
  87977. * @param uniformName Name of the variable.
  87978. * @param vector2 vector2 to be set.
  87979. * @returns this effect.
  87980. */
  87981. setVector2(uniformName: string, vector2: Vector2): Effect;
  87982. /**
  87983. * Sets a float2 on a uniform variable.
  87984. * @param uniformName Name of the variable.
  87985. * @param x First float in float2.
  87986. * @param y Second float in float2.
  87987. * @returns this effect.
  87988. */
  87989. setFloat2(uniformName: string, x: number, y: number): Effect;
  87990. /**
  87991. * Sets a Vector3 on a uniform variable.
  87992. * @param uniformName Name of the variable.
  87993. * @param vector3 Value to be set.
  87994. * @returns this effect.
  87995. */
  87996. setVector3(uniformName: string, vector3: Vector3): Effect;
  87997. /**
  87998. * Sets a float3 on a uniform variable.
  87999. * @param uniformName Name of the variable.
  88000. * @param x First float in float3.
  88001. * @param y Second float in float3.
  88002. * @param z Third float in float3.
  88003. * @returns this effect.
  88004. */
  88005. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88006. /**
  88007. * Sets a Vector4 on a uniform variable.
  88008. * @param uniformName Name of the variable.
  88009. * @param vector4 Value to be set.
  88010. * @returns this effect.
  88011. */
  88012. setVector4(uniformName: string, vector4: Vector4): Effect;
  88013. /**
  88014. * Sets a float4 on a uniform variable.
  88015. * @param uniformName Name of the variable.
  88016. * @param x First float in float4.
  88017. * @param y Second float in float4.
  88018. * @param z Third float in float4.
  88019. * @param w Fourth float in float4.
  88020. * @returns this effect.
  88021. */
  88022. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88023. /**
  88024. * Sets a Color3 on a uniform variable.
  88025. * @param uniformName Name of the variable.
  88026. * @param color3 Value to be set.
  88027. * @returns this effect.
  88028. */
  88029. setColor3(uniformName: string, color3: Color3): Effect;
  88030. /**
  88031. * Sets a Color4 on a uniform variable.
  88032. * @param uniformName Name of the variable.
  88033. * @param color3 Value to be set.
  88034. * @param alpha Alpha value to be set.
  88035. * @returns this effect.
  88036. */
  88037. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88038. /**
  88039. * Sets a Color4 on a uniform variable
  88040. * @param uniformName defines the name of the variable
  88041. * @param color4 defines the value to be set
  88042. * @returns this effect.
  88043. */
  88044. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88045. /**
  88046. * This function will add a new shader to the shader store
  88047. * @param name the name of the shader
  88048. * @param pixelShader optional pixel shader content
  88049. * @param vertexShader optional vertex shader content
  88050. */
  88051. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88052. /**
  88053. * Store of each shader (The can be looked up using effect.key)
  88054. */
  88055. static ShadersStore: {
  88056. [key: string]: string;
  88057. };
  88058. /**
  88059. * Store of each included file for a shader (The can be looked up using effect.key)
  88060. */
  88061. static IncludesShadersStore: {
  88062. [key: string]: string;
  88063. };
  88064. /**
  88065. * Resets the cache of effects.
  88066. */
  88067. static ResetCache(): void;
  88068. }
  88069. }
  88070. declare module BABYLON {
  88071. /**
  88072. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88073. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88074. * 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;
  88075. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88076. */
  88077. export class ColorCurves {
  88078. private _dirty;
  88079. private _tempColor;
  88080. private _globalCurve;
  88081. private _highlightsCurve;
  88082. private _midtonesCurve;
  88083. private _shadowsCurve;
  88084. private _positiveCurve;
  88085. private _negativeCurve;
  88086. private _globalHue;
  88087. private _globalDensity;
  88088. private _globalSaturation;
  88089. private _globalExposure;
  88090. /**
  88091. * Gets the global Hue value.
  88092. * 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).
  88093. */
  88094. /**
  88095. * Sets the global Hue value.
  88096. * 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).
  88097. */
  88098. globalHue: number;
  88099. /**
  88100. * Gets the global Density value.
  88101. * 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.
  88102. * Values less than zero provide a filter of opposite hue.
  88103. */
  88104. /**
  88105. * Sets the global Density value.
  88106. * 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.
  88107. * Values less than zero provide a filter of opposite hue.
  88108. */
  88109. globalDensity: number;
  88110. /**
  88111. * Gets the global Saturation value.
  88112. * 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.
  88113. */
  88114. /**
  88115. * Sets the global Saturation value.
  88116. * 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.
  88117. */
  88118. globalSaturation: number;
  88119. /**
  88120. * Gets the global Exposure value.
  88121. * 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.
  88122. */
  88123. /**
  88124. * Sets the global Exposure value.
  88125. * 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.
  88126. */
  88127. globalExposure: number;
  88128. private _highlightsHue;
  88129. private _highlightsDensity;
  88130. private _highlightsSaturation;
  88131. private _highlightsExposure;
  88132. /**
  88133. * Gets the highlights Hue value.
  88134. * 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).
  88135. */
  88136. /**
  88137. * Sets the highlights Hue value.
  88138. * 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).
  88139. */
  88140. highlightsHue: number;
  88141. /**
  88142. * Gets the highlights Density value.
  88143. * 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.
  88144. * Values less than zero provide a filter of opposite hue.
  88145. */
  88146. /**
  88147. * Sets the highlights Density value.
  88148. * 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.
  88149. * Values less than zero provide a filter of opposite hue.
  88150. */
  88151. highlightsDensity: number;
  88152. /**
  88153. * Gets the highlights Saturation value.
  88154. * 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.
  88155. */
  88156. /**
  88157. * Sets the highlights Saturation value.
  88158. * 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.
  88159. */
  88160. highlightsSaturation: number;
  88161. /**
  88162. * Gets the highlights Exposure value.
  88163. * 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.
  88164. */
  88165. /**
  88166. * Sets the highlights Exposure value.
  88167. * 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.
  88168. */
  88169. highlightsExposure: number;
  88170. private _midtonesHue;
  88171. private _midtonesDensity;
  88172. private _midtonesSaturation;
  88173. private _midtonesExposure;
  88174. /**
  88175. * Gets the midtones Hue value.
  88176. * 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).
  88177. */
  88178. /**
  88179. * Sets the midtones Hue value.
  88180. * 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).
  88181. */
  88182. midtonesHue: number;
  88183. /**
  88184. * Gets the midtones Density value.
  88185. * 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.
  88186. * Values less than zero provide a filter of opposite hue.
  88187. */
  88188. /**
  88189. * Sets the midtones Density value.
  88190. * 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.
  88191. * Values less than zero provide a filter of opposite hue.
  88192. */
  88193. midtonesDensity: number;
  88194. /**
  88195. * Gets the midtones Saturation value.
  88196. * 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.
  88197. */
  88198. /**
  88199. * Sets the midtones Saturation value.
  88200. * 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.
  88201. */
  88202. midtonesSaturation: number;
  88203. /**
  88204. * Gets the midtones Exposure value.
  88205. * 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.
  88206. */
  88207. /**
  88208. * Sets the midtones Exposure value.
  88209. * 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.
  88210. */
  88211. midtonesExposure: number;
  88212. private _shadowsHue;
  88213. private _shadowsDensity;
  88214. private _shadowsSaturation;
  88215. private _shadowsExposure;
  88216. /**
  88217. * Gets the shadows Hue value.
  88218. * 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).
  88219. */
  88220. /**
  88221. * Sets the shadows Hue value.
  88222. * 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).
  88223. */
  88224. shadowsHue: number;
  88225. /**
  88226. * Gets the shadows Density value.
  88227. * 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.
  88228. * Values less than zero provide a filter of opposite hue.
  88229. */
  88230. /**
  88231. * Sets the shadows Density value.
  88232. * 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.
  88233. * Values less than zero provide a filter of opposite hue.
  88234. */
  88235. shadowsDensity: number;
  88236. /**
  88237. * Gets the shadows Saturation value.
  88238. * 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.
  88239. */
  88240. /**
  88241. * Sets the shadows Saturation value.
  88242. * 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.
  88243. */
  88244. shadowsSaturation: number;
  88245. /**
  88246. * Gets the shadows Exposure value.
  88247. * 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.
  88248. */
  88249. /**
  88250. * Sets the shadows Exposure value.
  88251. * 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.
  88252. */
  88253. shadowsExposure: number;
  88254. /**
  88255. * Returns the class name
  88256. * @returns The class name
  88257. */
  88258. getClassName(): string;
  88259. /**
  88260. * Binds the color curves to the shader.
  88261. * @param colorCurves The color curve to bind
  88262. * @param effect The effect to bind to
  88263. * @param positiveUniform The positive uniform shader parameter
  88264. * @param neutralUniform The neutral uniform shader parameter
  88265. * @param negativeUniform The negative uniform shader parameter
  88266. */
  88267. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88268. /**
  88269. * Prepare the list of uniforms associated with the ColorCurves effects.
  88270. * @param uniformsList The list of uniforms used in the effect
  88271. */
  88272. static PrepareUniforms(uniformsList: string[]): void;
  88273. /**
  88274. * Returns color grading data based on a hue, density, saturation and exposure value.
  88275. * @param filterHue The hue of the color filter.
  88276. * @param filterDensity The density of the color filter.
  88277. * @param saturation The saturation.
  88278. * @param exposure The exposure.
  88279. * @param result The result data container.
  88280. */
  88281. private getColorGradingDataToRef;
  88282. /**
  88283. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88284. * @param value The input slider value in range [-100,100].
  88285. * @returns Adjusted value.
  88286. */
  88287. private static applyColorGradingSliderNonlinear;
  88288. /**
  88289. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88290. * @param hue The hue (H) input.
  88291. * @param saturation The saturation (S) input.
  88292. * @param brightness The brightness (B) input.
  88293. * @result An RGBA color represented as Vector4.
  88294. */
  88295. private static fromHSBToRef;
  88296. /**
  88297. * Returns a value clamped between min and max
  88298. * @param value The value to clamp
  88299. * @param min The minimum of value
  88300. * @param max The maximum of value
  88301. * @returns The clamped value.
  88302. */
  88303. private static clamp;
  88304. /**
  88305. * Clones the current color curve instance.
  88306. * @return The cloned curves
  88307. */
  88308. clone(): ColorCurves;
  88309. /**
  88310. * Serializes the current color curve instance to a json representation.
  88311. * @return a JSON representation
  88312. */
  88313. serialize(): any;
  88314. /**
  88315. * Parses the color curve from a json representation.
  88316. * @param source the JSON source to parse
  88317. * @return The parsed curves
  88318. */
  88319. static Parse(source: any): ColorCurves;
  88320. }
  88321. }
  88322. declare module BABYLON {
  88323. /**
  88324. * Interface to follow in your material defines to integrate easily the
  88325. * Image proccessing functions.
  88326. * @hidden
  88327. */
  88328. export interface IImageProcessingConfigurationDefines {
  88329. IMAGEPROCESSING: boolean;
  88330. VIGNETTE: boolean;
  88331. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88332. VIGNETTEBLENDMODEOPAQUE: boolean;
  88333. TONEMAPPING: boolean;
  88334. TONEMAPPING_ACES: boolean;
  88335. CONTRAST: boolean;
  88336. EXPOSURE: boolean;
  88337. COLORCURVES: boolean;
  88338. COLORGRADING: boolean;
  88339. COLORGRADING3D: boolean;
  88340. SAMPLER3DGREENDEPTH: boolean;
  88341. SAMPLER3DBGRMAP: boolean;
  88342. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88343. }
  88344. /**
  88345. * @hidden
  88346. */
  88347. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88348. IMAGEPROCESSING: boolean;
  88349. VIGNETTE: boolean;
  88350. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88351. VIGNETTEBLENDMODEOPAQUE: boolean;
  88352. TONEMAPPING: boolean;
  88353. TONEMAPPING_ACES: boolean;
  88354. CONTRAST: boolean;
  88355. COLORCURVES: boolean;
  88356. COLORGRADING: boolean;
  88357. COLORGRADING3D: boolean;
  88358. SAMPLER3DGREENDEPTH: boolean;
  88359. SAMPLER3DBGRMAP: boolean;
  88360. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88361. EXPOSURE: boolean;
  88362. constructor();
  88363. }
  88364. /**
  88365. * This groups together the common properties used for image processing either in direct forward pass
  88366. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88367. * or not.
  88368. */
  88369. export class ImageProcessingConfiguration {
  88370. /**
  88371. * Default tone mapping applied in BabylonJS.
  88372. */
  88373. static readonly TONEMAPPING_STANDARD: number;
  88374. /**
  88375. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88376. * to other engines rendering to increase portability.
  88377. */
  88378. static readonly TONEMAPPING_ACES: number;
  88379. /**
  88380. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88381. */
  88382. colorCurves: Nullable<ColorCurves>;
  88383. private _colorCurvesEnabled;
  88384. /**
  88385. * Gets wether the color curves effect is enabled.
  88386. */
  88387. /**
  88388. * Sets wether the color curves effect is enabled.
  88389. */
  88390. colorCurvesEnabled: boolean;
  88391. private _colorGradingTexture;
  88392. /**
  88393. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88394. */
  88395. /**
  88396. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88397. */
  88398. colorGradingTexture: Nullable<BaseTexture>;
  88399. private _colorGradingEnabled;
  88400. /**
  88401. * Gets wether the color grading effect is enabled.
  88402. */
  88403. /**
  88404. * Sets wether the color grading effect is enabled.
  88405. */
  88406. colorGradingEnabled: boolean;
  88407. private _colorGradingWithGreenDepth;
  88408. /**
  88409. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88410. */
  88411. /**
  88412. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88413. */
  88414. colorGradingWithGreenDepth: boolean;
  88415. private _colorGradingBGR;
  88416. /**
  88417. * Gets wether the color grading texture contains BGR values.
  88418. */
  88419. /**
  88420. * Sets wether the color grading texture contains BGR values.
  88421. */
  88422. colorGradingBGR: boolean;
  88423. /** @hidden */
  88424. _exposure: number;
  88425. /**
  88426. * Gets the Exposure used in the effect.
  88427. */
  88428. /**
  88429. * Sets the Exposure used in the effect.
  88430. */
  88431. exposure: number;
  88432. private _toneMappingEnabled;
  88433. /**
  88434. * Gets wether the tone mapping effect is enabled.
  88435. */
  88436. /**
  88437. * Sets wether the tone mapping effect is enabled.
  88438. */
  88439. toneMappingEnabled: boolean;
  88440. private _toneMappingType;
  88441. /**
  88442. * Gets the type of tone mapping effect.
  88443. */
  88444. /**
  88445. * Sets the type of tone mapping effect used in BabylonJS.
  88446. */
  88447. toneMappingType: number;
  88448. protected _contrast: number;
  88449. /**
  88450. * Gets the contrast used in the effect.
  88451. */
  88452. /**
  88453. * Sets the contrast used in the effect.
  88454. */
  88455. contrast: number;
  88456. /**
  88457. * Vignette stretch size.
  88458. */
  88459. vignetteStretch: number;
  88460. /**
  88461. * Vignette centre X Offset.
  88462. */
  88463. vignetteCentreX: number;
  88464. /**
  88465. * Vignette centre Y Offset.
  88466. */
  88467. vignetteCentreY: number;
  88468. /**
  88469. * Vignette weight or intensity of the vignette effect.
  88470. */
  88471. vignetteWeight: number;
  88472. /**
  88473. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88474. * if vignetteEnabled is set to true.
  88475. */
  88476. vignetteColor: Color4;
  88477. /**
  88478. * Camera field of view used by the Vignette effect.
  88479. */
  88480. vignetteCameraFov: number;
  88481. private _vignetteBlendMode;
  88482. /**
  88483. * Gets the vignette blend mode allowing different kind of effect.
  88484. */
  88485. /**
  88486. * Sets the vignette blend mode allowing different kind of effect.
  88487. */
  88488. vignetteBlendMode: number;
  88489. private _vignetteEnabled;
  88490. /**
  88491. * Gets wether the vignette effect is enabled.
  88492. */
  88493. /**
  88494. * Sets wether the vignette effect is enabled.
  88495. */
  88496. vignetteEnabled: boolean;
  88497. private _applyByPostProcess;
  88498. /**
  88499. * Gets wether the image processing is applied through a post process or not.
  88500. */
  88501. /**
  88502. * Sets wether the image processing is applied through a post process or not.
  88503. */
  88504. applyByPostProcess: boolean;
  88505. private _isEnabled;
  88506. /**
  88507. * Gets wether the image processing is enabled or not.
  88508. */
  88509. /**
  88510. * Sets wether the image processing is enabled or not.
  88511. */
  88512. isEnabled: boolean;
  88513. /**
  88514. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88515. */
  88516. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88517. /**
  88518. * Method called each time the image processing information changes requires to recompile the effect.
  88519. */
  88520. protected _updateParameters(): void;
  88521. /**
  88522. * Gets the current class name.
  88523. * @return "ImageProcessingConfiguration"
  88524. */
  88525. getClassName(): string;
  88526. /**
  88527. * Prepare the list of uniforms associated with the Image Processing effects.
  88528. * @param uniforms The list of uniforms used in the effect
  88529. * @param defines the list of defines currently in use
  88530. */
  88531. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88532. /**
  88533. * Prepare the list of samplers associated with the Image Processing effects.
  88534. * @param samplersList The list of uniforms used in the effect
  88535. * @param defines the list of defines currently in use
  88536. */
  88537. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88538. /**
  88539. * Prepare the list of defines associated to the shader.
  88540. * @param defines the list of defines to complete
  88541. * @param forPostProcess Define if we are currently in post process mode or not
  88542. */
  88543. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88544. /**
  88545. * Returns true if all the image processing information are ready.
  88546. * @returns True if ready, otherwise, false
  88547. */
  88548. isReady(): boolean;
  88549. /**
  88550. * Binds the image processing to the shader.
  88551. * @param effect The effect to bind to
  88552. * @param aspectRatio Define the current aspect ratio of the effect
  88553. */
  88554. bind(effect: Effect, aspectRatio?: number): void;
  88555. /**
  88556. * Clones the current image processing instance.
  88557. * @return The cloned image processing
  88558. */
  88559. clone(): ImageProcessingConfiguration;
  88560. /**
  88561. * Serializes the current image processing instance to a json representation.
  88562. * @return a JSON representation
  88563. */
  88564. serialize(): any;
  88565. /**
  88566. * Parses the image processing from a json representation.
  88567. * @param source the JSON source to parse
  88568. * @return The parsed image processing
  88569. */
  88570. static Parse(source: any): ImageProcessingConfiguration;
  88571. private static _VIGNETTEMODE_MULTIPLY;
  88572. private static _VIGNETTEMODE_OPAQUE;
  88573. /**
  88574. * Used to apply the vignette as a mix with the pixel color.
  88575. */
  88576. static readonly VIGNETTEMODE_MULTIPLY: number;
  88577. /**
  88578. * Used to apply the vignette as a replacement of the pixel color.
  88579. */
  88580. static readonly VIGNETTEMODE_OPAQUE: number;
  88581. }
  88582. }
  88583. declare module BABYLON {
  88584. /**
  88585. * This represents all the required information to add a fresnel effect on a material:
  88586. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  88587. */
  88588. export class FresnelParameters {
  88589. private _isEnabled;
  88590. /**
  88591. * Define if the fresnel effect is enable or not.
  88592. */
  88593. isEnabled: boolean;
  88594. /**
  88595. * Define the color used on edges (grazing angle)
  88596. */
  88597. leftColor: Color3;
  88598. /**
  88599. * Define the color used on center
  88600. */
  88601. rightColor: Color3;
  88602. /**
  88603. * Define bias applied to computed fresnel term
  88604. */
  88605. bias: number;
  88606. /**
  88607. * Defined the power exponent applied to fresnel term
  88608. */
  88609. power: number;
  88610. /**
  88611. * Clones the current fresnel and its valuues
  88612. * @returns a clone fresnel configuration
  88613. */
  88614. clone(): FresnelParameters;
  88615. /**
  88616. * Serializes the current fresnel parameters to a JSON representation.
  88617. * @return the JSON serialization
  88618. */
  88619. serialize(): any;
  88620. /**
  88621. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  88622. * @param parsedFresnelParameters Define the JSON representation
  88623. * @returns the parsed parameters
  88624. */
  88625. static Parse(parsedFresnelParameters: any): FresnelParameters;
  88626. }
  88627. }
  88628. declare module BABYLON {
  88629. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  88630. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88631. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88632. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88633. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88634. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88635. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88636. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88637. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88638. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88639. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88640. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88641. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88642. /**
  88643. * Decorator used to define property that can be serialized as reference to a camera
  88644. * @param sourceName defines the name of the property to decorate
  88645. */
  88646. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88647. /**
  88648. * Class used to help serialization objects
  88649. */
  88650. export class SerializationHelper {
  88651. /** hidden */
  88652. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  88653. /** hidden */
  88654. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  88655. /** hidden */
  88656. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  88657. /** hidden */
  88658. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  88659. /**
  88660. * Appends the serialized animations from the source animations
  88661. * @param source Source containing the animations
  88662. * @param destination Target to store the animations
  88663. */
  88664. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88665. /**
  88666. * Static function used to serialized a specific entity
  88667. * @param entity defines the entity to serialize
  88668. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  88669. * @returns a JSON compatible object representing the serialization of the entity
  88670. */
  88671. static Serialize<T>(entity: T, serializationObject?: any): any;
  88672. /**
  88673. * Creates a new entity from a serialization data object
  88674. * @param creationFunction defines a function used to instanciated the new entity
  88675. * @param source defines the source serialization data
  88676. * @param scene defines the hosting scene
  88677. * @param rootUrl defines the root url for resources
  88678. * @returns a new entity
  88679. */
  88680. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  88681. /**
  88682. * Clones an object
  88683. * @param creationFunction defines the function used to instanciate the new object
  88684. * @param source defines the source object
  88685. * @returns the cloned object
  88686. */
  88687. static Clone<T>(creationFunction: () => T, source: T): T;
  88688. /**
  88689. * Instanciates a new object based on a source one (some data will be shared between both object)
  88690. * @param creationFunction defines the function used to instanciate the new object
  88691. * @param source defines the source object
  88692. * @returns the new object
  88693. */
  88694. static Instanciate<T>(creationFunction: () => T, source: T): T;
  88695. }
  88696. }
  88697. declare module BABYLON {
  88698. /**
  88699. * This is the base class of all the camera used in the application.
  88700. * @see http://doc.babylonjs.com/features/cameras
  88701. */
  88702. export class Camera extends Node {
  88703. /** @hidden */
  88704. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88705. /**
  88706. * This is the default projection mode used by the cameras.
  88707. * It helps recreating a feeling of perspective and better appreciate depth.
  88708. * This is the best way to simulate real life cameras.
  88709. */
  88710. static readonly PERSPECTIVE_CAMERA: number;
  88711. /**
  88712. * This helps creating camera with an orthographic mode.
  88713. * 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.
  88714. */
  88715. static readonly ORTHOGRAPHIC_CAMERA: number;
  88716. /**
  88717. * This is the default FOV mode for perspective cameras.
  88718. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88719. */
  88720. static readonly FOVMODE_VERTICAL_FIXED: number;
  88721. /**
  88722. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88723. */
  88724. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88725. /**
  88726. * This specifies ther is no need for a camera rig.
  88727. * Basically only one eye is rendered corresponding to the camera.
  88728. */
  88729. static readonly RIG_MODE_NONE: number;
  88730. /**
  88731. * Simulates a camera Rig with one blue eye and one red eye.
  88732. * This can be use with 3d blue and red glasses.
  88733. */
  88734. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88735. /**
  88736. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88737. */
  88738. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88739. /**
  88740. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88741. */
  88742. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88743. /**
  88744. * Defines that both eyes of the camera will be rendered over under each other.
  88745. */
  88746. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88747. /**
  88748. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88749. */
  88750. static readonly RIG_MODE_VR: number;
  88751. /**
  88752. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88753. */
  88754. static readonly RIG_MODE_WEBVR: number;
  88755. /**
  88756. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88757. */
  88758. static readonly RIG_MODE_CUSTOM: number;
  88759. /**
  88760. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88761. */
  88762. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88763. /**
  88764. * Define the input manager associated with the camera.
  88765. */
  88766. inputs: CameraInputsManager<Camera>;
  88767. /** @hidden */
  88768. _position: Vector3;
  88769. /**
  88770. * Define the current local position of the camera in the scene
  88771. */
  88772. position: Vector3;
  88773. /**
  88774. * The vector the camera should consider as up.
  88775. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88776. */
  88777. upVector: Vector3;
  88778. /**
  88779. * Define the current limit on the left side for an orthographic camera
  88780. * In scene unit
  88781. */
  88782. orthoLeft: Nullable<number>;
  88783. /**
  88784. * Define the current limit on the right side for an orthographic camera
  88785. * In scene unit
  88786. */
  88787. orthoRight: Nullable<number>;
  88788. /**
  88789. * Define the current limit on the bottom side for an orthographic camera
  88790. * In scene unit
  88791. */
  88792. orthoBottom: Nullable<number>;
  88793. /**
  88794. * Define the current limit on the top side for an orthographic camera
  88795. * In scene unit
  88796. */
  88797. orthoTop: Nullable<number>;
  88798. /**
  88799. * Field Of View is set in Radians. (default is 0.8)
  88800. */
  88801. fov: number;
  88802. /**
  88803. * Define the minimum distance the camera can see from.
  88804. * This is important to note that the depth buffer are not infinite and the closer it starts
  88805. * the more your scene might encounter depth fighting issue.
  88806. */
  88807. minZ: number;
  88808. /**
  88809. * Define the maximum distance the camera can see to.
  88810. * This is important to note that the depth buffer are not infinite and the further it end
  88811. * the more your scene might encounter depth fighting issue.
  88812. */
  88813. maxZ: number;
  88814. /**
  88815. * Define the default inertia of the camera.
  88816. * This helps giving a smooth feeling to the camera movement.
  88817. */
  88818. inertia: number;
  88819. /**
  88820. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  88821. */
  88822. mode: number;
  88823. /**
  88824. * Define wether the camera is intermediate.
  88825. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88826. */
  88827. isIntermediate: boolean;
  88828. /**
  88829. * Define the viewport of the camera.
  88830. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88831. */
  88832. viewport: Viewport;
  88833. /**
  88834. * Restricts the camera to viewing objects with the same layerMask.
  88835. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88836. */
  88837. layerMask: number;
  88838. /**
  88839. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88840. */
  88841. fovMode: number;
  88842. /**
  88843. * Rig mode of the camera.
  88844. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88845. * This is normally controlled byt the camera themselves as internal use.
  88846. */
  88847. cameraRigMode: number;
  88848. /**
  88849. * Defines the distance between both "eyes" in case of a RIG
  88850. */
  88851. interaxialDistance: number;
  88852. /**
  88853. * Defines if stereoscopic rendering is done side by side or over under.
  88854. */
  88855. isStereoscopicSideBySide: boolean;
  88856. /**
  88857. * 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
  88858. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88859. * else in the scene.
  88860. */
  88861. customRenderTargets: RenderTargetTexture[];
  88862. /**
  88863. * When set, the camera will render to this render target instead of the default canvas
  88864. */
  88865. outputRenderTarget: Nullable<RenderTargetTexture>;
  88866. /**
  88867. * @hidden
  88868. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  88869. */
  88870. _useMultiviewToSingleView: boolean;
  88871. /**
  88872. * @hidden
  88873. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  88874. */
  88875. _multiviewTexture: Nullable<RenderTargetTexture>;
  88876. /**
  88877. * @hidden
  88878. * ensures the multiview texture of the camera exists and has the specified width/height
  88879. * @param width height to set on the multiview texture
  88880. * @param height width to set on the multiview texture
  88881. */
  88882. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  88883. /**
  88884. * Observable triggered when the camera view matrix has changed.
  88885. */
  88886. onViewMatrixChangedObservable: Observable<Camera>;
  88887. /**
  88888. * Observable triggered when the camera Projection matrix has changed.
  88889. */
  88890. onProjectionMatrixChangedObservable: Observable<Camera>;
  88891. /**
  88892. * Observable triggered when the inputs have been processed.
  88893. */
  88894. onAfterCheckInputsObservable: Observable<Camera>;
  88895. /**
  88896. * Observable triggered when reset has been called and applied to the camera.
  88897. */
  88898. onRestoreStateObservable: Observable<Camera>;
  88899. /** @hidden */
  88900. _cameraRigParams: any;
  88901. /** @hidden */
  88902. _rigCameras: Camera[];
  88903. /** @hidden */
  88904. _rigPostProcess: Nullable<PostProcess>;
  88905. protected _webvrViewMatrix: Matrix;
  88906. /** @hidden */
  88907. _skipRendering: boolean;
  88908. /** @hidden */
  88909. _projectionMatrix: Matrix;
  88910. /** @hidden */
  88911. _postProcesses: Nullable<PostProcess>[];
  88912. /** @hidden */
  88913. _activeMeshes: SmartArray<AbstractMesh>;
  88914. protected _globalPosition: Vector3;
  88915. /** hidden */
  88916. _computedViewMatrix: Matrix;
  88917. private _doNotComputeProjectionMatrix;
  88918. private _transformMatrix;
  88919. private _frustumPlanes;
  88920. private _refreshFrustumPlanes;
  88921. private _storedFov;
  88922. private _stateStored;
  88923. /**
  88924. * Instantiates a new camera object.
  88925. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88926. * @see http://doc.babylonjs.com/features/cameras
  88927. * @param name Defines the name of the camera in the scene
  88928. * @param position Defines the position of the camera
  88929. * @param scene Defines the scene the camera belongs too
  88930. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88931. */
  88932. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88933. /**
  88934. * Store current camera state (fov, position, etc..)
  88935. * @returns the camera
  88936. */
  88937. storeState(): Camera;
  88938. /**
  88939. * Restores the camera state values if it has been stored. You must call storeState() first
  88940. */
  88941. protected _restoreStateValues(): boolean;
  88942. /**
  88943. * Restored camera state. You must call storeState() first.
  88944. * @returns true if restored and false otherwise
  88945. */
  88946. restoreState(): boolean;
  88947. /**
  88948. * Gets the class name of the camera.
  88949. * @returns the class name
  88950. */
  88951. getClassName(): string;
  88952. /** @hidden */
  88953. readonly _isCamera: boolean;
  88954. /**
  88955. * Gets a string representation of the camera useful for debug purpose.
  88956. * @param fullDetails Defines that a more verboe level of logging is required
  88957. * @returns the string representation
  88958. */
  88959. toString(fullDetails?: boolean): string;
  88960. /**
  88961. * Gets the current world space position of the camera.
  88962. */
  88963. readonly globalPosition: Vector3;
  88964. /**
  88965. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88966. * @returns the active meshe list
  88967. */
  88968. getActiveMeshes(): SmartArray<AbstractMesh>;
  88969. /**
  88970. * Check wether a mesh is part of the current active mesh list of the camera
  88971. * @param mesh Defines the mesh to check
  88972. * @returns true if active, false otherwise
  88973. */
  88974. isActiveMesh(mesh: Mesh): boolean;
  88975. /**
  88976. * Is this camera ready to be used/rendered
  88977. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88978. * @return true if the camera is ready
  88979. */
  88980. isReady(completeCheck?: boolean): boolean;
  88981. /** @hidden */
  88982. _initCache(): void;
  88983. /** @hidden */
  88984. _updateCache(ignoreParentClass?: boolean): void;
  88985. /** @hidden */
  88986. _isSynchronized(): boolean;
  88987. /** @hidden */
  88988. _isSynchronizedViewMatrix(): boolean;
  88989. /** @hidden */
  88990. _isSynchronizedProjectionMatrix(): boolean;
  88991. /**
  88992. * Attach the input controls to a specific dom element to get the input from.
  88993. * @param element Defines the element the controls should be listened from
  88994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88995. */
  88996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88997. /**
  88998. * Detach the current controls from the specified dom element.
  88999. * @param element Defines the element to stop listening the inputs from
  89000. */
  89001. detachControl(element: HTMLElement): void;
  89002. /**
  89003. * Update the camera state according to the different inputs gathered during the frame.
  89004. */
  89005. update(): void;
  89006. /** @hidden */
  89007. _checkInputs(): void;
  89008. /** @hidden */
  89009. readonly rigCameras: Camera[];
  89010. /**
  89011. * Gets the post process used by the rig cameras
  89012. */
  89013. readonly rigPostProcess: Nullable<PostProcess>;
  89014. /**
  89015. * Internal, gets the first post proces.
  89016. * @returns the first post process to be run on this camera.
  89017. */
  89018. _getFirstPostProcess(): Nullable<PostProcess>;
  89019. private _cascadePostProcessesToRigCams;
  89020. /**
  89021. * Attach a post process to the camera.
  89022. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89023. * @param postProcess The post process to attach to the camera
  89024. * @param insertAt The position of the post process in case several of them are in use in the scene
  89025. * @returns the position the post process has been inserted at
  89026. */
  89027. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89028. /**
  89029. * Detach a post process to the camera.
  89030. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89031. * @param postProcess The post process to detach from the camera
  89032. */
  89033. detachPostProcess(postProcess: PostProcess): void;
  89034. /**
  89035. * Gets the current world matrix of the camera
  89036. */
  89037. getWorldMatrix(): Matrix;
  89038. /** @hidden */
  89039. _getViewMatrix(): Matrix;
  89040. /**
  89041. * Gets the current view matrix of the camera.
  89042. * @param force forces the camera to recompute the matrix without looking at the cached state
  89043. * @returns the view matrix
  89044. */
  89045. getViewMatrix(force?: boolean): Matrix;
  89046. /**
  89047. * Freeze the projection matrix.
  89048. * It will prevent the cache check of the camera projection compute and can speed up perf
  89049. * if no parameter of the camera are meant to change
  89050. * @param projection Defines manually a projection if necessary
  89051. */
  89052. freezeProjectionMatrix(projection?: Matrix): void;
  89053. /**
  89054. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89055. */
  89056. unfreezeProjectionMatrix(): void;
  89057. /**
  89058. * Gets the current projection matrix of the camera.
  89059. * @param force forces the camera to recompute the matrix without looking at the cached state
  89060. * @returns the projection matrix
  89061. */
  89062. getProjectionMatrix(force?: boolean): Matrix;
  89063. /**
  89064. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89065. * @returns a Matrix
  89066. */
  89067. getTransformationMatrix(): Matrix;
  89068. private _updateFrustumPlanes;
  89069. /**
  89070. * Checks if a cullable object (mesh...) is in the camera frustum
  89071. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89072. * @param target The object to check
  89073. * @returns true if the object is in frustum otherwise false
  89074. */
  89075. isInFrustum(target: ICullable): boolean;
  89076. /**
  89077. * Checks if a cullable object (mesh...) is in the camera frustum
  89078. * Unlike isInFrustum this cheks the full bounding box
  89079. * @param target The object to check
  89080. * @returns true if the object is in frustum otherwise false
  89081. */
  89082. isCompletelyInFrustum(target: ICullable): boolean;
  89083. /**
  89084. * Gets a ray in the forward direction from the camera.
  89085. * @param length Defines the length of the ray to create
  89086. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89087. * @param origin Defines the start point of the ray which defaults to the camera position
  89088. * @returns the forward ray
  89089. */
  89090. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89091. /**
  89092. * Releases resources associated with this node.
  89093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89095. */
  89096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89097. /** @hidden */
  89098. _isLeftCamera: boolean;
  89099. /**
  89100. * Gets the left camera of a rig setup in case of Rigged Camera
  89101. */
  89102. readonly isLeftCamera: boolean;
  89103. /** @hidden */
  89104. _isRightCamera: boolean;
  89105. /**
  89106. * Gets the right camera of a rig setup in case of Rigged Camera
  89107. */
  89108. readonly isRightCamera: boolean;
  89109. /**
  89110. * Gets the left camera of a rig setup in case of Rigged Camera
  89111. */
  89112. readonly leftCamera: Nullable<FreeCamera>;
  89113. /**
  89114. * Gets the right camera of a rig setup in case of Rigged Camera
  89115. */
  89116. readonly rightCamera: Nullable<FreeCamera>;
  89117. /**
  89118. * Gets the left camera target of a rig setup in case of Rigged Camera
  89119. * @returns the target position
  89120. */
  89121. getLeftTarget(): Nullable<Vector3>;
  89122. /**
  89123. * Gets the right camera target of a rig setup in case of Rigged Camera
  89124. * @returns the target position
  89125. */
  89126. getRightTarget(): Nullable<Vector3>;
  89127. /**
  89128. * @hidden
  89129. */
  89130. setCameraRigMode(mode: number, rigParams: any): void;
  89131. /** @hidden */
  89132. static _setStereoscopicRigMode(camera: Camera): void;
  89133. /** @hidden */
  89134. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89135. /** @hidden */
  89136. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89137. /** @hidden */
  89138. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89139. /** @hidden */
  89140. _getVRProjectionMatrix(): Matrix;
  89141. protected _updateCameraRotationMatrix(): void;
  89142. protected _updateWebVRCameraRotationMatrix(): void;
  89143. /**
  89144. * This function MUST be overwritten by the different WebVR cameras available.
  89145. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89146. * @hidden
  89147. */
  89148. _getWebVRProjectionMatrix(): Matrix;
  89149. /**
  89150. * This function MUST be overwritten by the different WebVR cameras available.
  89151. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89152. * @hidden
  89153. */
  89154. _getWebVRViewMatrix(): Matrix;
  89155. /** @hidden */
  89156. setCameraRigParameter(name: string, value: any): void;
  89157. /**
  89158. * needs to be overridden by children so sub has required properties to be copied
  89159. * @hidden
  89160. */
  89161. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89162. /**
  89163. * May need to be overridden by children
  89164. * @hidden
  89165. */
  89166. _updateRigCameras(): void;
  89167. /** @hidden */
  89168. _setupInputs(): void;
  89169. /**
  89170. * Serialiaze the camera setup to a json represention
  89171. * @returns the JSON representation
  89172. */
  89173. serialize(): any;
  89174. /**
  89175. * Clones the current camera.
  89176. * @param name The cloned camera name
  89177. * @returns the cloned camera
  89178. */
  89179. clone(name: string): Camera;
  89180. /**
  89181. * Gets the direction of the camera relative to a given local axis.
  89182. * @param localAxis Defines the reference axis to provide a relative direction.
  89183. * @return the direction
  89184. */
  89185. getDirection(localAxis: Vector3): Vector3;
  89186. /**
  89187. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89188. * @param localAxis Defines the reference axis to provide a relative direction.
  89189. * @param result Defines the vector to store the result in
  89190. */
  89191. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89192. /**
  89193. * Gets a camera constructor for a given camera type
  89194. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89195. * @param name The name of the camera the result will be able to instantiate
  89196. * @param scene The scene the result will construct the camera in
  89197. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89198. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89199. * @returns a factory method to construc the camera
  89200. */
  89201. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89202. /**
  89203. * Compute the world matrix of the camera.
  89204. * @returns the camera workd matrix
  89205. */
  89206. computeWorldMatrix(): Matrix;
  89207. /**
  89208. * Parse a JSON and creates the camera from the parsed information
  89209. * @param parsedCamera The JSON to parse
  89210. * @param scene The scene to instantiate the camera in
  89211. * @returns the newly constructed camera
  89212. */
  89213. static Parse(parsedCamera: any, scene: Scene): Camera;
  89214. }
  89215. }
  89216. declare module BABYLON {
  89217. /**
  89218. * Interface for any object that can request an animation frame
  89219. */
  89220. export interface ICustomAnimationFrameRequester {
  89221. /**
  89222. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89223. */
  89224. renderFunction?: Function;
  89225. /**
  89226. * Called to request the next frame to render to
  89227. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89228. */
  89229. requestAnimationFrame: Function;
  89230. /**
  89231. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89232. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89233. */
  89234. requestID?: number;
  89235. }
  89236. /**
  89237. * Interface containing an array of animations
  89238. */
  89239. export interface IAnimatable {
  89240. /**
  89241. * Array of animations
  89242. */
  89243. animations: Array<Animation>;
  89244. }
  89245. /** Interface used by value gradients (color, factor, ...) */
  89246. export interface IValueGradient {
  89247. /**
  89248. * Gets or sets the gradient value (between 0 and 1)
  89249. */
  89250. gradient: number;
  89251. }
  89252. /** Class used to store color4 gradient */
  89253. export class ColorGradient implements IValueGradient {
  89254. /**
  89255. * Gets or sets the gradient value (between 0 and 1)
  89256. */
  89257. gradient: number;
  89258. /**
  89259. * Gets or sets first associated color
  89260. */
  89261. color1: Color4;
  89262. /**
  89263. * Gets or sets second associated color
  89264. */
  89265. color2?: Color4;
  89266. /**
  89267. * Will get a color picked randomly between color1 and color2.
  89268. * If color2 is undefined then color1 will be used
  89269. * @param result defines the target Color4 to store the result in
  89270. */
  89271. getColorToRef(result: Color4): void;
  89272. }
  89273. /** Class used to store color 3 gradient */
  89274. export class Color3Gradient implements IValueGradient {
  89275. /**
  89276. * Gets or sets the gradient value (between 0 and 1)
  89277. */
  89278. gradient: number;
  89279. /**
  89280. * Gets or sets the associated color
  89281. */
  89282. color: Color3;
  89283. }
  89284. /** Class used to store factor gradient */
  89285. export class FactorGradient implements IValueGradient {
  89286. /**
  89287. * Gets or sets the gradient value (between 0 and 1)
  89288. */
  89289. gradient: number;
  89290. /**
  89291. * Gets or sets first associated factor
  89292. */
  89293. factor1: number;
  89294. /**
  89295. * Gets or sets second associated factor
  89296. */
  89297. factor2?: number;
  89298. /**
  89299. * Will get a number picked randomly between factor1 and factor2.
  89300. * If factor2 is undefined then factor1 will be used
  89301. * @returns the picked number
  89302. */
  89303. getFactor(): number;
  89304. }
  89305. /**
  89306. * @ignore
  89307. * Application error to support additional information when loading a file
  89308. */
  89309. export class LoadFileError extends Error {
  89310. /** defines the optional web request */
  89311. request?: WebRequest | undefined;
  89312. private static _setPrototypeOf;
  89313. /**
  89314. * Creates a new LoadFileError
  89315. * @param message defines the message of the error
  89316. * @param request defines the optional web request
  89317. */
  89318. constructor(message: string,
  89319. /** defines the optional web request */
  89320. request?: WebRequest | undefined);
  89321. }
  89322. /**
  89323. * Class used to define a retry strategy when error happens while loading assets
  89324. */
  89325. export class RetryStrategy {
  89326. /**
  89327. * Function used to defines an exponential back off strategy
  89328. * @param maxRetries defines the maximum number of retries (3 by default)
  89329. * @param baseInterval defines the interval between retries
  89330. * @returns the strategy function to use
  89331. */
  89332. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  89333. }
  89334. /**
  89335. * File request interface
  89336. */
  89337. export interface IFileRequest {
  89338. /**
  89339. * Raised when the request is complete (success or error).
  89340. */
  89341. onCompleteObservable: Observable<IFileRequest>;
  89342. /**
  89343. * Aborts the request for a file.
  89344. */
  89345. abort: () => void;
  89346. }
  89347. /**
  89348. * Class containing a set of static utilities functions
  89349. */
  89350. export class Tools {
  89351. /**
  89352. * Gets or sets the base URL to use to load assets
  89353. */
  89354. static BaseUrl: string;
  89355. /**
  89356. * Enable/Disable Custom HTTP Request Headers globally.
  89357. * default = false
  89358. * @see CustomRequestHeaders
  89359. */
  89360. static UseCustomRequestHeaders: boolean;
  89361. /**
  89362. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  89363. * i.e. when loading files, where the server/service expects an Authorization header
  89364. */
  89365. static CustomRequestHeaders: {
  89366. [key: string]: string;
  89367. };
  89368. /**
  89369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  89370. */
  89371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  89372. /**
  89373. * Default behaviour for cors in the application.
  89374. * It can be a string if the expected behavior is identical in the entire app.
  89375. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  89376. */
  89377. static CorsBehavior: string | ((url: string | string[]) => string);
  89378. /**
  89379. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  89380. * @ignorenaming
  89381. */
  89382. static UseFallbackTexture: boolean;
  89383. /**
  89384. * Use this object to register external classes like custom textures or material
  89385. * to allow the laoders to instantiate them
  89386. */
  89387. static RegisteredExternalClasses: {
  89388. [key: string]: Object;
  89389. };
  89390. /**
  89391. * Texture content used if a texture cannot loaded
  89392. * @ignorenaming
  89393. */
  89394. static fallbackTexture: string;
  89395. /**
  89396. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  89397. * @param u defines the coordinate on X axis
  89398. * @param v defines the coordinate on Y axis
  89399. * @param width defines the width of the source data
  89400. * @param height defines the height of the source data
  89401. * @param pixels defines the source byte array
  89402. * @param color defines the output color
  89403. */
  89404. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  89405. /**
  89406. * Interpolates between a and b via alpha
  89407. * @param a The lower value (returned when alpha = 0)
  89408. * @param b The upper value (returned when alpha = 1)
  89409. * @param alpha The interpolation-factor
  89410. * @return The mixed value
  89411. */
  89412. static Mix(a: number, b: number, alpha: number): number;
  89413. /**
  89414. * Tries to instantiate a new object from a given class name
  89415. * @param className defines the class name to instantiate
  89416. * @returns the new object or null if the system was not able to do the instantiation
  89417. */
  89418. static Instantiate(className: string): any;
  89419. /**
  89420. * Provides a slice function that will work even on IE
  89421. * @param data defines the array to slice
  89422. * @param start defines the start of the data (optional)
  89423. * @param end defines the end of the data (optional)
  89424. * @returns the new sliced array
  89425. */
  89426. static Slice<T>(data: T, start?: number, end?: number): T;
  89427. /**
  89428. * Polyfill for setImmediate
  89429. * @param action defines the action to execute after the current execution block
  89430. */
  89431. static SetImmediate(action: () => void): void;
  89432. /**
  89433. * Function indicating if a number is an exponent of 2
  89434. * @param value defines the value to test
  89435. * @returns true if the value is an exponent of 2
  89436. */
  89437. static IsExponentOfTwo(value: number): boolean;
  89438. private static _tmpFloatArray;
  89439. /**
  89440. * Returns the nearest 32-bit single precision float representation of a Number
  89441. * @param value A Number. If the parameter is of a different type, it will get converted
  89442. * to a number or to NaN if it cannot be converted
  89443. * @returns number
  89444. */
  89445. static FloatRound(value: number): number;
  89446. /**
  89447. * Find the next highest power of two.
  89448. * @param x Number to start search from.
  89449. * @return Next highest power of two.
  89450. */
  89451. static CeilingPOT(x: number): number;
  89452. /**
  89453. * Find the next lowest power of two.
  89454. * @param x Number to start search from.
  89455. * @return Next lowest power of two.
  89456. */
  89457. static FloorPOT(x: number): number;
  89458. /**
  89459. * Find the nearest power of two.
  89460. * @param x Number to start search from.
  89461. * @return Next nearest power of two.
  89462. */
  89463. static NearestPOT(x: number): number;
  89464. /**
  89465. * Get the closest exponent of two
  89466. * @param value defines the value to approximate
  89467. * @param max defines the maximum value to return
  89468. * @param mode defines how to define the closest value
  89469. * @returns closest exponent of two of the given value
  89470. */
  89471. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  89472. /**
  89473. * Extracts the filename from a path
  89474. * @param path defines the path to use
  89475. * @returns the filename
  89476. */
  89477. static GetFilename(path: string): string;
  89478. /**
  89479. * Extracts the "folder" part of a path (everything before the filename).
  89480. * @param uri The URI to extract the info from
  89481. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89482. * @returns The "folder" part of the path
  89483. */
  89484. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89485. /**
  89486. * Extracts text content from a DOM element hierarchy
  89487. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89488. */
  89489. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89490. /**
  89491. * Convert an angle in radians to degrees
  89492. * @param angle defines the angle to convert
  89493. * @returns the angle in degrees
  89494. */
  89495. static ToDegrees(angle: number): number;
  89496. /**
  89497. * Convert an angle in degrees to radians
  89498. * @param angle defines the angle to convert
  89499. * @returns the angle in radians
  89500. */
  89501. static ToRadians(angle: number): number;
  89502. /**
  89503. * Encode a buffer to a base64 string
  89504. * @param buffer defines the buffer to encode
  89505. * @returns the encoded string
  89506. */
  89507. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89508. /**
  89509. * Extracts minimum and maximum values from a list of indexed positions
  89510. * @param positions defines the positions to use
  89511. * @param indices defines the indices to the positions
  89512. * @param indexStart defines the start index
  89513. * @param indexCount defines the end index
  89514. * @param bias defines bias value to add to the result
  89515. * @return minimum and maximum values
  89516. */
  89517. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89518. minimum: Vector3;
  89519. maximum: Vector3;
  89520. };
  89521. /**
  89522. * Extracts minimum and maximum values from a list of positions
  89523. * @param positions defines the positions to use
  89524. * @param start defines the start index in the positions array
  89525. * @param count defines the number of positions to handle
  89526. * @param bias defines bias value to add to the result
  89527. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89528. * @return minimum and maximum values
  89529. */
  89530. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89531. minimum: Vector3;
  89532. maximum: Vector3;
  89533. };
  89534. /**
  89535. * Returns an array if obj is not an array
  89536. * @param obj defines the object to evaluate as an array
  89537. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89538. * @returns either obj directly if obj is an array or a new array containing obj
  89539. */
  89540. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89541. /**
  89542. * Gets the pointer prefix to use
  89543. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89544. */
  89545. static GetPointerPrefix(): string;
  89546. /**
  89547. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89548. * @param func - the function to be called
  89549. * @param requester - the object that will request the next frame. Falls back to window.
  89550. * @returns frame number
  89551. */
  89552. static QueueNewFrame(func: () => void, requester?: any): number;
  89553. /**
  89554. * Ask the browser to promote the current element to fullscreen rendering mode
  89555. * @param element defines the DOM element to promote
  89556. */
  89557. static RequestFullscreen(element: HTMLElement): void;
  89558. /**
  89559. * Asks the browser to exit fullscreen mode
  89560. */
  89561. static ExitFullscreen(): void;
  89562. /**
  89563. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89564. * @param url define the url we are trying
  89565. * @param element define the dom element where to configure the cors policy
  89566. */
  89567. static SetCorsBehavior(url: string | string[], element: {
  89568. crossOrigin: string | null;
  89569. }): void;
  89570. /**
  89571. * Removes unwanted characters from an url
  89572. * @param url defines the url to clean
  89573. * @returns the cleaned url
  89574. */
  89575. static CleanUrl(url: string): string;
  89576. /**
  89577. * Gets or sets a function used to pre-process url before using them to load assets
  89578. */
  89579. static PreprocessUrl: (url: string) => string;
  89580. /**
  89581. * Loads an image as an HTMLImageElement.
  89582. * @param input url string, ArrayBuffer, or Blob to load
  89583. * @param onLoad callback called when the image successfully loads
  89584. * @param onError callback called when the image fails to load
  89585. * @param offlineProvider offline provider for caching
  89586. * @returns the HTMLImageElement of the loaded image
  89587. */
  89588. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89589. /**
  89590. * Loads a file
  89591. * @param url url string, ArrayBuffer, or Blob to load
  89592. * @param onSuccess callback called when the file successfully loads
  89593. * @param onProgress callback called while file is loading (if the server supports this mode)
  89594. * @param offlineProvider defines the offline provider for caching
  89595. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  89596. * @param onError callback called when the file fails to load
  89597. * @returns a file request object
  89598. */
  89599. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  89600. /**
  89601. * Load a script (identified by an url). When the url returns, the
  89602. * content of this file is added into a new script element, attached to the DOM (body element)
  89603. * @param scriptUrl defines the url of the script to laod
  89604. * @param onSuccess defines the callback called when the script is loaded
  89605. * @param onError defines the callback to call if an error occurs
  89606. */
  89607. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  89608. /**
  89609. * Loads a file from a blob
  89610. * @param fileToLoad defines the blob to use
  89611. * @param callback defines the callback to call when data is loaded
  89612. * @param progressCallback defines the callback to call during loading process
  89613. * @returns a file request object
  89614. */
  89615. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  89616. /**
  89617. * Loads a file
  89618. * @param fileToLoad defines the file to load
  89619. * @param callback defines the callback to call when data is loaded
  89620. * @param progressCallBack defines the callback to call during loading process
  89621. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  89622. * @returns a file request object
  89623. */
  89624. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  89625. /**
  89626. * Creates a data url from a given string content
  89627. * @param content defines the content to convert
  89628. * @returns the new data url link
  89629. */
  89630. static FileAsURL(content: string): string;
  89631. /**
  89632. * Format the given number to a specific decimal format
  89633. * @param value defines the number to format
  89634. * @param decimals defines the number of decimals to use
  89635. * @returns the formatted string
  89636. */
  89637. static Format(value: number, decimals?: number): string;
  89638. /**
  89639. * Checks if a given vector is inside a specific range
  89640. * @param v defines the vector to test
  89641. * @param min defines the minimum range
  89642. * @param max defines the maximum range
  89643. */
  89644. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89645. /**
  89646. * Tries to copy an object by duplicating every property
  89647. * @param source defines the source object
  89648. * @param destination defines the target object
  89649. * @param doNotCopyList defines a list of properties to avoid
  89650. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  89651. */
  89652. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  89653. /**
  89654. * Gets a boolean indicating if the given object has no own property
  89655. * @param obj defines the object to test
  89656. * @returns true if object has no own property
  89657. */
  89658. static IsEmpty(obj: any): boolean;
  89659. /**
  89660. * Function used to register events at window level
  89661. * @param events defines the events to register
  89662. */
  89663. static RegisterTopRootEvents(events: {
  89664. name: string;
  89665. handler: Nullable<(e: FocusEvent) => any>;
  89666. }[]): void;
  89667. /**
  89668. * Function used to unregister events from window level
  89669. * @param events defines the events to unregister
  89670. */
  89671. static UnregisterTopRootEvents(events: {
  89672. name: string;
  89673. handler: Nullable<(e: FocusEvent) => any>;
  89674. }[]): void;
  89675. /**
  89676. * @ignore
  89677. */
  89678. static _ScreenshotCanvas: HTMLCanvasElement;
  89679. /**
  89680. * Dumps the current bound framebuffer
  89681. * @param width defines the rendering width
  89682. * @param height defines the rendering height
  89683. * @param engine defines the hosting engine
  89684. * @param successCallback defines the callback triggered once the data are available
  89685. * @param mimeType defines the mime type of the result
  89686. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  89687. */
  89688. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89689. /**
  89690. * Converts the canvas data to blob.
  89691. * This acts as a polyfill for browsers not supporting the to blob function.
  89692. * @param canvas Defines the canvas to extract the data from
  89693. * @param successCallback Defines the callback triggered once the data are available
  89694. * @param mimeType Defines the mime type of the result
  89695. */
  89696. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  89697. /**
  89698. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  89699. * @param successCallback defines the callback triggered once the data are available
  89700. * @param mimeType defines the mime type of the result
  89701. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  89702. */
  89703. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89704. /**
  89705. * Downloads a blob in the browser
  89706. * @param blob defines the blob to download
  89707. * @param fileName defines the name of the downloaded file
  89708. */
  89709. static Download(blob: Blob, fileName: string): void;
  89710. /**
  89711. * Captures a screenshot of the current rendering
  89712. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89713. * @param engine defines the rendering engine
  89714. * @param camera defines the source camera
  89715. * @param size This parameter can be set to a single number or to an object with the
  89716. * following (optional) properties: precision, width, height. If a single number is passed,
  89717. * it will be used for both width and height. If an object is passed, the screenshot size
  89718. * will be derived from the parameters. The precision property is a multiplier allowing
  89719. * rendering at a higher or lower resolution
  89720. * @param successCallback defines the callback receives a single parameter which contains the
  89721. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89722. * src parameter of an <img> to display it
  89723. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  89724. * Check your browser for supported MIME types
  89725. */
  89726. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  89727. /**
  89728. * Generates an image screenshot from the specified camera.
  89729. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89730. * @param engine The engine to use for rendering
  89731. * @param camera The camera to use for rendering
  89732. * @param size This parameter can be set to a single number or to an object with the
  89733. * following (optional) properties: precision, width, height. If a single number is passed,
  89734. * it will be used for both width and height. If an object is passed, the screenshot size
  89735. * will be derived from the parameters. The precision property is a multiplier allowing
  89736. * rendering at a higher or lower resolution
  89737. * @param successCallback The callback receives a single parameter which contains the
  89738. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89739. * src parameter of an <img> to display it
  89740. * @param mimeType The MIME type of the screenshot image (default: image/png).
  89741. * Check your browser for supported MIME types
  89742. * @param samples Texture samples (default: 1)
  89743. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  89744. * @param fileName A name for for the downloaded file.
  89745. */
  89746. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  89747. /**
  89748. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89749. * Be aware Math.random() could cause collisions, but:
  89750. * "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"
  89751. * @returns a pseudo random id
  89752. */
  89753. static RandomId(): string;
  89754. /**
  89755. * Test if the given uri is a base64 string
  89756. * @param uri The uri to test
  89757. * @return True if the uri is a base64 string or false otherwise
  89758. */
  89759. static IsBase64(uri: string): boolean;
  89760. /**
  89761. * Decode the given base64 uri.
  89762. * @param uri The uri to decode
  89763. * @return The decoded base64 data.
  89764. */
  89765. static DecodeBase64(uri: string): ArrayBuffer;
  89766. /**
  89767. * No log
  89768. */
  89769. static readonly NoneLogLevel: number;
  89770. /**
  89771. * Only message logs
  89772. */
  89773. static readonly MessageLogLevel: number;
  89774. /**
  89775. * Only warning logs
  89776. */
  89777. static readonly WarningLogLevel: number;
  89778. /**
  89779. * Only error logs
  89780. */
  89781. static readonly ErrorLogLevel: number;
  89782. /**
  89783. * All logs
  89784. */
  89785. static readonly AllLogLevel: number;
  89786. /**
  89787. * Gets a value indicating the number of loading errors
  89788. * @ignorenaming
  89789. */
  89790. static readonly errorsCount: number;
  89791. /**
  89792. * Callback called when a new log is added
  89793. */
  89794. static OnNewCacheEntry: (entry: string) => void;
  89795. /**
  89796. * Log a message to the console
  89797. * @param message defines the message to log
  89798. */
  89799. static Log(message: string): void;
  89800. /**
  89801. * Write a warning message to the console
  89802. * @param message defines the message to log
  89803. */
  89804. static Warn(message: string): void;
  89805. /**
  89806. * Write an error message to the console
  89807. * @param message defines the message to log
  89808. */
  89809. static Error(message: string): void;
  89810. /**
  89811. * Gets current log cache (list of logs)
  89812. */
  89813. static readonly LogCache: string;
  89814. /**
  89815. * Clears the log cache
  89816. */
  89817. static ClearLogCache(): void;
  89818. /**
  89819. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  89820. */
  89821. static LogLevels: number;
  89822. /**
  89823. * Checks if the loaded document was accessed via `file:`-Protocol.
  89824. * @returns boolean
  89825. */
  89826. static IsFileURL(): boolean;
  89827. /**
  89828. * Checks if the window object exists
  89829. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  89830. */
  89831. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  89832. /**
  89833. * No performance log
  89834. */
  89835. static readonly PerformanceNoneLogLevel: number;
  89836. /**
  89837. * Use user marks to log performance
  89838. */
  89839. static readonly PerformanceUserMarkLogLevel: number;
  89840. /**
  89841. * Log performance to the console
  89842. */
  89843. static readonly PerformanceConsoleLogLevel: number;
  89844. private static _performance;
  89845. /**
  89846. * Sets the current performance log level
  89847. */
  89848. static PerformanceLogLevel: number;
  89849. private static _StartPerformanceCounterDisabled;
  89850. private static _EndPerformanceCounterDisabled;
  89851. private static _StartUserMark;
  89852. private static _EndUserMark;
  89853. private static _StartPerformanceConsole;
  89854. private static _EndPerformanceConsole;
  89855. /**
  89856. * Starts a performance counter
  89857. */
  89858. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89859. /**
  89860. * Ends a specific performance coutner
  89861. */
  89862. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89863. /**
  89864. * Gets either window.performance.now() if supported or Date.now() else
  89865. */
  89866. static readonly Now: number;
  89867. /**
  89868. * This method will return the name of the class used to create the instance of the given object.
  89869. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  89870. * @param object the object to get the class name from
  89871. * @param isType defines if the object is actually a type
  89872. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  89873. */
  89874. static GetClassName(object: any, isType?: boolean): string;
  89875. /**
  89876. * Gets the first element of an array satisfying a given predicate
  89877. * @param array defines the array to browse
  89878. * @param predicate defines the predicate to use
  89879. * @returns null if not found or the element
  89880. */
  89881. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  89882. /**
  89883. * This method will return the name of the full name of the class, including its owning module (if any).
  89884. * 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).
  89885. * @param object the object to get the class name from
  89886. * @param isType defines if the object is actually a type
  89887. * @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.
  89888. * @ignorenaming
  89889. */
  89890. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  89891. /**
  89892. * Returns a promise that resolves after the given amount of time.
  89893. * @param delay Number of milliseconds to delay
  89894. * @returns Promise that resolves after the given amount of time
  89895. */
  89896. static DelayAsync(delay: number): Promise<void>;
  89897. /**
  89898. * Gets the current gradient from an array of IValueGradient
  89899. * @param ratio defines the current ratio to get
  89900. * @param gradients defines the array of IValueGradient
  89901. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89902. */
  89903. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89904. }
  89905. /**
  89906. * This class is used to track a performance counter which is number based.
  89907. * The user has access to many properties which give statistics of different nature.
  89908. *
  89909. * The implementer can track two kinds of Performance Counter: time and count.
  89910. * 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.
  89911. * 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.
  89912. */
  89913. export class PerfCounter {
  89914. /**
  89915. * Gets or sets a global boolean to turn on and off all the counters
  89916. */
  89917. static Enabled: boolean;
  89918. /**
  89919. * Returns the smallest value ever
  89920. */
  89921. readonly min: number;
  89922. /**
  89923. * Returns the biggest value ever
  89924. */
  89925. readonly max: number;
  89926. /**
  89927. * Returns the average value since the performance counter is running
  89928. */
  89929. readonly average: number;
  89930. /**
  89931. * Returns the average value of the last second the counter was monitored
  89932. */
  89933. readonly lastSecAverage: number;
  89934. /**
  89935. * Returns the current value
  89936. */
  89937. readonly current: number;
  89938. /**
  89939. * Gets the accumulated total
  89940. */
  89941. readonly total: number;
  89942. /**
  89943. * Gets the total value count
  89944. */
  89945. readonly count: number;
  89946. /**
  89947. * Creates a new counter
  89948. */
  89949. constructor();
  89950. /**
  89951. * Call this method to start monitoring a new frame.
  89952. * 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.
  89953. */
  89954. fetchNewFrame(): void;
  89955. /**
  89956. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  89957. * @param newCount the count value to add to the monitored count
  89958. * @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.
  89959. */
  89960. addCount(newCount: number, fetchResult: boolean): void;
  89961. /**
  89962. * Start monitoring this performance counter
  89963. */
  89964. beginMonitoring(): void;
  89965. /**
  89966. * Compute the time lapsed since the previous beginMonitoring() call.
  89967. * @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
  89968. */
  89969. endMonitoring(newFrame?: boolean): void;
  89970. private _fetchResult;
  89971. private _startMonitoringTime;
  89972. private _min;
  89973. private _max;
  89974. private _average;
  89975. private _current;
  89976. private _totalValueCount;
  89977. private _totalAccumulated;
  89978. private _lastSecAverage;
  89979. private _lastSecAccumulated;
  89980. private _lastSecTime;
  89981. private _lastSecValueCount;
  89982. }
  89983. /**
  89984. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  89985. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  89986. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  89987. * @param name The name of the class, case should be preserved
  89988. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  89989. */
  89990. export function className(name: string, module?: string): (target: Object) => void;
  89991. /**
  89992. * An implementation of a loop for asynchronous functions.
  89993. */
  89994. export class AsyncLoop {
  89995. /**
  89996. * Defines the number of iterations for the loop
  89997. */
  89998. iterations: number;
  89999. /**
  90000. * Defines the current index of the loop.
  90001. */
  90002. index: number;
  90003. private _done;
  90004. private _fn;
  90005. private _successCallback;
  90006. /**
  90007. * Constructor.
  90008. * @param iterations the number of iterations.
  90009. * @param func the function to run each iteration
  90010. * @param successCallback the callback that will be called upon succesful execution
  90011. * @param offset starting offset.
  90012. */
  90013. constructor(
  90014. /**
  90015. * Defines the number of iterations for the loop
  90016. */
  90017. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90018. /**
  90019. * Execute the next iteration. Must be called after the last iteration was finished.
  90020. */
  90021. executeNext(): void;
  90022. /**
  90023. * Break the loop and run the success callback.
  90024. */
  90025. breakLoop(): void;
  90026. /**
  90027. * Create and run an async loop.
  90028. * @param iterations the number of iterations.
  90029. * @param fn the function to run each iteration
  90030. * @param successCallback the callback that will be called upon succesful execution
  90031. * @param offset starting offset.
  90032. * @returns the created async loop object
  90033. */
  90034. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90035. /**
  90036. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90037. * @param iterations total number of iterations
  90038. * @param syncedIterations number of synchronous iterations in each async iteration.
  90039. * @param fn the function to call each iteration.
  90040. * @param callback a success call back that will be called when iterating stops.
  90041. * @param breakFunction a break condition (optional)
  90042. * @param timeout timeout settings for the setTimeout function. default - 0.
  90043. * @returns the created async loop object
  90044. */
  90045. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90046. }
  90047. }
  90048. declare module BABYLON {
  90049. /** @hidden */
  90050. export interface ICollisionCoordinator {
  90051. createCollider(): Collider;
  90052. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90053. init(scene: Scene): void;
  90054. }
  90055. /** @hidden */
  90056. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90057. private _scene;
  90058. private _scaledPosition;
  90059. private _scaledVelocity;
  90060. private _finalPosition;
  90061. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90062. createCollider(): Collider;
  90063. init(scene: Scene): void;
  90064. private _collideWithWorld;
  90065. }
  90066. }
  90067. declare module BABYLON {
  90068. /**
  90069. * This class defines the direct association between an animation and a target
  90070. */
  90071. export class TargetedAnimation {
  90072. /**
  90073. * Animation to perform
  90074. */
  90075. animation: Animation;
  90076. /**
  90077. * Target to animate
  90078. */
  90079. target: any;
  90080. }
  90081. /**
  90082. * Use this class to create coordinated animations on multiple targets
  90083. */
  90084. export class AnimationGroup implements IDisposable {
  90085. /** The name of the animation group */
  90086. name: string;
  90087. private _scene;
  90088. private _targetedAnimations;
  90089. private _animatables;
  90090. private _from;
  90091. private _to;
  90092. private _isStarted;
  90093. private _isPaused;
  90094. private _speedRatio;
  90095. /**
  90096. * Gets or sets the unique id of the node
  90097. */
  90098. uniqueId: number;
  90099. /**
  90100. * This observable will notify when one animation have ended
  90101. */
  90102. onAnimationEndObservable: Observable<TargetedAnimation>;
  90103. /**
  90104. * Observer raised when one animation loops
  90105. */
  90106. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90107. /**
  90108. * This observable will notify when all animations have ended.
  90109. */
  90110. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90111. /**
  90112. * This observable will notify when all animations have paused.
  90113. */
  90114. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90115. /**
  90116. * This observable will notify when all animations are playing.
  90117. */
  90118. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90119. /**
  90120. * Gets the first frame
  90121. */
  90122. readonly from: number;
  90123. /**
  90124. * Gets the last frame
  90125. */
  90126. readonly to: number;
  90127. /**
  90128. * Define if the animations are started
  90129. */
  90130. readonly isStarted: boolean;
  90131. /**
  90132. * Gets a value indicating that the current group is playing
  90133. */
  90134. readonly isPlaying: boolean;
  90135. /**
  90136. * Gets or sets the speed ratio to use for all animations
  90137. */
  90138. /**
  90139. * Gets or sets the speed ratio to use for all animations
  90140. */
  90141. speedRatio: number;
  90142. /**
  90143. * Gets the targeted animations for this animation group
  90144. */
  90145. readonly targetedAnimations: Array<TargetedAnimation>;
  90146. /**
  90147. * returning the list of animatables controlled by this animation group.
  90148. */
  90149. readonly animatables: Array<Animatable>;
  90150. /**
  90151. * Instantiates a new Animation Group.
  90152. * This helps managing several animations at once.
  90153. * @see http://doc.babylonjs.com/how_to/group
  90154. * @param name Defines the name of the group
  90155. * @param scene Defines the scene the group belongs to
  90156. */
  90157. constructor(
  90158. /** The name of the animation group */
  90159. name: string, scene?: Nullable<Scene>);
  90160. /**
  90161. * Add an animation (with its target) in the group
  90162. * @param animation defines the animation we want to add
  90163. * @param target defines the target of the animation
  90164. * @returns the TargetedAnimation object
  90165. */
  90166. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90167. /**
  90168. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90169. * It can add constant keys at begin or end
  90170. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90171. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90172. * @returns the animation group
  90173. */
  90174. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90175. /**
  90176. * Start all animations on given targets
  90177. * @param loop defines if animations must loop
  90178. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90179. * @param from defines the from key (optional)
  90180. * @param to defines the to key (optional)
  90181. * @returns the current animation group
  90182. */
  90183. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90184. /**
  90185. * Pause all animations
  90186. * @returns the animation group
  90187. */
  90188. pause(): AnimationGroup;
  90189. /**
  90190. * Play all animations to initial state
  90191. * This function will start() the animations if they were not started or will restart() them if they were paused
  90192. * @param loop defines if animations must loop
  90193. * @returns the animation group
  90194. */
  90195. play(loop?: boolean): AnimationGroup;
  90196. /**
  90197. * Reset all animations to initial state
  90198. * @returns the animation group
  90199. */
  90200. reset(): AnimationGroup;
  90201. /**
  90202. * Restart animations from key 0
  90203. * @returns the animation group
  90204. */
  90205. restart(): AnimationGroup;
  90206. /**
  90207. * Stop all animations
  90208. * @returns the animation group
  90209. */
  90210. stop(): AnimationGroup;
  90211. /**
  90212. * Set animation weight for all animatables
  90213. * @param weight defines the weight to use
  90214. * @return the animationGroup
  90215. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90216. */
  90217. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90218. /**
  90219. * Synchronize and normalize all animatables with a source animatable
  90220. * @param root defines the root animatable to synchronize with
  90221. * @return the animationGroup
  90222. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90223. */
  90224. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90225. /**
  90226. * Goes to a specific frame in this animation group
  90227. * @param frame the frame number to go to
  90228. * @return the animationGroup
  90229. */
  90230. goToFrame(frame: number): AnimationGroup;
  90231. /**
  90232. * Dispose all associated resources
  90233. */
  90234. dispose(): void;
  90235. private _checkAnimationGroupEnded;
  90236. /**
  90237. * Clone the current animation group and returns a copy
  90238. * @param newName defines the name of the new group
  90239. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90240. * @returns the new aniamtion group
  90241. */
  90242. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90243. /**
  90244. * Returns a new AnimationGroup object parsed from the source provided.
  90245. * @param parsedAnimationGroup defines the source
  90246. * @param scene defines the scene that will receive the animationGroup
  90247. * @returns a new AnimationGroup
  90248. */
  90249. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90250. /**
  90251. * Returns the string "AnimationGroup"
  90252. * @returns "AnimationGroup"
  90253. */
  90254. getClassName(): string;
  90255. /**
  90256. * Creates a detailled string about the object
  90257. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90258. * @returns a string representing the object
  90259. */
  90260. toString(fullDetails?: boolean): string;
  90261. }
  90262. }
  90263. declare module BABYLON {
  90264. /**
  90265. * Define an interface for all classes that will hold resources
  90266. */
  90267. export interface IDisposable {
  90268. /**
  90269. * Releases all held resources
  90270. */
  90271. dispose(): void;
  90272. }
  90273. /** Interface defining initialization parameters for Scene class */
  90274. export interface SceneOptions {
  90275. /**
  90276. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  90277. * It will improve performance when the number of geometries becomes important.
  90278. */
  90279. useGeometryUniqueIdsMap?: boolean;
  90280. /**
  90281. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  90282. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90283. */
  90284. useMaterialMeshMap?: boolean;
  90285. /**
  90286. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  90287. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90288. */
  90289. useClonedMeshhMap?: boolean;
  90290. }
  90291. /**
  90292. * Represents a scene to be rendered by the engine.
  90293. * @see http://doc.babylonjs.com/features/scene
  90294. */
  90295. export class Scene extends AbstractScene implements IAnimatable {
  90296. private static _uniqueIdCounter;
  90297. /** The fog is deactivated */
  90298. static readonly FOGMODE_NONE: number;
  90299. /** The fog density is following an exponential function */
  90300. static readonly FOGMODE_EXP: number;
  90301. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  90302. static readonly FOGMODE_EXP2: number;
  90303. /** The fog density is following a linear function. */
  90304. static readonly FOGMODE_LINEAR: number;
  90305. /**
  90306. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  90307. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90308. */
  90309. static MinDeltaTime: number;
  90310. /**
  90311. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  90312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90313. */
  90314. static MaxDeltaTime: number;
  90315. /**
  90316. * Factory used to create the default material.
  90317. * @param name The name of the material to create
  90318. * @param scene The scene to create the material for
  90319. * @returns The default material
  90320. */
  90321. static DefaultMaterialFactory(scene: Scene): Material;
  90322. /**
  90323. * Factory used to create the a collision coordinator.
  90324. * @returns The collision coordinator
  90325. */
  90326. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  90327. /** @hidden */
  90328. readonly _isScene: boolean;
  90329. /**
  90330. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  90331. */
  90332. autoClear: boolean;
  90333. /**
  90334. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  90335. */
  90336. autoClearDepthAndStencil: boolean;
  90337. /**
  90338. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  90339. */
  90340. clearColor: Color4;
  90341. /**
  90342. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  90343. */
  90344. ambientColor: Color3;
  90345. /**
  90346. * This is use to store the default BRDF lookup for PBR materials in your scene.
  90347. * It should only be one of the following (if not the default embedded one):
  90348. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  90349. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  90350. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  90351. * The material properties need to be setup according to the type of texture in use.
  90352. */
  90353. environmentBRDFTexture: BaseTexture;
  90354. /** @hidden */
  90355. protected _environmentTexture: Nullable<BaseTexture>;
  90356. /**
  90357. * Texture used in all pbr material as the reflection texture.
  90358. * As in the majority of the scene they are the same (exception for multi room and so on),
  90359. * this is easier to reference from here than from all the materials.
  90360. */
  90361. /**
  90362. * Texture used in all pbr material as the reflection texture.
  90363. * As in the majority of the scene they are the same (exception for multi room and so on),
  90364. * this is easier to set here than in all the materials.
  90365. */
  90366. environmentTexture: Nullable<BaseTexture>;
  90367. /** @hidden */
  90368. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90369. /**
  90370. * Default image processing configuration used either in the rendering
  90371. * Forward main pass or through the imageProcessingPostProcess if present.
  90372. * As in the majority of the scene they are the same (exception for multi camera),
  90373. * this is easier to reference from here than from all the materials and post process.
  90374. *
  90375. * No setter as we it is a shared configuration, you can set the values instead.
  90376. */
  90377. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  90378. private _forceWireframe;
  90379. /**
  90380. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  90381. */
  90382. forceWireframe: boolean;
  90383. private _forcePointsCloud;
  90384. /**
  90385. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  90386. */
  90387. forcePointsCloud: boolean;
  90388. /**
  90389. * Gets or sets the active clipplane 1
  90390. */
  90391. clipPlane: Nullable<Plane>;
  90392. /**
  90393. * Gets or sets the active clipplane 2
  90394. */
  90395. clipPlane2: Nullable<Plane>;
  90396. /**
  90397. * Gets or sets the active clipplane 3
  90398. */
  90399. clipPlane3: Nullable<Plane>;
  90400. /**
  90401. * Gets or sets the active clipplane 4
  90402. */
  90403. clipPlane4: Nullable<Plane>;
  90404. /**
  90405. * Gets or sets a boolean indicating if animations are enabled
  90406. */
  90407. animationsEnabled: boolean;
  90408. private _animationPropertiesOverride;
  90409. /**
  90410. * Gets or sets the animation properties override
  90411. */
  90412. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90413. /**
  90414. * Gets or sets a boolean indicating if a constant deltatime has to be used
  90415. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  90416. */
  90417. useConstantAnimationDeltaTime: boolean;
  90418. /**
  90419. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  90420. * Please note that it requires to run a ray cast through the scene on every frame
  90421. */
  90422. constantlyUpdateMeshUnderPointer: boolean;
  90423. /**
  90424. * Defines the HTML cursor to use when hovering over interactive elements
  90425. */
  90426. hoverCursor: string;
  90427. /**
  90428. * Defines the HTML default cursor to use (empty by default)
  90429. */
  90430. defaultCursor: string;
  90431. /**
  90432. * This is used to call preventDefault() on pointer down
  90433. * in order to block unwanted artifacts like system double clicks
  90434. */
  90435. preventDefaultOnPointerDown: boolean;
  90436. /**
  90437. * This is used to call preventDefault() on pointer up
  90438. * in order to block unwanted artifacts like system double clicks
  90439. */
  90440. preventDefaultOnPointerUp: boolean;
  90441. /**
  90442. * Gets or sets user defined metadata
  90443. */
  90444. metadata: any;
  90445. /**
  90446. * For internal use only. Please do not use.
  90447. */
  90448. reservedDataStore: any;
  90449. /**
  90450. * Gets the name of the plugin used to load this scene (null by default)
  90451. */
  90452. loadingPluginName: string;
  90453. /**
  90454. * Use this array to add regular expressions used to disable offline support for specific urls
  90455. */
  90456. disableOfflineSupportExceptionRules: RegExp[];
  90457. /**
  90458. * An event triggered when the scene is disposed.
  90459. */
  90460. onDisposeObservable: Observable<Scene>;
  90461. private _onDisposeObserver;
  90462. /** Sets a function to be executed when this scene is disposed. */
  90463. onDispose: () => void;
  90464. /**
  90465. * An event triggered before rendering the scene (right after animations and physics)
  90466. */
  90467. onBeforeRenderObservable: Observable<Scene>;
  90468. private _onBeforeRenderObserver;
  90469. /** Sets a function to be executed before rendering this scene */
  90470. beforeRender: Nullable<() => void>;
  90471. /**
  90472. * An event triggered after rendering the scene
  90473. */
  90474. onAfterRenderObservable: Observable<Scene>;
  90475. private _onAfterRenderObserver;
  90476. /** Sets a function to be executed after rendering this scene */
  90477. afterRender: Nullable<() => void>;
  90478. /**
  90479. * An event triggered before animating the scene
  90480. */
  90481. onBeforeAnimationsObservable: Observable<Scene>;
  90482. /**
  90483. * An event triggered after animations processing
  90484. */
  90485. onAfterAnimationsObservable: Observable<Scene>;
  90486. /**
  90487. * An event triggered before draw calls are ready to be sent
  90488. */
  90489. onBeforeDrawPhaseObservable: Observable<Scene>;
  90490. /**
  90491. * An event triggered after draw calls have been sent
  90492. */
  90493. onAfterDrawPhaseObservable: Observable<Scene>;
  90494. /**
  90495. * An event triggered when the scene is ready
  90496. */
  90497. onReadyObservable: Observable<Scene>;
  90498. /**
  90499. * An event triggered before rendering a camera
  90500. */
  90501. onBeforeCameraRenderObservable: Observable<Camera>;
  90502. private _onBeforeCameraRenderObserver;
  90503. /** Sets a function to be executed before rendering a camera*/
  90504. beforeCameraRender: () => void;
  90505. /**
  90506. * An event triggered after rendering a camera
  90507. */
  90508. onAfterCameraRenderObservable: Observable<Camera>;
  90509. private _onAfterCameraRenderObserver;
  90510. /** Sets a function to be executed after rendering a camera*/
  90511. afterCameraRender: () => void;
  90512. /**
  90513. * An event triggered when active meshes evaluation is about to start
  90514. */
  90515. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90516. /**
  90517. * An event triggered when active meshes evaluation is done
  90518. */
  90519. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90520. /**
  90521. * An event triggered when particles rendering is about to start
  90522. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90523. */
  90524. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90525. /**
  90526. * An event triggered when particles rendering is done
  90527. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90528. */
  90529. onAfterParticlesRenderingObservable: Observable<Scene>;
  90530. /**
  90531. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90532. */
  90533. onDataLoadedObservable: Observable<Scene>;
  90534. /**
  90535. * An event triggered when a camera is created
  90536. */
  90537. onNewCameraAddedObservable: Observable<Camera>;
  90538. /**
  90539. * An event triggered when a camera is removed
  90540. */
  90541. onCameraRemovedObservable: Observable<Camera>;
  90542. /**
  90543. * An event triggered when a light is created
  90544. */
  90545. onNewLightAddedObservable: Observable<Light>;
  90546. /**
  90547. * An event triggered when a light is removed
  90548. */
  90549. onLightRemovedObservable: Observable<Light>;
  90550. /**
  90551. * An event triggered when a geometry is created
  90552. */
  90553. onNewGeometryAddedObservable: Observable<Geometry>;
  90554. /**
  90555. * An event triggered when a geometry is removed
  90556. */
  90557. onGeometryRemovedObservable: Observable<Geometry>;
  90558. /**
  90559. * An event triggered when a transform node is created
  90560. */
  90561. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90562. /**
  90563. * An event triggered when a transform node is removed
  90564. */
  90565. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90566. /**
  90567. * An event triggered when a mesh is created
  90568. */
  90569. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90570. /**
  90571. * An event triggered when a mesh is removed
  90572. */
  90573. onMeshRemovedObservable: Observable<AbstractMesh>;
  90574. /**
  90575. * An event triggered when a skeleton is created
  90576. */
  90577. onNewSkeletonAddedObservable: Observable<Skeleton>;
  90578. /**
  90579. * An event triggered when a skeleton is removed
  90580. */
  90581. onSkeletonRemovedObservable: Observable<Skeleton>;
  90582. /**
  90583. * An event triggered when a material is created
  90584. */
  90585. onNewMaterialAddedObservable: Observable<Material>;
  90586. /**
  90587. * An event triggered when a material is removed
  90588. */
  90589. onMaterialRemovedObservable: Observable<Material>;
  90590. /**
  90591. * An event triggered when a texture is created
  90592. */
  90593. onNewTextureAddedObservable: Observable<BaseTexture>;
  90594. /**
  90595. * An event triggered when a texture is removed
  90596. */
  90597. onTextureRemovedObservable: Observable<BaseTexture>;
  90598. /**
  90599. * An event triggered when render targets are about to be rendered
  90600. * Can happen multiple times per frame.
  90601. */
  90602. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  90603. /**
  90604. * An event triggered when render targets were rendered.
  90605. * Can happen multiple times per frame.
  90606. */
  90607. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  90608. /**
  90609. * An event triggered before calculating deterministic simulation step
  90610. */
  90611. onBeforeStepObservable: Observable<Scene>;
  90612. /**
  90613. * An event triggered after calculating deterministic simulation step
  90614. */
  90615. onAfterStepObservable: Observable<Scene>;
  90616. /**
  90617. * An event triggered when the activeCamera property is updated
  90618. */
  90619. onActiveCameraChanged: Observable<Scene>;
  90620. /**
  90621. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  90622. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90623. * 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)
  90624. */
  90625. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90626. /**
  90627. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  90628. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90629. * 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)
  90630. */
  90631. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90632. /**
  90633. * This Observable will when a mesh has been imported into the scene.
  90634. */
  90635. onMeshImportedObservable: Observable<AbstractMesh>;
  90636. /**
  90637. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  90638. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  90639. */
  90640. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  90641. /** @hidden */
  90642. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  90643. /**
  90644. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  90645. */
  90646. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  90647. /**
  90648. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  90649. */
  90650. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  90651. /**
  90652. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  90653. */
  90654. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  90655. private _onPointerMove;
  90656. private _onPointerDown;
  90657. private _onPointerUp;
  90658. /** Callback called when a pointer move is detected */
  90659. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90660. /** Callback called when a pointer down is detected */
  90661. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90662. /** Callback called when a pointer up is detected */
  90663. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  90664. /** Callback called when a pointer pick is detected */
  90665. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  90666. /**
  90667. * 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).
  90668. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  90669. */
  90670. onPrePointerObservable: Observable<PointerInfoPre>;
  90671. /**
  90672. * Observable event triggered each time an input event is received from the rendering canvas
  90673. */
  90674. onPointerObservable: Observable<PointerInfo>;
  90675. /**
  90676. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  90677. */
  90678. readonly unTranslatedPointer: Vector2;
  90679. /** The distance in pixel that you have to move to prevent some events */
  90680. static DragMovementThreshold: number;
  90681. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  90682. static LongPressDelay: number;
  90683. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  90684. static DoubleClickDelay: number;
  90685. /** If you need to check double click without raising a single click at first click, enable this flag */
  90686. static ExclusiveDoubleClickMode: boolean;
  90687. private _initClickEvent;
  90688. private _initActionManager;
  90689. private _delayedSimpleClick;
  90690. private _delayedSimpleClickTimeout;
  90691. private _previousDelayedSimpleClickTimeout;
  90692. private _meshPickProceed;
  90693. private _previousButtonPressed;
  90694. private _currentPickResult;
  90695. private _previousPickResult;
  90696. private _totalPointersPressed;
  90697. private _doubleClickOccured;
  90698. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  90699. cameraToUseForPointers: Nullable<Camera>;
  90700. private _pointerX;
  90701. private _pointerY;
  90702. private _unTranslatedPointerX;
  90703. private _unTranslatedPointerY;
  90704. private _startingPointerPosition;
  90705. private _previousStartingPointerPosition;
  90706. private _startingPointerTime;
  90707. private _previousStartingPointerTime;
  90708. private _pointerCaptures;
  90709. private _timeAccumulator;
  90710. private _currentStepId;
  90711. private _currentInternalStep;
  90712. /** @hidden */
  90713. _mirroredCameraPosition: Nullable<Vector3>;
  90714. /**
  90715. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  90716. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  90717. */
  90718. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  90719. /**
  90720. * Observable event triggered each time an keyboard event is received from the hosting window
  90721. */
  90722. onKeyboardObservable: Observable<KeyboardInfo>;
  90723. private _onKeyDown;
  90724. private _onKeyUp;
  90725. private _onCanvasFocusObserver;
  90726. private _onCanvasBlurObserver;
  90727. private _useRightHandedSystem;
  90728. /**
  90729. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  90730. */
  90731. useRightHandedSystem: boolean;
  90732. /**
  90733. * Sets the step Id used by deterministic lock step
  90734. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90735. * @param newStepId defines the step Id
  90736. */
  90737. setStepId(newStepId: number): void;
  90738. /**
  90739. * Gets the step Id used by deterministic lock step
  90740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90741. * @returns the step Id
  90742. */
  90743. getStepId(): number;
  90744. /**
  90745. * Gets the internal step used by deterministic lock step
  90746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90747. * @returns the internal step
  90748. */
  90749. getInternalStep(): number;
  90750. private _fogEnabled;
  90751. /**
  90752. * Gets or sets a boolean indicating if fog is enabled on this scene
  90753. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90754. * (Default is true)
  90755. */
  90756. fogEnabled: boolean;
  90757. private _fogMode;
  90758. /**
  90759. * Gets or sets the fog mode to use
  90760. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90761. * | mode | value |
  90762. * | --- | --- |
  90763. * | FOGMODE_NONE | 0 |
  90764. * | FOGMODE_EXP | 1 |
  90765. * | FOGMODE_EXP2 | 2 |
  90766. * | FOGMODE_LINEAR | 3 |
  90767. */
  90768. fogMode: number;
  90769. /**
  90770. * Gets or sets the fog color to use
  90771. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90772. * (Default is Color3(0.2, 0.2, 0.3))
  90773. */
  90774. fogColor: Color3;
  90775. /**
  90776. * Gets or sets the fog density to use
  90777. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90778. * (Default is 0.1)
  90779. */
  90780. fogDensity: number;
  90781. /**
  90782. * Gets or sets the fog start distance to use
  90783. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90784. * (Default is 0)
  90785. */
  90786. fogStart: number;
  90787. /**
  90788. * Gets or sets the fog end distance to use
  90789. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90790. * (Default is 1000)
  90791. */
  90792. fogEnd: number;
  90793. private _shadowsEnabled;
  90794. /**
  90795. * Gets or sets a boolean indicating if shadows are enabled on this scene
  90796. */
  90797. shadowsEnabled: boolean;
  90798. private _lightsEnabled;
  90799. /**
  90800. * Gets or sets a boolean indicating if lights are enabled on this scene
  90801. */
  90802. lightsEnabled: boolean;
  90803. /** All of the active cameras added to this scene. */
  90804. activeCameras: Camera[];
  90805. private _activeCamera;
  90806. /** Gets or sets the current active camera */
  90807. activeCamera: Nullable<Camera>;
  90808. private _defaultMaterial;
  90809. /** The default material used on meshes when no material is affected */
  90810. /** The default material used on meshes when no material is affected */
  90811. defaultMaterial: Material;
  90812. private _texturesEnabled;
  90813. /**
  90814. * Gets or sets a boolean indicating if textures are enabled on this scene
  90815. */
  90816. texturesEnabled: boolean;
  90817. /**
  90818. * Gets or sets a boolean indicating if particles are enabled on this scene
  90819. */
  90820. particlesEnabled: boolean;
  90821. /**
  90822. * Gets or sets a boolean indicating if sprites are enabled on this scene
  90823. */
  90824. spritesEnabled: boolean;
  90825. private _skeletonsEnabled;
  90826. /**
  90827. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  90828. */
  90829. skeletonsEnabled: boolean;
  90830. /**
  90831. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  90832. */
  90833. lensFlaresEnabled: boolean;
  90834. /**
  90835. * Gets or sets a boolean indicating if collisions are enabled on this scene
  90836. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90837. */
  90838. collisionsEnabled: boolean;
  90839. private _collisionCoordinator;
  90840. /** @hidden */
  90841. readonly collisionCoordinator: ICollisionCoordinator;
  90842. /**
  90843. * Defines the gravity applied to this scene (used only for collisions)
  90844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90845. */
  90846. gravity: Vector3;
  90847. /**
  90848. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  90849. */
  90850. postProcessesEnabled: boolean;
  90851. /**
  90852. * The list of postprocesses added to the scene
  90853. */
  90854. postProcesses: PostProcess[];
  90855. /**
  90856. * Gets the current postprocess manager
  90857. */
  90858. postProcessManager: PostProcessManager;
  90859. /**
  90860. * Gets or sets a boolean indicating if render targets are enabled on this scene
  90861. */
  90862. renderTargetsEnabled: boolean;
  90863. /**
  90864. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  90865. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  90866. */
  90867. dumpNextRenderTargets: boolean;
  90868. /**
  90869. * The list of user defined render targets added to the scene
  90870. */
  90871. customRenderTargets: RenderTargetTexture[];
  90872. /**
  90873. * Defines if texture loading must be delayed
  90874. * If true, textures will only be loaded when they need to be rendered
  90875. */
  90876. useDelayedTextureLoading: boolean;
  90877. /**
  90878. * Gets the list of meshes imported to the scene through SceneLoader
  90879. */
  90880. importedMeshesFiles: String[];
  90881. /**
  90882. * Gets or sets a boolean indicating if probes are enabled on this scene
  90883. */
  90884. probesEnabled: boolean;
  90885. /**
  90886. * Gets or sets the current offline provider to use to store scene data
  90887. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  90888. */
  90889. offlineProvider: IOfflineProvider;
  90890. /**
  90891. * Gets or sets the action manager associated with the scene
  90892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90893. */
  90894. actionManager: AbstractActionManager;
  90895. private _meshesForIntersections;
  90896. /**
  90897. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  90898. */
  90899. proceduralTexturesEnabled: boolean;
  90900. private _engine;
  90901. private _totalVertices;
  90902. /** @hidden */
  90903. _activeIndices: PerfCounter;
  90904. /** @hidden */
  90905. _activeParticles: PerfCounter;
  90906. /** @hidden */
  90907. _activeBones: PerfCounter;
  90908. private _animationRatio;
  90909. /** @hidden */
  90910. _animationTimeLast: number;
  90911. /** @hidden */
  90912. _animationTime: number;
  90913. /**
  90914. * Gets or sets a general scale for animation speed
  90915. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  90916. */
  90917. animationTimeScale: number;
  90918. /** @hidden */
  90919. _cachedMaterial: Nullable<Material>;
  90920. /** @hidden */
  90921. _cachedEffect: Nullable<Effect>;
  90922. /** @hidden */
  90923. _cachedVisibility: Nullable<number>;
  90924. private _renderId;
  90925. private _frameId;
  90926. private _executeWhenReadyTimeoutId;
  90927. private _intermediateRendering;
  90928. private _viewUpdateFlag;
  90929. private _projectionUpdateFlag;
  90930. /** @hidden */
  90931. _toBeDisposed: Nullable<IDisposable>[];
  90932. private _activeRequests;
  90933. /** @hidden */
  90934. _pendingData: any[];
  90935. private _isDisposed;
  90936. /**
  90937. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  90938. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  90939. */
  90940. dispatchAllSubMeshesOfActiveMeshes: boolean;
  90941. private _activeMeshes;
  90942. private _processedMaterials;
  90943. private _renderTargets;
  90944. /** @hidden */
  90945. _activeParticleSystems: SmartArray<IParticleSystem>;
  90946. private _activeSkeletons;
  90947. private _softwareSkinnedMeshes;
  90948. private _renderingManager;
  90949. /** @hidden */
  90950. _activeAnimatables: Animatable[];
  90951. private _transformMatrix;
  90952. private _transformMatrixR;
  90953. private _sceneUbo;
  90954. private _multiviewSceneUbo;
  90955. private _viewMatrix;
  90956. private _projectionMatrix;
  90957. private _wheelEventName;
  90958. /** @hidden */
  90959. _forcedViewPosition: Nullable<Vector3>;
  90960. private _frustumPlanes;
  90961. /**
  90962. * Gets the list of frustum planes (built from the active camera)
  90963. */
  90964. readonly frustumPlanes: Plane[];
  90965. /**
  90966. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  90967. * This is useful if there are more lights that the maximum simulteanous authorized
  90968. */
  90969. requireLightSorting: boolean;
  90970. /** @hidden */
  90971. readonly useMaterialMeshMap: boolean;
  90972. /** @hidden */
  90973. readonly useClonedMeshhMap: boolean;
  90974. private _pointerOverMesh;
  90975. private _pickedDownMesh;
  90976. private _pickedUpMesh;
  90977. private _externalData;
  90978. private _uid;
  90979. /**
  90980. * @hidden
  90981. * Backing store of defined scene components.
  90982. */
  90983. _components: ISceneComponent[];
  90984. /**
  90985. * @hidden
  90986. * Backing store of defined scene components.
  90987. */
  90988. _serializableComponents: ISceneSerializableComponent[];
  90989. /**
  90990. * List of components to register on the next registration step.
  90991. */
  90992. private _transientComponents;
  90993. /**
  90994. * Registers the transient components if needed.
  90995. */
  90996. private _registerTransientComponents;
  90997. /**
  90998. * @hidden
  90999. * Add a component to the scene.
  91000. * Note that the ccomponent could be registered on th next frame if this is called after
  91001. * the register component stage.
  91002. * @param component Defines the component to add to the scene
  91003. */
  91004. _addComponent(component: ISceneComponent): void;
  91005. /**
  91006. * @hidden
  91007. * Gets a component from the scene.
  91008. * @param name defines the name of the component to retrieve
  91009. * @returns the component or null if not present
  91010. */
  91011. _getComponent(name: string): Nullable<ISceneComponent>;
  91012. /**
  91013. * @hidden
  91014. * Defines the actions happening before camera updates.
  91015. */
  91016. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91017. /**
  91018. * @hidden
  91019. * Defines the actions happening before clear the canvas.
  91020. */
  91021. _beforeClearStage: Stage<SimpleStageAction>;
  91022. /**
  91023. * @hidden
  91024. * Defines the actions when collecting render targets for the frame.
  91025. */
  91026. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91027. /**
  91028. * @hidden
  91029. * Defines the actions happening for one camera in the frame.
  91030. */
  91031. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91032. /**
  91033. * @hidden
  91034. * Defines the actions happening during the per mesh ready checks.
  91035. */
  91036. _isReadyForMeshStage: Stage<MeshStageAction>;
  91037. /**
  91038. * @hidden
  91039. * Defines the actions happening before evaluate active mesh checks.
  91040. */
  91041. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91042. /**
  91043. * @hidden
  91044. * Defines the actions happening during the evaluate sub mesh checks.
  91045. */
  91046. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91047. /**
  91048. * @hidden
  91049. * Defines the actions happening during the active mesh stage.
  91050. */
  91051. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91052. /**
  91053. * @hidden
  91054. * Defines the actions happening during the per camera render target step.
  91055. */
  91056. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91057. /**
  91058. * @hidden
  91059. * Defines the actions happening just before the active camera is drawing.
  91060. */
  91061. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91062. /**
  91063. * @hidden
  91064. * Defines the actions happening just before a render target is drawing.
  91065. */
  91066. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91067. /**
  91068. * @hidden
  91069. * Defines the actions happening just before a rendering group is drawing.
  91070. */
  91071. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91072. /**
  91073. * @hidden
  91074. * Defines the actions happening just before a mesh is drawing.
  91075. */
  91076. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91077. /**
  91078. * @hidden
  91079. * Defines the actions happening just after a mesh has been drawn.
  91080. */
  91081. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91082. /**
  91083. * @hidden
  91084. * Defines the actions happening just after a rendering group has been drawn.
  91085. */
  91086. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91087. /**
  91088. * @hidden
  91089. * Defines the actions happening just after the active camera has been drawn.
  91090. */
  91091. _afterCameraDrawStage: Stage<CameraStageAction>;
  91092. /**
  91093. * @hidden
  91094. * Defines the actions happening just after a render target has been drawn.
  91095. */
  91096. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91097. /**
  91098. * @hidden
  91099. * Defines the actions happening just after rendering all cameras and computing intersections.
  91100. */
  91101. _afterRenderStage: Stage<SimpleStageAction>;
  91102. /**
  91103. * @hidden
  91104. * Defines the actions happening when a pointer move event happens.
  91105. */
  91106. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91107. /**
  91108. * @hidden
  91109. * Defines the actions happening when a pointer down event happens.
  91110. */
  91111. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91112. /**
  91113. * @hidden
  91114. * Defines the actions happening when a pointer up event happens.
  91115. */
  91116. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91117. /**
  91118. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91119. */
  91120. private geometriesByUniqueId;
  91121. /**
  91122. * Creates a new Scene
  91123. * @param engine defines the engine to use to render this scene
  91124. * @param options defines the scene options
  91125. */
  91126. constructor(engine: Engine, options?: SceneOptions);
  91127. private _defaultMeshCandidates;
  91128. /**
  91129. * @hidden
  91130. */
  91131. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91132. private _defaultSubMeshCandidates;
  91133. /**
  91134. * @hidden
  91135. */
  91136. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91137. /**
  91138. * Sets the default candidate providers for the scene.
  91139. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91140. * and getCollidingSubMeshCandidates to their default function
  91141. */
  91142. setDefaultCandidateProviders(): void;
  91143. /**
  91144. * Gets the mesh that is currently under the pointer
  91145. */
  91146. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91147. /**
  91148. * Gets or sets the current on-screen X position of the pointer
  91149. */
  91150. pointerX: number;
  91151. /**
  91152. * Gets or sets the current on-screen Y position of the pointer
  91153. */
  91154. pointerY: number;
  91155. /**
  91156. * Gets the cached material (ie. the latest rendered one)
  91157. * @returns the cached material
  91158. */
  91159. getCachedMaterial(): Nullable<Material>;
  91160. /**
  91161. * Gets the cached effect (ie. the latest rendered one)
  91162. * @returns the cached effect
  91163. */
  91164. getCachedEffect(): Nullable<Effect>;
  91165. /**
  91166. * Gets the cached visibility state (ie. the latest rendered one)
  91167. * @returns the cached visibility state
  91168. */
  91169. getCachedVisibility(): Nullable<number>;
  91170. /**
  91171. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91172. * @param material defines the current material
  91173. * @param effect defines the current effect
  91174. * @param visibility defines the current visibility state
  91175. * @returns true if one parameter is not cached
  91176. */
  91177. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91178. /**
  91179. * Gets the engine associated with the scene
  91180. * @returns an Engine
  91181. */
  91182. getEngine(): Engine;
  91183. /**
  91184. * Gets the total number of vertices rendered per frame
  91185. * @returns the total number of vertices rendered per frame
  91186. */
  91187. getTotalVertices(): number;
  91188. /**
  91189. * Gets the performance counter for total vertices
  91190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91191. */
  91192. readonly totalVerticesPerfCounter: PerfCounter;
  91193. /**
  91194. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91195. * @returns the total number of active indices rendered per frame
  91196. */
  91197. getActiveIndices(): number;
  91198. /**
  91199. * Gets the performance counter for active indices
  91200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91201. */
  91202. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91203. /**
  91204. * Gets the total number of active particles rendered per frame
  91205. * @returns the total number of active particles rendered per frame
  91206. */
  91207. getActiveParticles(): number;
  91208. /**
  91209. * Gets the performance counter for active particles
  91210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91211. */
  91212. readonly activeParticlesPerfCounter: PerfCounter;
  91213. /**
  91214. * Gets the total number of active bones rendered per frame
  91215. * @returns the total number of active bones rendered per frame
  91216. */
  91217. getActiveBones(): number;
  91218. /**
  91219. * Gets the performance counter for active bones
  91220. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91221. */
  91222. readonly activeBonesPerfCounter: PerfCounter;
  91223. /**
  91224. * Gets the array of active meshes
  91225. * @returns an array of AbstractMesh
  91226. */
  91227. getActiveMeshes(): SmartArray<AbstractMesh>;
  91228. /**
  91229. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91230. * @returns a number
  91231. */
  91232. getAnimationRatio(): number;
  91233. /**
  91234. * Gets an unique Id for the current render phase
  91235. * @returns a number
  91236. */
  91237. getRenderId(): number;
  91238. /**
  91239. * Gets an unique Id for the current frame
  91240. * @returns a number
  91241. */
  91242. getFrameId(): number;
  91243. /** Call this function if you want to manually increment the render Id*/
  91244. incrementRenderId(): void;
  91245. private _updatePointerPosition;
  91246. private _createUbo;
  91247. private _createMultiviewUbo;
  91248. private _setRayOnPointerInfo;
  91249. /**
  91250. * Use this method to simulate a pointer move on a mesh
  91251. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91252. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91253. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91254. * @returns the current scene
  91255. */
  91256. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91257. private _processPointerMove;
  91258. private _checkPrePointerObservable;
  91259. /**
  91260. * Use this method to simulate a pointer down on a mesh
  91261. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91262. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91263. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91264. * @returns the current scene
  91265. */
  91266. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91267. private _processPointerDown;
  91268. /**
  91269. * Use this method to simulate a pointer up on a mesh
  91270. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91271. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91272. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91273. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91274. * @returns the current scene
  91275. */
  91276. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  91277. private _processPointerUp;
  91278. /**
  91279. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91280. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91281. * @returns true if the pointer was captured
  91282. */
  91283. isPointerCaptured(pointerId?: number): boolean;
  91284. /** @hidden */
  91285. _isPointerSwiping(): boolean;
  91286. /**
  91287. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91288. * @param attachUp defines if you want to attach events to pointerup
  91289. * @param attachDown defines if you want to attach events to pointerdown
  91290. * @param attachMove defines if you want to attach events to pointermove
  91291. */
  91292. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91293. /** Detaches all event handlers*/
  91294. detachControl(): void;
  91295. /**
  91296. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  91297. * Delay loaded resources are not taking in account
  91298. * @return true if all required resources are ready
  91299. */
  91300. isReady(): boolean;
  91301. /** Resets all cached information relative to material (including effect and visibility) */
  91302. resetCachedMaterial(): void;
  91303. /**
  91304. * Registers a function to be called before every frame render
  91305. * @param func defines the function to register
  91306. */
  91307. registerBeforeRender(func: () => void): void;
  91308. /**
  91309. * Unregisters a function called before every frame render
  91310. * @param func defines the function to unregister
  91311. */
  91312. unregisterBeforeRender(func: () => void): void;
  91313. /**
  91314. * Registers a function to be called after every frame render
  91315. * @param func defines the function to register
  91316. */
  91317. registerAfterRender(func: () => void): void;
  91318. /**
  91319. * Unregisters a function called after every frame render
  91320. * @param func defines the function to unregister
  91321. */
  91322. unregisterAfterRender(func: () => void): void;
  91323. private _executeOnceBeforeRender;
  91324. /**
  91325. * The provided function will run before render once and will be disposed afterwards.
  91326. * A timeout delay can be provided so that the function will be executed in N ms.
  91327. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  91328. * @param func The function to be executed.
  91329. * @param timeout optional delay in ms
  91330. */
  91331. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  91332. /** @hidden */
  91333. _addPendingData(data: any): void;
  91334. /** @hidden */
  91335. _removePendingData(data: any): void;
  91336. /**
  91337. * Returns the number of items waiting to be loaded
  91338. * @returns the number of items waiting to be loaded
  91339. */
  91340. getWaitingItemsCount(): number;
  91341. /**
  91342. * Returns a boolean indicating if the scene is still loading data
  91343. */
  91344. readonly isLoading: boolean;
  91345. /**
  91346. * Registers a function to be executed when the scene is ready
  91347. * @param {Function} func - the function to be executed
  91348. */
  91349. executeWhenReady(func: () => void): void;
  91350. /**
  91351. * Returns a promise that resolves when the scene is ready
  91352. * @returns A promise that resolves when the scene is ready
  91353. */
  91354. whenReadyAsync(): Promise<void>;
  91355. /** @hidden */
  91356. _checkIsReady(): void;
  91357. /**
  91358. * Gets all animatable attached to the scene
  91359. */
  91360. readonly animatables: Animatable[];
  91361. /**
  91362. * Resets the last animation time frame.
  91363. * Useful to override when animations start running when loading a scene for the first time.
  91364. */
  91365. resetLastAnimationTimeFrame(): void;
  91366. /**
  91367. * Gets the current view matrix
  91368. * @returns a Matrix
  91369. */
  91370. getViewMatrix(): Matrix;
  91371. /**
  91372. * Gets the current projection matrix
  91373. * @returns a Matrix
  91374. */
  91375. getProjectionMatrix(): Matrix;
  91376. /**
  91377. * Gets the current transform matrix
  91378. * @returns a Matrix made of View * Projection
  91379. */
  91380. getTransformMatrix(): Matrix;
  91381. /**
  91382. * Sets the current transform matrix
  91383. * @param viewL defines the View matrix to use
  91384. * @param projectionL defines the Projection matrix to use
  91385. * @param viewR defines the right View matrix to use (if provided)
  91386. * @param projectionR defines the right Projection matrix to use (if provided)
  91387. */
  91388. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  91389. /**
  91390. * Gets the uniform buffer used to store scene data
  91391. * @returns a UniformBuffer
  91392. */
  91393. getSceneUniformBuffer(): UniformBuffer;
  91394. /**
  91395. * Gets an unique (relatively to the current scene) Id
  91396. * @returns an unique number for the scene
  91397. */
  91398. getUniqueId(): number;
  91399. /**
  91400. * Add a mesh to the list of scene's meshes
  91401. * @param newMesh defines the mesh to add
  91402. * @param recursive if all child meshes should also be added to the scene
  91403. */
  91404. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  91405. /**
  91406. * Remove a mesh for the list of scene's meshes
  91407. * @param toRemove defines the mesh to remove
  91408. * @param recursive if all child meshes should also be removed from the scene
  91409. * @returns the index where the mesh was in the mesh list
  91410. */
  91411. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  91412. /**
  91413. * Add a transform node to the list of scene's transform nodes
  91414. * @param newTransformNode defines the transform node to add
  91415. */
  91416. addTransformNode(newTransformNode: TransformNode): void;
  91417. /**
  91418. * Remove a transform node for the list of scene's transform nodes
  91419. * @param toRemove defines the transform node to remove
  91420. * @returns the index where the transform node was in the transform node list
  91421. */
  91422. removeTransformNode(toRemove: TransformNode): number;
  91423. /**
  91424. * Remove a skeleton for the list of scene's skeletons
  91425. * @param toRemove defines the skeleton to remove
  91426. * @returns the index where the skeleton was in the skeleton list
  91427. */
  91428. removeSkeleton(toRemove: Skeleton): number;
  91429. /**
  91430. * Remove a morph target for the list of scene's morph targets
  91431. * @param toRemove defines the morph target to remove
  91432. * @returns the index where the morph target was in the morph target list
  91433. */
  91434. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  91435. /**
  91436. * Remove a light for the list of scene's lights
  91437. * @param toRemove defines the light to remove
  91438. * @returns the index where the light was in the light list
  91439. */
  91440. removeLight(toRemove: Light): number;
  91441. /**
  91442. * Remove a camera for the list of scene's cameras
  91443. * @param toRemove defines the camera to remove
  91444. * @returns the index where the camera was in the camera list
  91445. */
  91446. removeCamera(toRemove: Camera): number;
  91447. /**
  91448. * Remove a particle system for the list of scene's particle systems
  91449. * @param toRemove defines the particle system to remove
  91450. * @returns the index where the particle system was in the particle system list
  91451. */
  91452. removeParticleSystem(toRemove: IParticleSystem): number;
  91453. /**
  91454. * Remove a animation for the list of scene's animations
  91455. * @param toRemove defines the animation to remove
  91456. * @returns the index where the animation was in the animation list
  91457. */
  91458. removeAnimation(toRemove: Animation): number;
  91459. /**
  91460. * Removes the given animation group from this scene.
  91461. * @param toRemove The animation group to remove
  91462. * @returns The index of the removed animation group
  91463. */
  91464. removeAnimationGroup(toRemove: AnimationGroup): number;
  91465. /**
  91466. * Removes the given multi-material from this scene.
  91467. * @param toRemove The multi-material to remove
  91468. * @returns The index of the removed multi-material
  91469. */
  91470. removeMultiMaterial(toRemove: MultiMaterial): number;
  91471. /**
  91472. * Removes the given material from this scene.
  91473. * @param toRemove The material to remove
  91474. * @returns The index of the removed material
  91475. */
  91476. removeMaterial(toRemove: Material): number;
  91477. /**
  91478. * Removes the given action manager from this scene.
  91479. * @param toRemove The action manager to remove
  91480. * @returns The index of the removed action manager
  91481. */
  91482. removeActionManager(toRemove: AbstractActionManager): number;
  91483. /**
  91484. * Removes the given texture from this scene.
  91485. * @param toRemove The texture to remove
  91486. * @returns The index of the removed texture
  91487. */
  91488. removeTexture(toRemove: BaseTexture): number;
  91489. /**
  91490. * Adds the given light to this scene
  91491. * @param newLight The light to add
  91492. */
  91493. addLight(newLight: Light): void;
  91494. /**
  91495. * Sorts the list list based on light priorities
  91496. */
  91497. sortLightsByPriority(): void;
  91498. /**
  91499. * Adds the given camera to this scene
  91500. * @param newCamera The camera to add
  91501. */
  91502. addCamera(newCamera: Camera): void;
  91503. /**
  91504. * Adds the given skeleton to this scene
  91505. * @param newSkeleton The skeleton to add
  91506. */
  91507. addSkeleton(newSkeleton: Skeleton): void;
  91508. /**
  91509. * Adds the given particle system to this scene
  91510. * @param newParticleSystem The particle system to add
  91511. */
  91512. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91513. /**
  91514. * Adds the given animation to this scene
  91515. * @param newAnimation The animation to add
  91516. */
  91517. addAnimation(newAnimation: Animation): void;
  91518. /**
  91519. * Adds the given animation group to this scene.
  91520. * @param newAnimationGroup The animation group to add
  91521. */
  91522. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91523. /**
  91524. * Adds the given multi-material to this scene
  91525. * @param newMultiMaterial The multi-material to add
  91526. */
  91527. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91528. /**
  91529. * Adds the given material to this scene
  91530. * @param newMaterial The material to add
  91531. */
  91532. addMaterial(newMaterial: Material): void;
  91533. /**
  91534. * Adds the given morph target to this scene
  91535. * @param newMorphTargetManager The morph target to add
  91536. */
  91537. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91538. /**
  91539. * Adds the given geometry to this scene
  91540. * @param newGeometry The geometry to add
  91541. */
  91542. addGeometry(newGeometry: Geometry): void;
  91543. /**
  91544. * Adds the given action manager to this scene
  91545. * @param newActionManager The action manager to add
  91546. */
  91547. addActionManager(newActionManager: AbstractActionManager): void;
  91548. /**
  91549. * Adds the given texture to this scene.
  91550. * @param newTexture The texture to add
  91551. */
  91552. addTexture(newTexture: BaseTexture): void;
  91553. /**
  91554. * Switch active camera
  91555. * @param newCamera defines the new active camera
  91556. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91557. */
  91558. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91559. /**
  91560. * sets the active camera of the scene using its ID
  91561. * @param id defines the camera's ID
  91562. * @return the new active camera or null if none found.
  91563. */
  91564. setActiveCameraByID(id: string): Nullable<Camera>;
  91565. /**
  91566. * sets the active camera of the scene using its name
  91567. * @param name defines the camera's name
  91568. * @returns the new active camera or null if none found.
  91569. */
  91570. setActiveCameraByName(name: string): Nullable<Camera>;
  91571. /**
  91572. * get an animation group using its name
  91573. * @param name defines the material's name
  91574. * @return the animation group or null if none found.
  91575. */
  91576. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  91577. /**
  91578. * Get a material using its unique id
  91579. * @param uniqueId defines the material's unique id
  91580. * @return the material or null if none found.
  91581. */
  91582. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  91583. /**
  91584. * get a material using its id
  91585. * @param id defines the material's ID
  91586. * @return the material or null if none found.
  91587. */
  91588. getMaterialByID(id: string): Nullable<Material>;
  91589. /**
  91590. * Gets a material using its name
  91591. * @param name defines the material's name
  91592. * @return the material or null if none found.
  91593. */
  91594. getMaterialByName(name: string): Nullable<Material>;
  91595. /**
  91596. * Gets a camera using its id
  91597. * @param id defines the id to look for
  91598. * @returns the camera or null if not found
  91599. */
  91600. getCameraByID(id: string): Nullable<Camera>;
  91601. /**
  91602. * Gets a camera using its unique id
  91603. * @param uniqueId defines the unique id to look for
  91604. * @returns the camera or null if not found
  91605. */
  91606. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  91607. /**
  91608. * Gets a camera using its name
  91609. * @param name defines the camera's name
  91610. * @return the camera or null if none found.
  91611. */
  91612. getCameraByName(name: string): Nullable<Camera>;
  91613. /**
  91614. * Gets a bone using its id
  91615. * @param id defines the bone's id
  91616. * @return the bone or null if not found
  91617. */
  91618. getBoneByID(id: string): Nullable<Bone>;
  91619. /**
  91620. * Gets a bone using its id
  91621. * @param name defines the bone's name
  91622. * @return the bone or null if not found
  91623. */
  91624. getBoneByName(name: string): Nullable<Bone>;
  91625. /**
  91626. * Gets a light node using its name
  91627. * @param name defines the the light's name
  91628. * @return the light or null if none found.
  91629. */
  91630. getLightByName(name: string): Nullable<Light>;
  91631. /**
  91632. * Gets a light node using its id
  91633. * @param id defines the light's id
  91634. * @return the light or null if none found.
  91635. */
  91636. getLightByID(id: string): Nullable<Light>;
  91637. /**
  91638. * Gets a light node using its scene-generated unique ID
  91639. * @param uniqueId defines the light's unique id
  91640. * @return the light or null if none found.
  91641. */
  91642. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  91643. /**
  91644. * Gets a particle system by id
  91645. * @param id defines the particle system id
  91646. * @return the corresponding system or null if none found
  91647. */
  91648. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  91649. /**
  91650. * Gets a geometry using its ID
  91651. * @param id defines the geometry's id
  91652. * @return the geometry or null if none found.
  91653. */
  91654. getGeometryByID(id: string): Nullable<Geometry>;
  91655. private _getGeometryByUniqueID;
  91656. /**
  91657. * Add a new geometry to this scene
  91658. * @param geometry defines the geometry to be added to the scene.
  91659. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  91660. * @return a boolean defining if the geometry was added or not
  91661. */
  91662. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  91663. /**
  91664. * Removes an existing geometry
  91665. * @param geometry defines the geometry to be removed from the scene
  91666. * @return a boolean defining if the geometry was removed or not
  91667. */
  91668. removeGeometry(geometry: Geometry): boolean;
  91669. /**
  91670. * Gets the list of geometries attached to the scene
  91671. * @returns an array of Geometry
  91672. */
  91673. getGeometries(): Geometry[];
  91674. /**
  91675. * Gets the first added mesh found of a given ID
  91676. * @param id defines the id to search for
  91677. * @return the mesh found or null if not found at all
  91678. */
  91679. getMeshByID(id: string): Nullable<AbstractMesh>;
  91680. /**
  91681. * Gets a list of meshes using their id
  91682. * @param id defines the id to search for
  91683. * @returns a list of meshes
  91684. */
  91685. getMeshesByID(id: string): Array<AbstractMesh>;
  91686. /**
  91687. * Gets the first added transform node found of a given ID
  91688. * @param id defines the id to search for
  91689. * @return the found transform node or null if not found at all.
  91690. */
  91691. getTransformNodeByID(id: string): Nullable<TransformNode>;
  91692. /**
  91693. * Gets a transform node with its auto-generated unique id
  91694. * @param uniqueId efines the unique id to search for
  91695. * @return the found transform node or null if not found at all.
  91696. */
  91697. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  91698. /**
  91699. * Gets a list of transform nodes using their id
  91700. * @param id defines the id to search for
  91701. * @returns a list of transform nodes
  91702. */
  91703. getTransformNodesByID(id: string): Array<TransformNode>;
  91704. /**
  91705. * Gets a mesh with its auto-generated unique id
  91706. * @param uniqueId defines the unique id to search for
  91707. * @return the found mesh or null if not found at all.
  91708. */
  91709. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  91710. /**
  91711. * Gets a the last added mesh using a given id
  91712. * @param id defines the id to search for
  91713. * @return the found mesh or null if not found at all.
  91714. */
  91715. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  91716. /**
  91717. * Gets a the last added node (Mesh, Camera, Light) using a given id
  91718. * @param id defines the id to search for
  91719. * @return the found node or null if not found at all
  91720. */
  91721. getLastEntryByID(id: string): Nullable<Node>;
  91722. /**
  91723. * Gets a node (Mesh, Camera, Light) using a given id
  91724. * @param id defines the id to search for
  91725. * @return the found node or null if not found at all
  91726. */
  91727. getNodeByID(id: string): Nullable<Node>;
  91728. /**
  91729. * Gets a node (Mesh, Camera, Light) using a given name
  91730. * @param name defines the name to search for
  91731. * @return the found node or null if not found at all.
  91732. */
  91733. getNodeByName(name: string): Nullable<Node>;
  91734. /**
  91735. * Gets a mesh using a given name
  91736. * @param name defines the name to search for
  91737. * @return the found mesh or null if not found at all.
  91738. */
  91739. getMeshByName(name: string): Nullable<AbstractMesh>;
  91740. /**
  91741. * Gets a transform node using a given name
  91742. * @param name defines the name to search for
  91743. * @return the found transform node or null if not found at all.
  91744. */
  91745. getTransformNodeByName(name: string): Nullable<TransformNode>;
  91746. /**
  91747. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  91748. * @param id defines the id to search for
  91749. * @return the found skeleton or null if not found at all.
  91750. */
  91751. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  91752. /**
  91753. * Gets a skeleton using a given auto generated unique id
  91754. * @param uniqueId defines the unique id to search for
  91755. * @return the found skeleton or null if not found at all.
  91756. */
  91757. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  91758. /**
  91759. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  91760. * @param id defines the id to search for
  91761. * @return the found skeleton or null if not found at all.
  91762. */
  91763. getSkeletonById(id: string): Nullable<Skeleton>;
  91764. /**
  91765. * Gets a skeleton using a given name
  91766. * @param name defines the name to search for
  91767. * @return the found skeleton or null if not found at all.
  91768. */
  91769. getSkeletonByName(name: string): Nullable<Skeleton>;
  91770. /**
  91771. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  91772. * @param id defines the id to search for
  91773. * @return the found morph target manager or null if not found at all.
  91774. */
  91775. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  91776. /**
  91777. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  91778. * @param id defines the id to search for
  91779. * @return the found morph target or null if not found at all.
  91780. */
  91781. getMorphTargetById(id: string): Nullable<MorphTarget>;
  91782. /**
  91783. * Gets a boolean indicating if the given mesh is active
  91784. * @param mesh defines the mesh to look for
  91785. * @returns true if the mesh is in the active list
  91786. */
  91787. isActiveMesh(mesh: AbstractMesh): boolean;
  91788. /**
  91789. * Return a unique id as a string which can serve as an identifier for the scene
  91790. */
  91791. readonly uid: string;
  91792. /**
  91793. * Add an externaly attached data from its key.
  91794. * This method call will fail and return false, if such key already exists.
  91795. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91796. * @param key the unique key that identifies the data
  91797. * @param data the data object to associate to the key for this Engine instance
  91798. * @return true if no such key were already present and the data was added successfully, false otherwise
  91799. */
  91800. addExternalData<T>(key: string, data: T): boolean;
  91801. /**
  91802. * Get an externaly attached data from its key
  91803. * @param key the unique key that identifies the data
  91804. * @return the associated data, if present (can be null), or undefined if not present
  91805. */
  91806. getExternalData<T>(key: string): Nullable<T>;
  91807. /**
  91808. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91809. * @param key the unique key that identifies the data
  91810. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91811. * @return the associated data, can be null if the factory returned null.
  91812. */
  91813. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91814. /**
  91815. * Remove an externaly attached data from the Engine instance
  91816. * @param key the unique key that identifies the data
  91817. * @return true if the data was successfully removed, false if it doesn't exist
  91818. */
  91819. removeExternalData(key: string): boolean;
  91820. private _evaluateSubMesh;
  91821. /**
  91822. * Clear the processed materials smart array preventing retention point in material dispose.
  91823. */
  91824. freeProcessedMaterials(): void;
  91825. private _preventFreeActiveMeshesAndRenderingGroups;
  91826. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  91827. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  91828. * when disposing several meshes in a row or a hierarchy of meshes.
  91829. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  91830. */
  91831. blockfreeActiveMeshesAndRenderingGroups: boolean;
  91832. /**
  91833. * Clear the active meshes smart array preventing retention point in mesh dispose.
  91834. */
  91835. freeActiveMeshes(): void;
  91836. /**
  91837. * Clear the info related to rendering groups preventing retention points during dispose.
  91838. */
  91839. freeRenderingGroups(): void;
  91840. /** @hidden */
  91841. _isInIntermediateRendering(): boolean;
  91842. /**
  91843. * Lambda returning the list of potentially active meshes.
  91844. */
  91845. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  91846. /**
  91847. * Lambda returning the list of potentially active sub meshes.
  91848. */
  91849. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  91850. /**
  91851. * Lambda returning the list of potentially intersecting sub meshes.
  91852. */
  91853. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  91854. /**
  91855. * Lambda returning the list of potentially colliding sub meshes.
  91856. */
  91857. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  91858. private _activeMeshesFrozen;
  91859. /**
  91860. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  91861. * @returns the current scene
  91862. */
  91863. freezeActiveMeshes(): Scene;
  91864. /**
  91865. * Use this function to restart evaluating active meshes on every frame
  91866. * @returns the current scene
  91867. */
  91868. unfreezeActiveMeshes(): Scene;
  91869. private _evaluateActiveMeshes;
  91870. private _activeMesh;
  91871. /**
  91872. * Update the transform matrix to update from the current active camera
  91873. * @param force defines a boolean used to force the update even if cache is up to date
  91874. */
  91875. updateTransformMatrix(force?: boolean): void;
  91876. private _bindFrameBuffer;
  91877. /** @hidden */
  91878. _allowPostProcessClearColor: boolean;
  91879. private _renderForCamera;
  91880. private _processSubCameras;
  91881. private _checkIntersections;
  91882. /** @hidden */
  91883. _advancePhysicsEngineStep(step: number): void;
  91884. /**
  91885. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  91886. */
  91887. getDeterministicFrameTime: () => number;
  91888. /** @hidden */
  91889. _animate(): void;
  91890. /**
  91891. * Render the scene
  91892. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  91893. */
  91894. render(updateCameras?: boolean): void;
  91895. /**
  91896. * Freeze all materials
  91897. * A frozen material will not be updatable but should be faster to render
  91898. */
  91899. freezeMaterials(): void;
  91900. /**
  91901. * Unfreeze all materials
  91902. * A frozen material will not be updatable but should be faster to render
  91903. */
  91904. unfreezeMaterials(): void;
  91905. /**
  91906. * Releases all held ressources
  91907. */
  91908. dispose(): void;
  91909. /**
  91910. * Gets if the scene is already disposed
  91911. */
  91912. readonly isDisposed: boolean;
  91913. /**
  91914. * Call this function to reduce memory footprint of the scene.
  91915. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  91916. */
  91917. clearCachedVertexData(): void;
  91918. /**
  91919. * This function will remove the local cached buffer data from texture.
  91920. * It will save memory but will prevent the texture from being rebuilt
  91921. */
  91922. cleanCachedTextureBuffer(): void;
  91923. /**
  91924. * Get the world extend vectors with an optional filter
  91925. *
  91926. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  91927. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  91928. */
  91929. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  91930. min: Vector3;
  91931. max: Vector3;
  91932. };
  91933. /**
  91934. * Creates a ray that can be used to pick in the scene
  91935. * @param x defines the x coordinate of the origin (on-screen)
  91936. * @param y defines the y coordinate of the origin (on-screen)
  91937. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91938. * @param camera defines the camera to use for the picking
  91939. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91940. * @returns a Ray
  91941. */
  91942. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  91943. /**
  91944. * Creates a ray that can be used to pick in the scene
  91945. * @param x defines the x coordinate of the origin (on-screen)
  91946. * @param y defines the y coordinate of the origin (on-screen)
  91947. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91948. * @param result defines the ray where to store the picking ray
  91949. * @param camera defines the camera to use for the picking
  91950. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91951. * @returns the current scene
  91952. */
  91953. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  91954. /**
  91955. * Creates a ray that can be used to pick in the scene
  91956. * @param x defines the x coordinate of the origin (on-screen)
  91957. * @param y defines the y coordinate of the origin (on-screen)
  91958. * @param camera defines the camera to use for the picking
  91959. * @returns a Ray
  91960. */
  91961. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  91962. /**
  91963. * Creates a ray that can be used to pick in the scene
  91964. * @param x defines the x coordinate of the origin (on-screen)
  91965. * @param y defines the y coordinate of the origin (on-screen)
  91966. * @param result defines the ray where to store the picking ray
  91967. * @param camera defines the camera to use for the picking
  91968. * @returns the current scene
  91969. */
  91970. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  91971. /** Launch a ray to try to pick a mesh in the scene
  91972. * @param x position on screen
  91973. * @param y position on screen
  91974. * @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
  91975. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  91976. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91977. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91978. * @returns a PickingInfo
  91979. */
  91980. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  91981. /** Use the given ray to pick a mesh in the scene
  91982. * @param ray The ray to use to pick meshes
  91983. * @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
  91984. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  91985. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91986. * @returns a PickingInfo
  91987. */
  91988. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91989. /**
  91990. * Launch a ray to try to pick a mesh in the scene
  91991. * @param x X position on screen
  91992. * @param y Y position on screen
  91993. * @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
  91994. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91995. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91996. * @returns an array of PickingInfo
  91997. */
  91998. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91999. /**
  92000. * Launch a ray to try to pick a mesh in the scene
  92001. * @param ray Ray to use
  92002. * @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
  92003. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92004. * @returns an array of PickingInfo
  92005. */
  92006. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92007. /**
  92008. * Force the value of meshUnderPointer
  92009. * @param mesh defines the mesh to use
  92010. */
  92011. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92012. /**
  92013. * Gets the mesh under the pointer
  92014. * @returns a Mesh or null if no mesh is under the pointer
  92015. */
  92016. getPointerOverMesh(): Nullable<AbstractMesh>;
  92017. /** @hidden */
  92018. _rebuildGeometries(): void;
  92019. /** @hidden */
  92020. _rebuildTextures(): void;
  92021. private _getByTags;
  92022. /**
  92023. * Get a list of meshes by tags
  92024. * @param tagsQuery defines the tags query to use
  92025. * @param forEach defines a predicate used to filter results
  92026. * @returns an array of Mesh
  92027. */
  92028. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92029. /**
  92030. * Get a list of cameras by tags
  92031. * @param tagsQuery defines the tags query to use
  92032. * @param forEach defines a predicate used to filter results
  92033. * @returns an array of Camera
  92034. */
  92035. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92036. /**
  92037. * Get a list of lights by tags
  92038. * @param tagsQuery defines the tags query to use
  92039. * @param forEach defines a predicate used to filter results
  92040. * @returns an array of Light
  92041. */
  92042. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92043. /**
  92044. * Get a list of materials by tags
  92045. * @param tagsQuery defines the tags query to use
  92046. * @param forEach defines a predicate used to filter results
  92047. * @returns an array of Material
  92048. */
  92049. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92050. /**
  92051. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92052. * This allowed control for front to back rendering or reversly depending of the special needs.
  92053. *
  92054. * @param renderingGroupId The rendering group id corresponding to its index
  92055. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92056. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92057. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92058. */
  92059. 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;
  92060. /**
  92061. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92062. *
  92063. * @param renderingGroupId The rendering group id corresponding to its index
  92064. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92065. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92066. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92067. */
  92068. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92069. /**
  92070. * Gets the current auto clear configuration for one rendering group of the rendering
  92071. * manager.
  92072. * @param index the rendering group index to get the information for
  92073. * @returns The auto clear setup for the requested rendering group
  92074. */
  92075. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92076. private _blockMaterialDirtyMechanism;
  92077. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92078. blockMaterialDirtyMechanism: boolean;
  92079. /**
  92080. * Will flag all materials as dirty to trigger new shader compilation
  92081. * @param flag defines the flag used to specify which material part must be marked as dirty
  92082. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92083. */
  92084. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92085. /** @hidden */
  92086. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  92087. /** @hidden */
  92088. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92089. }
  92090. }
  92091. declare module BABYLON {
  92092. /**
  92093. * Set of assets to keep when moving a scene into an asset container.
  92094. */
  92095. export class KeepAssets extends AbstractScene {
  92096. }
  92097. /**
  92098. * Container with a set of assets that can be added or removed from a scene.
  92099. */
  92100. export class AssetContainer extends AbstractScene {
  92101. /**
  92102. * The scene the AssetContainer belongs to.
  92103. */
  92104. scene: Scene;
  92105. /**
  92106. * Instantiates an AssetContainer.
  92107. * @param scene The scene the AssetContainer belongs to.
  92108. */
  92109. constructor(scene: Scene);
  92110. /**
  92111. * Adds all the assets from the container to the scene.
  92112. */
  92113. addAllToScene(): void;
  92114. /**
  92115. * Removes all the assets in the container from the scene
  92116. */
  92117. removeAllFromScene(): void;
  92118. /**
  92119. * Disposes all the assets in the container
  92120. */
  92121. dispose(): void;
  92122. private _moveAssets;
  92123. /**
  92124. * Removes all the assets contained in the scene and adds them to the container.
  92125. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92126. */
  92127. moveAllFromScene(keepAssets?: KeepAssets): void;
  92128. /**
  92129. * 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.
  92130. * @returns the root mesh
  92131. */
  92132. createRootMesh(): Mesh;
  92133. }
  92134. }
  92135. declare module BABYLON {
  92136. /**
  92137. * Defines how the parser contract is defined.
  92138. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92139. */
  92140. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92141. /**
  92142. * Defines how the individual parser contract is defined.
  92143. * These parser can parse an individual asset
  92144. */
  92145. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92146. /**
  92147. * Base class of the scene acting as a container for the different elements composing a scene.
  92148. * This class is dynamically extended by the different components of the scene increasing
  92149. * flexibility and reducing coupling
  92150. */
  92151. export abstract class AbstractScene {
  92152. /**
  92153. * Stores the list of available parsers in the application.
  92154. */
  92155. private static _BabylonFileParsers;
  92156. /**
  92157. * Stores the list of available individual parsers in the application.
  92158. */
  92159. private static _IndividualBabylonFileParsers;
  92160. /**
  92161. * Adds a parser in the list of available ones
  92162. * @param name Defines the name of the parser
  92163. * @param parser Defines the parser to add
  92164. */
  92165. static AddParser(name: string, parser: BabylonFileParser): void;
  92166. /**
  92167. * Gets a general parser from the list of avaialble ones
  92168. * @param name Defines the name of the parser
  92169. * @returns the requested parser or null
  92170. */
  92171. static GetParser(name: string): Nullable<BabylonFileParser>;
  92172. /**
  92173. * Adds n individual parser in the list of available ones
  92174. * @param name Defines the name of the parser
  92175. * @param parser Defines the parser to add
  92176. */
  92177. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92178. /**
  92179. * Gets an individual parser from the list of avaialble ones
  92180. * @param name Defines the name of the parser
  92181. * @returns the requested parser or null
  92182. */
  92183. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92184. /**
  92185. * Parser json data and populate both a scene and its associated container object
  92186. * @param jsonData Defines the data to parse
  92187. * @param scene Defines the scene to parse the data for
  92188. * @param container Defines the container attached to the parsing sequence
  92189. * @param rootUrl Defines the root url of the data
  92190. */
  92191. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92192. /**
  92193. * Gets the list of root nodes (ie. nodes with no parent)
  92194. */
  92195. rootNodes: Node[];
  92196. /** All of the cameras added to this scene
  92197. * @see http://doc.babylonjs.com/babylon101/cameras
  92198. */
  92199. cameras: Camera[];
  92200. /**
  92201. * All of the lights added to this scene
  92202. * @see http://doc.babylonjs.com/babylon101/lights
  92203. */
  92204. lights: Light[];
  92205. /**
  92206. * All of the (abstract) meshes added to this scene
  92207. */
  92208. meshes: AbstractMesh[];
  92209. /**
  92210. * The list of skeletons added to the scene
  92211. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92212. */
  92213. skeletons: Skeleton[];
  92214. /**
  92215. * All of the particle systems added to this scene
  92216. * @see http://doc.babylonjs.com/babylon101/particles
  92217. */
  92218. particleSystems: IParticleSystem[];
  92219. /**
  92220. * Gets a list of Animations associated with the scene
  92221. */
  92222. animations: Animation[];
  92223. /**
  92224. * All of the animation groups added to this scene
  92225. * @see http://doc.babylonjs.com/how_to/group
  92226. */
  92227. animationGroups: AnimationGroup[];
  92228. /**
  92229. * All of the multi-materials added to this scene
  92230. * @see http://doc.babylonjs.com/how_to/multi_materials
  92231. */
  92232. multiMaterials: MultiMaterial[];
  92233. /**
  92234. * All of the materials added to this scene
  92235. * In the context of a Scene, it is not supposed to be modified manually.
  92236. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92237. * Note also that the order of the Material wihin the array is not significant and might change.
  92238. * @see http://doc.babylonjs.com/babylon101/materials
  92239. */
  92240. materials: Material[];
  92241. /**
  92242. * The list of morph target managers added to the scene
  92243. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92244. */
  92245. morphTargetManagers: MorphTargetManager[];
  92246. /**
  92247. * The list of geometries used in the scene.
  92248. */
  92249. geometries: Geometry[];
  92250. /**
  92251. * All of the tranform nodes added to this scene
  92252. * In the context of a Scene, it is not supposed to be modified manually.
  92253. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92254. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92255. * @see http://doc.babylonjs.com/how_to/transformnode
  92256. */
  92257. transformNodes: TransformNode[];
  92258. /**
  92259. * ActionManagers available on the scene.
  92260. */
  92261. actionManagers: AbstractActionManager[];
  92262. /**
  92263. * Textures to keep.
  92264. */
  92265. textures: BaseTexture[];
  92266. /**
  92267. * Environment texture for the scene
  92268. */
  92269. environmentTexture: Nullable<BaseTexture>;
  92270. }
  92271. }
  92272. declare module BABYLON {
  92273. /**
  92274. * Defines a sound that can be played in the application.
  92275. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  92276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92277. */
  92278. export class Sound {
  92279. /**
  92280. * The name of the sound in the scene.
  92281. */
  92282. name: string;
  92283. /**
  92284. * Does the sound autoplay once loaded.
  92285. */
  92286. autoplay: boolean;
  92287. /**
  92288. * Does the sound loop after it finishes playing once.
  92289. */
  92290. loop: boolean;
  92291. /**
  92292. * Does the sound use a custom attenuation curve to simulate the falloff
  92293. * happening when the source gets further away from the camera.
  92294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92295. */
  92296. useCustomAttenuation: boolean;
  92297. /**
  92298. * The sound track id this sound belongs to.
  92299. */
  92300. soundTrackId: number;
  92301. /**
  92302. * Is this sound currently played.
  92303. */
  92304. isPlaying: boolean;
  92305. /**
  92306. * Is this sound currently paused.
  92307. */
  92308. isPaused: boolean;
  92309. /**
  92310. * Does this sound enables spatial sound.
  92311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92312. */
  92313. spatialSound: boolean;
  92314. /**
  92315. * Define the reference distance the sound should be heard perfectly.
  92316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92317. */
  92318. refDistance: number;
  92319. /**
  92320. * Define the roll off factor of spatial sounds.
  92321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92322. */
  92323. rolloffFactor: number;
  92324. /**
  92325. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  92326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92327. */
  92328. maxDistance: number;
  92329. /**
  92330. * Define the distance attenuation model the sound will follow.
  92331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92332. */
  92333. distanceModel: string;
  92334. /**
  92335. * @hidden
  92336. * Back Compat
  92337. **/
  92338. onended: () => any;
  92339. /**
  92340. * Observable event when the current playing sound finishes.
  92341. */
  92342. onEndedObservable: Observable<Sound>;
  92343. private _panningModel;
  92344. private _playbackRate;
  92345. private _streaming;
  92346. private _startTime;
  92347. private _startOffset;
  92348. private _position;
  92349. /** @hidden */
  92350. _positionInEmitterSpace: boolean;
  92351. private _localDirection;
  92352. private _volume;
  92353. private _isReadyToPlay;
  92354. private _isDirectional;
  92355. private _readyToPlayCallback;
  92356. private _audioBuffer;
  92357. private _soundSource;
  92358. private _streamingSource;
  92359. private _soundPanner;
  92360. private _soundGain;
  92361. private _inputAudioNode;
  92362. private _outputAudioNode;
  92363. private _coneInnerAngle;
  92364. private _coneOuterAngle;
  92365. private _coneOuterGain;
  92366. private _scene;
  92367. private _connectedTransformNode;
  92368. private _customAttenuationFunction;
  92369. private _registerFunc;
  92370. private _isOutputConnected;
  92371. private _htmlAudioElement;
  92372. private _urlType;
  92373. /** @hidden */
  92374. static _SceneComponentInitialization: (scene: Scene) => void;
  92375. /**
  92376. * Create a sound and attach it to a scene
  92377. * @param name Name of your sound
  92378. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  92379. * @param scene defines the scene the sound belongs to
  92380. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  92381. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  92382. */
  92383. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  92384. /**
  92385. * Release the sound and its associated resources
  92386. */
  92387. dispose(): void;
  92388. /**
  92389. * Gets if the sounds is ready to be played or not.
  92390. * @returns true if ready, otherwise false
  92391. */
  92392. isReady(): boolean;
  92393. private _soundLoaded;
  92394. /**
  92395. * Sets the data of the sound from an audiobuffer
  92396. * @param audioBuffer The audioBuffer containing the data
  92397. */
  92398. setAudioBuffer(audioBuffer: AudioBuffer): void;
  92399. /**
  92400. * Updates the current sounds options such as maxdistance, loop...
  92401. * @param options A JSON object containing values named as the object properties
  92402. */
  92403. updateOptions(options: any): void;
  92404. private _createSpatialParameters;
  92405. private _updateSpatialParameters;
  92406. /**
  92407. * Switch the panning model to HRTF:
  92408. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92410. */
  92411. switchPanningModelToHRTF(): void;
  92412. /**
  92413. * Switch the panning model to Equal Power:
  92414. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92416. */
  92417. switchPanningModelToEqualPower(): void;
  92418. private _switchPanningModel;
  92419. /**
  92420. * Connect this sound to a sound track audio node like gain...
  92421. * @param soundTrackAudioNode the sound track audio node to connect to
  92422. */
  92423. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  92424. /**
  92425. * Transform this sound into a directional source
  92426. * @param coneInnerAngle Size of the inner cone in degree
  92427. * @param coneOuterAngle Size of the outer cone in degree
  92428. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  92429. */
  92430. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  92431. /**
  92432. * Gets or sets the inner angle for the directional cone.
  92433. */
  92434. /**
  92435. * Gets or sets the inner angle for the directional cone.
  92436. */
  92437. directionalConeInnerAngle: number;
  92438. /**
  92439. * Gets or sets the outer angle for the directional cone.
  92440. */
  92441. /**
  92442. * Gets or sets the outer angle for the directional cone.
  92443. */
  92444. directionalConeOuterAngle: number;
  92445. /**
  92446. * Sets the position of the emitter if spatial sound is enabled
  92447. * @param newPosition Defines the new posisiton
  92448. */
  92449. setPosition(newPosition: Vector3): void;
  92450. /**
  92451. * Sets the local direction of the emitter if spatial sound is enabled
  92452. * @param newLocalDirection Defines the new local direction
  92453. */
  92454. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  92455. private _updateDirection;
  92456. /** @hidden */
  92457. updateDistanceFromListener(): void;
  92458. /**
  92459. * Sets a new custom attenuation function for the sound.
  92460. * @param callback Defines the function used for the attenuation
  92461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92462. */
  92463. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  92464. /**
  92465. * Play the sound
  92466. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  92467. * @param offset (optional) Start the sound setting it at a specific time
  92468. */
  92469. play(time?: number, offset?: number): void;
  92470. private _onended;
  92471. /**
  92472. * Stop the sound
  92473. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  92474. */
  92475. stop(time?: number): void;
  92476. /**
  92477. * Put the sound in pause
  92478. */
  92479. pause(): void;
  92480. /**
  92481. * Sets a dedicated volume for this sounds
  92482. * @param newVolume Define the new volume of the sound
  92483. * @param time Define in how long the sound should be at this value
  92484. */
  92485. setVolume(newVolume: number, time?: number): void;
  92486. /**
  92487. * Set the sound play back rate
  92488. * @param newPlaybackRate Define the playback rate the sound should be played at
  92489. */
  92490. setPlaybackRate(newPlaybackRate: number): void;
  92491. /**
  92492. * Gets the volume of the sound.
  92493. * @returns the volume of the sound
  92494. */
  92495. getVolume(): number;
  92496. /**
  92497. * Attach the sound to a dedicated mesh
  92498. * @param transformNode The transform node to connect the sound with
  92499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92500. */
  92501. attachToMesh(transformNode: TransformNode): void;
  92502. /**
  92503. * Detach the sound from the previously attached mesh
  92504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92505. */
  92506. detachFromMesh(): void;
  92507. private _onRegisterAfterWorldMatrixUpdate;
  92508. /**
  92509. * Clone the current sound in the scene.
  92510. * @returns the new sound clone
  92511. */
  92512. clone(): Nullable<Sound>;
  92513. /**
  92514. * Gets the current underlying audio buffer containing the data
  92515. * @returns the audio buffer
  92516. */
  92517. getAudioBuffer(): Nullable<AudioBuffer>;
  92518. /**
  92519. * Serializes the Sound in a JSON representation
  92520. * @returns the JSON representation of the sound
  92521. */
  92522. serialize(): any;
  92523. /**
  92524. * Parse a JSON representation of a sound to innstantiate in a given scene
  92525. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92526. * @param scene Define the scene the new parsed sound should be created in
  92527. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92528. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92529. * @returns the newly parsed sound
  92530. */
  92531. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92532. }
  92533. }
  92534. declare module BABYLON {
  92535. /**
  92536. * This defines an action helpful to play a defined sound on a triggered action.
  92537. */
  92538. export class PlaySoundAction extends Action {
  92539. private _sound;
  92540. /**
  92541. * Instantiate the action
  92542. * @param triggerOptions defines the trigger options
  92543. * @param sound defines the sound to play
  92544. * @param condition defines the trigger related conditions
  92545. */
  92546. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92547. /** @hidden */
  92548. _prepare(): void;
  92549. /**
  92550. * Execute the action and play the sound.
  92551. */
  92552. execute(): void;
  92553. /**
  92554. * Serializes the actions and its related information.
  92555. * @param parent defines the object to serialize in
  92556. * @returns the serialized object
  92557. */
  92558. serialize(parent: any): any;
  92559. }
  92560. /**
  92561. * This defines an action helpful to stop a defined sound on a triggered action.
  92562. */
  92563. export class StopSoundAction extends Action {
  92564. private _sound;
  92565. /**
  92566. * Instantiate the action
  92567. * @param triggerOptions defines the trigger options
  92568. * @param sound defines the sound to stop
  92569. * @param condition defines the trigger related conditions
  92570. */
  92571. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92572. /** @hidden */
  92573. _prepare(): void;
  92574. /**
  92575. * Execute the action and stop the sound.
  92576. */
  92577. execute(): void;
  92578. /**
  92579. * Serializes the actions and its related information.
  92580. * @param parent defines the object to serialize in
  92581. * @returns the serialized object
  92582. */
  92583. serialize(parent: any): any;
  92584. }
  92585. }
  92586. declare module BABYLON {
  92587. /**
  92588. * This defines an action responsible to change the value of a property
  92589. * by interpolating between its current value and the newly set one once triggered.
  92590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92591. */
  92592. export class InterpolateValueAction extends Action {
  92593. /**
  92594. * Defines the path of the property where the value should be interpolated
  92595. */
  92596. propertyPath: string;
  92597. /**
  92598. * Defines the target value at the end of the interpolation.
  92599. */
  92600. value: any;
  92601. /**
  92602. * Defines the time it will take for the property to interpolate to the value.
  92603. */
  92604. duration: number;
  92605. /**
  92606. * Defines if the other scene animations should be stopped when the action has been triggered
  92607. */
  92608. stopOtherAnimations?: boolean;
  92609. /**
  92610. * Defines a callback raised once the interpolation animation has been done.
  92611. */
  92612. onInterpolationDone?: () => void;
  92613. /**
  92614. * Observable triggered once the interpolation animation has been done.
  92615. */
  92616. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  92617. private _target;
  92618. private _effectiveTarget;
  92619. private _property;
  92620. /**
  92621. * Instantiate the action
  92622. * @param triggerOptions defines the trigger options
  92623. * @param target defines the object containing the value to interpolate
  92624. * @param propertyPath defines the path to the property in the target object
  92625. * @param value defines the target value at the end of the interpolation
  92626. * @param duration deines the time it will take for the property to interpolate to the value.
  92627. * @param condition defines the trigger related conditions
  92628. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  92629. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  92630. */
  92631. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  92632. /** @hidden */
  92633. _prepare(): void;
  92634. /**
  92635. * Execute the action starts the value interpolation.
  92636. */
  92637. execute(): void;
  92638. /**
  92639. * Serializes the actions and its related information.
  92640. * @param parent defines the object to serialize in
  92641. * @returns the serialized object
  92642. */
  92643. serialize(parent: any): any;
  92644. }
  92645. }
  92646. declare module BABYLON {
  92647. /**
  92648. * Options allowed during the creation of a sound track.
  92649. */
  92650. export interface ISoundTrackOptions {
  92651. /**
  92652. * The volume the sound track should take during creation
  92653. */
  92654. volume?: number;
  92655. /**
  92656. * Define if the sound track is the main sound track of the scene
  92657. */
  92658. mainTrack?: boolean;
  92659. }
  92660. /**
  92661. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  92662. * It will be also used in a future release to apply effects on a specific track.
  92663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92664. */
  92665. export class SoundTrack {
  92666. /**
  92667. * The unique identifier of the sound track in the scene.
  92668. */
  92669. id: number;
  92670. /**
  92671. * The list of sounds included in the sound track.
  92672. */
  92673. soundCollection: Array<Sound>;
  92674. private _outputAudioNode;
  92675. private _scene;
  92676. private _isMainTrack;
  92677. private _connectedAnalyser;
  92678. private _options;
  92679. private _isInitialized;
  92680. /**
  92681. * Creates a new sound track.
  92682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92683. * @param scene Define the scene the sound track belongs to
  92684. * @param options
  92685. */
  92686. constructor(scene: Scene, options?: ISoundTrackOptions);
  92687. private _initializeSoundTrackAudioGraph;
  92688. /**
  92689. * Release the sound track and its associated resources
  92690. */
  92691. dispose(): void;
  92692. /**
  92693. * Adds a sound to this sound track
  92694. * @param sound define the cound to add
  92695. * @ignoreNaming
  92696. */
  92697. AddSound(sound: Sound): void;
  92698. /**
  92699. * Removes a sound to this sound track
  92700. * @param sound define the cound to remove
  92701. * @ignoreNaming
  92702. */
  92703. RemoveSound(sound: Sound): void;
  92704. /**
  92705. * Set a global volume for the full sound track.
  92706. * @param newVolume Define the new volume of the sound track
  92707. */
  92708. setVolume(newVolume: number): void;
  92709. /**
  92710. * Switch the panning model to HRTF:
  92711. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92713. */
  92714. switchPanningModelToHRTF(): void;
  92715. /**
  92716. * Switch the panning model to Equal Power:
  92717. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92719. */
  92720. switchPanningModelToEqualPower(): void;
  92721. /**
  92722. * Connect the sound track to an audio analyser allowing some amazing
  92723. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92725. * @param analyser The analyser to connect to the engine
  92726. */
  92727. connectToAnalyser(analyser: Analyser): void;
  92728. }
  92729. }
  92730. declare module BABYLON {
  92731. interface AbstractScene {
  92732. /**
  92733. * The list of sounds used in the scene.
  92734. */
  92735. sounds: Nullable<Array<Sound>>;
  92736. }
  92737. interface Scene {
  92738. /**
  92739. * @hidden
  92740. * Backing field
  92741. */
  92742. _mainSoundTrack: SoundTrack;
  92743. /**
  92744. * The main sound track played by the scene.
  92745. * It cotains your primary collection of sounds.
  92746. */
  92747. mainSoundTrack: SoundTrack;
  92748. /**
  92749. * The list of sound tracks added to the scene
  92750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92751. */
  92752. soundTracks: Nullable<Array<SoundTrack>>;
  92753. /**
  92754. * Gets a sound using a given name
  92755. * @param name defines the name to search for
  92756. * @return the found sound or null if not found at all.
  92757. */
  92758. getSoundByName(name: string): Nullable<Sound>;
  92759. /**
  92760. * Gets or sets if audio support is enabled
  92761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92762. */
  92763. audioEnabled: boolean;
  92764. /**
  92765. * Gets or sets if audio will be output to headphones
  92766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92767. */
  92768. headphone: boolean;
  92769. }
  92770. /**
  92771. * Defines the sound scene component responsible to manage any sounds
  92772. * in a given scene.
  92773. */
  92774. export class AudioSceneComponent implements ISceneSerializableComponent {
  92775. /**
  92776. * The component name helpfull to identify the component in the list of scene components.
  92777. */
  92778. readonly name: string;
  92779. /**
  92780. * The scene the component belongs to.
  92781. */
  92782. scene: Scene;
  92783. private _audioEnabled;
  92784. /**
  92785. * Gets whether audio is enabled or not.
  92786. * Please use related enable/disable method to switch state.
  92787. */
  92788. readonly audioEnabled: boolean;
  92789. private _headphone;
  92790. /**
  92791. * Gets whether audio is outputing to headphone or not.
  92792. * Please use the according Switch methods to change output.
  92793. */
  92794. readonly headphone: boolean;
  92795. /**
  92796. * Creates a new instance of the component for the given scene
  92797. * @param scene Defines the scene to register the component in
  92798. */
  92799. constructor(scene: Scene);
  92800. /**
  92801. * Registers the component in a given scene
  92802. */
  92803. register(): void;
  92804. /**
  92805. * Rebuilds the elements related to this component in case of
  92806. * context lost for instance.
  92807. */
  92808. rebuild(): void;
  92809. /**
  92810. * Serializes the component data to the specified json object
  92811. * @param serializationObject The object to serialize to
  92812. */
  92813. serialize(serializationObject: any): void;
  92814. /**
  92815. * Adds all the element from the container to the scene
  92816. * @param container the container holding the elements
  92817. */
  92818. addFromContainer(container: AbstractScene): void;
  92819. /**
  92820. * Removes all the elements in the container from the scene
  92821. * @param container contains the elements to remove
  92822. * @param dispose if the removed element should be disposed (default: false)
  92823. */
  92824. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  92825. /**
  92826. * Disposes the component and the associated ressources.
  92827. */
  92828. dispose(): void;
  92829. /**
  92830. * Disables audio in the associated scene.
  92831. */
  92832. disableAudio(): void;
  92833. /**
  92834. * Enables audio in the associated scene.
  92835. */
  92836. enableAudio(): void;
  92837. /**
  92838. * Switch audio to headphone output.
  92839. */
  92840. switchAudioModeForHeadphones(): void;
  92841. /**
  92842. * Switch audio to normal speakers.
  92843. */
  92844. switchAudioModeForNormalSpeakers(): void;
  92845. private _afterRender;
  92846. }
  92847. }
  92848. declare module BABYLON {
  92849. /**
  92850. * Wraps one or more Sound objects and selects one with random weight for playback.
  92851. */
  92852. export class WeightedSound {
  92853. /** When true a Sound will be selected and played when the current playing Sound completes. */
  92854. loop: boolean;
  92855. private _coneInnerAngle;
  92856. private _coneOuterAngle;
  92857. private _volume;
  92858. /** A Sound is currently playing. */
  92859. isPlaying: boolean;
  92860. /** A Sound is currently paused. */
  92861. isPaused: boolean;
  92862. private _sounds;
  92863. private _weights;
  92864. private _currentIndex?;
  92865. /**
  92866. * Creates a new WeightedSound from the list of sounds given.
  92867. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  92868. * @param sounds Array of Sounds that will be selected from.
  92869. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  92870. */
  92871. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  92872. /**
  92873. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  92874. */
  92875. /**
  92876. * The size of cone in degress for a directional sound in which there will be no attenuation.
  92877. */
  92878. directionalConeInnerAngle: number;
  92879. /**
  92880. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92881. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92882. */
  92883. /**
  92884. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92885. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92886. */
  92887. directionalConeOuterAngle: number;
  92888. /**
  92889. * Playback volume.
  92890. */
  92891. /**
  92892. * Playback volume.
  92893. */
  92894. volume: number;
  92895. private _onended;
  92896. /**
  92897. * Suspend playback
  92898. */
  92899. pause(): void;
  92900. /**
  92901. * Stop playback
  92902. */
  92903. stop(): void;
  92904. /**
  92905. * Start playback.
  92906. * @param startOffset Position the clip head at a specific time in seconds.
  92907. */
  92908. play(startOffset?: number): void;
  92909. }
  92910. }
  92911. declare module BABYLON {
  92912. /**
  92913. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  92914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92915. */
  92916. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  92917. /**
  92918. * Gets the name of the behavior.
  92919. */
  92920. readonly name: string;
  92921. /**
  92922. * The easing function used by animations
  92923. */
  92924. static EasingFunction: BackEase;
  92925. /**
  92926. * The easing mode used by animations
  92927. */
  92928. static EasingMode: number;
  92929. /**
  92930. * The duration of the animation, in milliseconds
  92931. */
  92932. transitionDuration: number;
  92933. /**
  92934. * Length of the distance animated by the transition when lower radius is reached
  92935. */
  92936. lowerRadiusTransitionRange: number;
  92937. /**
  92938. * Length of the distance animated by the transition when upper radius is reached
  92939. */
  92940. upperRadiusTransitionRange: number;
  92941. private _autoTransitionRange;
  92942. /**
  92943. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92944. */
  92945. /**
  92946. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92947. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  92948. */
  92949. autoTransitionRange: boolean;
  92950. private _attachedCamera;
  92951. private _onAfterCheckInputsObserver;
  92952. private _onMeshTargetChangedObserver;
  92953. /**
  92954. * Initializes the behavior.
  92955. */
  92956. init(): void;
  92957. /**
  92958. * Attaches the behavior to its arc rotate camera.
  92959. * @param camera Defines the camera to attach the behavior to
  92960. */
  92961. attach(camera: ArcRotateCamera): void;
  92962. /**
  92963. * Detaches the behavior from its current arc rotate camera.
  92964. */
  92965. detach(): void;
  92966. private _radiusIsAnimating;
  92967. private _radiusBounceTransition;
  92968. private _animatables;
  92969. private _cachedWheelPrecision;
  92970. /**
  92971. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  92972. * @param radiusLimit The limit to check against.
  92973. * @return Bool to indicate if at limit.
  92974. */
  92975. private _isRadiusAtLimit;
  92976. /**
  92977. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  92978. * @param radiusDelta The delta by which to animate to. Can be negative.
  92979. */
  92980. private _applyBoundRadiusAnimation;
  92981. /**
  92982. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  92983. */
  92984. protected _clearAnimationLocks(): void;
  92985. /**
  92986. * Stops and removes all animations that have been applied to the camera
  92987. */
  92988. stopAllAnimations(): void;
  92989. }
  92990. }
  92991. declare module BABYLON {
  92992. /**
  92993. * 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.
  92994. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92995. */
  92996. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  92997. /**
  92998. * Gets the name of the behavior.
  92999. */
  93000. readonly name: string;
  93001. private _mode;
  93002. private _radiusScale;
  93003. private _positionScale;
  93004. private _defaultElevation;
  93005. private _elevationReturnTime;
  93006. private _elevationReturnWaitTime;
  93007. private _zoomStopsAnimation;
  93008. private _framingTime;
  93009. /**
  93010. * The easing function used by animations
  93011. */
  93012. static EasingFunction: ExponentialEase;
  93013. /**
  93014. * The easing mode used by animations
  93015. */
  93016. static EasingMode: number;
  93017. /**
  93018. * Sets the current mode used by the behavior
  93019. */
  93020. /**
  93021. * Gets current mode used by the behavior.
  93022. */
  93023. mode: number;
  93024. /**
  93025. * Sets the scale applied to the radius (1 by default)
  93026. */
  93027. /**
  93028. * Gets the scale applied to the radius
  93029. */
  93030. radiusScale: number;
  93031. /**
  93032. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93033. */
  93034. /**
  93035. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93036. */
  93037. positionScale: number;
  93038. /**
  93039. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93040. * behaviour is triggered, in radians.
  93041. */
  93042. /**
  93043. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93044. * behaviour is triggered, in radians.
  93045. */
  93046. defaultElevation: number;
  93047. /**
  93048. * Sets the time (in milliseconds) taken to return to the default beta position.
  93049. * Negative value indicates camera should not return to default.
  93050. */
  93051. /**
  93052. * Gets the time (in milliseconds) taken to return to the default beta position.
  93053. * Negative value indicates camera should not return to default.
  93054. */
  93055. elevationReturnTime: number;
  93056. /**
  93057. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93058. */
  93059. /**
  93060. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93061. */
  93062. elevationReturnWaitTime: number;
  93063. /**
  93064. * Sets the flag that indicates if user zooming should stop animation.
  93065. */
  93066. /**
  93067. * Gets the flag that indicates if user zooming should stop animation.
  93068. */
  93069. zoomStopsAnimation: boolean;
  93070. /**
  93071. * Sets the transition time when framing the mesh, in milliseconds
  93072. */
  93073. /**
  93074. * Gets the transition time when framing the mesh, in milliseconds
  93075. */
  93076. framingTime: number;
  93077. /**
  93078. * Define if the behavior should automatically change the configured
  93079. * camera limits and sensibilities.
  93080. */
  93081. autoCorrectCameraLimitsAndSensibility: boolean;
  93082. private _onPrePointerObservableObserver;
  93083. private _onAfterCheckInputsObserver;
  93084. private _onMeshTargetChangedObserver;
  93085. private _attachedCamera;
  93086. private _isPointerDown;
  93087. private _lastInteractionTime;
  93088. /**
  93089. * Initializes the behavior.
  93090. */
  93091. init(): void;
  93092. /**
  93093. * Attaches the behavior to its arc rotate camera.
  93094. * @param camera Defines the camera to attach the behavior to
  93095. */
  93096. attach(camera: ArcRotateCamera): void;
  93097. /**
  93098. * Detaches the behavior from its current arc rotate camera.
  93099. */
  93100. detach(): void;
  93101. private _animatables;
  93102. private _betaIsAnimating;
  93103. private _betaTransition;
  93104. private _radiusTransition;
  93105. private _vectorTransition;
  93106. /**
  93107. * Targets the given mesh and updates zoom level accordingly.
  93108. * @param mesh The mesh to target.
  93109. * @param radius Optional. If a cached radius position already exists, overrides default.
  93110. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93111. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93112. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93113. */
  93114. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93115. /**
  93116. * Targets the given mesh with its children and updates zoom level accordingly.
  93117. * @param mesh The mesh to target.
  93118. * @param radius Optional. If a cached radius position already exists, overrides default.
  93119. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93120. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93121. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93122. */
  93123. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93124. /**
  93125. * Targets the given meshes with their children and updates zoom level accordingly.
  93126. * @param meshes The mesh to target.
  93127. * @param radius Optional. If a cached radius position already exists, overrides default.
  93128. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93129. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93130. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93131. */
  93132. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93133. /**
  93134. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93135. * @param minimumWorld Determines the smaller position of the bounding box extend
  93136. * @param maximumWorld Determines the bigger position of the bounding box extend
  93137. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93138. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93139. */
  93140. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93141. /**
  93142. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93143. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93144. * frustum width.
  93145. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93146. * to fully enclose the mesh in the viewing frustum.
  93147. */
  93148. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93149. /**
  93150. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93151. * is automatically returned to its default position (expected to be above ground plane).
  93152. */
  93153. private _maintainCameraAboveGround;
  93154. /**
  93155. * Returns the frustum slope based on the canvas ratio and camera FOV
  93156. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93157. */
  93158. private _getFrustumSlope;
  93159. /**
  93160. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93161. */
  93162. private _clearAnimationLocks;
  93163. /**
  93164. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93165. */
  93166. private _applyUserInteraction;
  93167. /**
  93168. * Stops and removes all animations that have been applied to the camera
  93169. */
  93170. stopAllAnimations(): void;
  93171. /**
  93172. * Gets a value indicating if the user is moving the camera
  93173. */
  93174. readonly isUserIsMoving: boolean;
  93175. /**
  93176. * The camera can move all the way towards the mesh.
  93177. */
  93178. static IgnoreBoundsSizeMode: number;
  93179. /**
  93180. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93181. */
  93182. static FitFrustumSidesMode: number;
  93183. }
  93184. }
  93185. declare module BABYLON {
  93186. /**
  93187. * Base class for Camera Pointer Inputs.
  93188. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93189. * for example usage.
  93190. */
  93191. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93192. /**
  93193. * Defines the camera the input is attached to.
  93194. */
  93195. abstract camera: Camera;
  93196. /**
  93197. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93198. */
  93199. protected _altKey: boolean;
  93200. protected _ctrlKey: boolean;
  93201. protected _metaKey: boolean;
  93202. protected _shiftKey: boolean;
  93203. /**
  93204. * Which mouse buttons were pressed at time of last mouse event.
  93205. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93206. */
  93207. protected _buttonsPressed: number;
  93208. /**
  93209. * Defines the buttons associated with the input to handle camera move.
  93210. */
  93211. buttons: number[];
  93212. /**
  93213. * Attach the input controls to a specific dom element to get the input from.
  93214. * @param element Defines the element the controls should be listened from
  93215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93216. */
  93217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93218. /**
  93219. * Detach the current controls from the specified dom element.
  93220. * @param element Defines the element to stop listening the inputs from
  93221. */
  93222. detachControl(element: Nullable<HTMLElement>): void;
  93223. /**
  93224. * Gets the class name of the current input.
  93225. * @returns the class name
  93226. */
  93227. getClassName(): string;
  93228. /**
  93229. * Get the friendly name associated with the input class.
  93230. * @returns the input friendly name
  93231. */
  93232. getSimpleName(): string;
  93233. /**
  93234. * Called on pointer POINTERDOUBLETAP event.
  93235. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93236. */
  93237. protected onDoubleTap(type: string): void;
  93238. /**
  93239. * Called on pointer POINTERMOVE event if only a single touch is active.
  93240. * Override this method to provide functionality.
  93241. */
  93242. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93243. /**
  93244. * Called on pointer POINTERMOVE event if multiple touches are active.
  93245. * Override this method to provide functionality.
  93246. */
  93247. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93248. /**
  93249. * Called on JS contextmenu event.
  93250. * Override this method to provide functionality.
  93251. */
  93252. protected onContextMenu(evt: PointerEvent): void;
  93253. /**
  93254. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93255. * press.
  93256. * Override this method to provide functionality.
  93257. */
  93258. protected onButtonDown(evt: PointerEvent): void;
  93259. /**
  93260. * Called each time a new POINTERUP event occurs. Ie, for each button
  93261. * release.
  93262. * Override this method to provide functionality.
  93263. */
  93264. protected onButtonUp(evt: PointerEvent): void;
  93265. /**
  93266. * Called when window becomes inactive.
  93267. * Override this method to provide functionality.
  93268. */
  93269. protected onLostFocus(): void;
  93270. private _pointerInput;
  93271. private _observer;
  93272. private _onLostFocus;
  93273. private pointA;
  93274. private pointB;
  93275. }
  93276. }
  93277. declare module BABYLON {
  93278. /**
  93279. * Manage the pointers inputs to control an arc rotate camera.
  93280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93281. */
  93282. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  93283. /**
  93284. * Defines the camera the input is attached to.
  93285. */
  93286. camera: ArcRotateCamera;
  93287. /**
  93288. * Gets the class name of the current input.
  93289. * @returns the class name
  93290. */
  93291. getClassName(): string;
  93292. /**
  93293. * Defines the buttons associated with the input to handle camera move.
  93294. */
  93295. buttons: number[];
  93296. /**
  93297. * Defines the pointer angular sensibility along the X axis or how fast is
  93298. * the camera rotating.
  93299. */
  93300. angularSensibilityX: number;
  93301. /**
  93302. * Defines the pointer angular sensibility along the Y axis or how fast is
  93303. * the camera rotating.
  93304. */
  93305. angularSensibilityY: number;
  93306. /**
  93307. * Defines the pointer pinch precision or how fast is the camera zooming.
  93308. */
  93309. pinchPrecision: number;
  93310. /**
  93311. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93312. * from 0.
  93313. * It defines the percentage of current camera.radius to use as delta when
  93314. * pinch zoom is used.
  93315. */
  93316. pinchDeltaPercentage: number;
  93317. /**
  93318. * Defines the pointer panning sensibility or how fast is the camera moving.
  93319. */
  93320. panningSensibility: number;
  93321. /**
  93322. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  93323. */
  93324. multiTouchPanning: boolean;
  93325. /**
  93326. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  93327. * zoom (pinch) through multitouch.
  93328. */
  93329. multiTouchPanAndZoom: boolean;
  93330. /**
  93331. * Revers pinch action direction.
  93332. */
  93333. pinchInwards: boolean;
  93334. private _isPanClick;
  93335. private _twoFingerActivityCount;
  93336. private _isPinching;
  93337. /**
  93338. * Called on pointer POINTERMOVE event if only a single touch is active.
  93339. */
  93340. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93341. /**
  93342. * Called on pointer POINTERDOUBLETAP event.
  93343. */
  93344. protected onDoubleTap(type: string): void;
  93345. /**
  93346. * Called on pointer POINTERMOVE event if multiple touches are active.
  93347. */
  93348. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93349. /**
  93350. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93351. * press.
  93352. */
  93353. protected onButtonDown(evt: PointerEvent): void;
  93354. /**
  93355. * Called each time a new POINTERUP event occurs. Ie, for each button
  93356. * release.
  93357. */
  93358. protected onButtonUp(evt: PointerEvent): void;
  93359. /**
  93360. * Called when window becomes inactive.
  93361. */
  93362. protected onLostFocus(): void;
  93363. }
  93364. }
  93365. declare module BABYLON {
  93366. /**
  93367. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  93368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93369. */
  93370. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  93371. /**
  93372. * Defines the camera the input is attached to.
  93373. */
  93374. camera: ArcRotateCamera;
  93375. /**
  93376. * Defines the list of key codes associated with the up action (increase alpha)
  93377. */
  93378. keysUp: number[];
  93379. /**
  93380. * Defines the list of key codes associated with the down action (decrease alpha)
  93381. */
  93382. keysDown: number[];
  93383. /**
  93384. * Defines the list of key codes associated with the left action (increase beta)
  93385. */
  93386. keysLeft: number[];
  93387. /**
  93388. * Defines the list of key codes associated with the right action (decrease beta)
  93389. */
  93390. keysRight: number[];
  93391. /**
  93392. * Defines the list of key codes associated with the reset action.
  93393. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  93394. */
  93395. keysReset: number[];
  93396. /**
  93397. * Defines the panning sensibility of the inputs.
  93398. * (How fast is the camera paning)
  93399. */
  93400. panningSensibility: number;
  93401. /**
  93402. * Defines the zooming sensibility of the inputs.
  93403. * (How fast is the camera zooming)
  93404. */
  93405. zoomingSensibility: number;
  93406. /**
  93407. * Defines wether maintaining the alt key down switch the movement mode from
  93408. * orientation to zoom.
  93409. */
  93410. useAltToZoom: boolean;
  93411. /**
  93412. * Rotation speed of the camera
  93413. */
  93414. angularSpeed: number;
  93415. private _keys;
  93416. private _ctrlPressed;
  93417. private _altPressed;
  93418. private _onCanvasBlurObserver;
  93419. private _onKeyboardObserver;
  93420. private _engine;
  93421. private _scene;
  93422. /**
  93423. * Attach the input controls to a specific dom element to get the input from.
  93424. * @param element Defines the element the controls should be listened from
  93425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93426. */
  93427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93428. /**
  93429. * Detach the current controls from the specified dom element.
  93430. * @param element Defines the element to stop listening the inputs from
  93431. */
  93432. detachControl(element: Nullable<HTMLElement>): void;
  93433. /**
  93434. * Update the current camera state depending on the inputs that have been used this frame.
  93435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93436. */
  93437. checkInputs(): void;
  93438. /**
  93439. * Gets the class name of the current intput.
  93440. * @returns the class name
  93441. */
  93442. getClassName(): string;
  93443. /**
  93444. * Get the friendly name associated with the input class.
  93445. * @returns the input friendly name
  93446. */
  93447. getSimpleName(): string;
  93448. }
  93449. }
  93450. declare module BABYLON {
  93451. /**
  93452. * Manage the mouse wheel inputs to control an arc rotate camera.
  93453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93454. */
  93455. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  93456. /**
  93457. * Defines the camera the input is attached to.
  93458. */
  93459. camera: ArcRotateCamera;
  93460. /**
  93461. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93462. */
  93463. wheelPrecision: number;
  93464. /**
  93465. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93466. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93467. */
  93468. wheelDeltaPercentage: number;
  93469. private _wheel;
  93470. private _observer;
  93471. /**
  93472. * Attach the input controls to a specific dom element to get the input from.
  93473. * @param element Defines the element the controls should be listened from
  93474. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93475. */
  93476. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93477. /**
  93478. * Detach the current controls from the specified dom element.
  93479. * @param element Defines the element to stop listening the inputs from
  93480. */
  93481. detachControl(element: Nullable<HTMLElement>): void;
  93482. /**
  93483. * Gets the class name of the current intput.
  93484. * @returns the class name
  93485. */
  93486. getClassName(): string;
  93487. /**
  93488. * Get the friendly name associated with the input class.
  93489. * @returns the input friendly name
  93490. */
  93491. getSimpleName(): string;
  93492. }
  93493. }
  93494. declare module BABYLON {
  93495. /**
  93496. * Default Inputs manager for the ArcRotateCamera.
  93497. * It groups all the default supported inputs for ease of use.
  93498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93499. */
  93500. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93501. /**
  93502. * Instantiates a new ArcRotateCameraInputsManager.
  93503. * @param camera Defines the camera the inputs belong to
  93504. */
  93505. constructor(camera: ArcRotateCamera);
  93506. /**
  93507. * Add mouse wheel input support to the input manager.
  93508. * @returns the current input manager
  93509. */
  93510. addMouseWheel(): ArcRotateCameraInputsManager;
  93511. /**
  93512. * Add pointers input support to the input manager.
  93513. * @returns the current input manager
  93514. */
  93515. addPointers(): ArcRotateCameraInputsManager;
  93516. /**
  93517. * Add keyboard input support to the input manager.
  93518. * @returns the current input manager
  93519. */
  93520. addKeyboard(): ArcRotateCameraInputsManager;
  93521. }
  93522. }
  93523. declare module BABYLON {
  93524. /**
  93525. * This represents an orbital type of camera.
  93526. *
  93527. * 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.
  93528. * 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.
  93529. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93530. */
  93531. export class ArcRotateCamera extends TargetCamera {
  93532. /**
  93533. * Defines the rotation angle of the camera along the longitudinal axis.
  93534. */
  93535. alpha: number;
  93536. /**
  93537. * Defines the rotation angle of the camera along the latitudinal axis.
  93538. */
  93539. beta: number;
  93540. /**
  93541. * Defines the radius of the camera from it s target point.
  93542. */
  93543. radius: number;
  93544. protected _target: Vector3;
  93545. protected _targetHost: Nullable<AbstractMesh>;
  93546. /**
  93547. * Defines the target point of the camera.
  93548. * The camera looks towards it form the radius distance.
  93549. */
  93550. target: Vector3;
  93551. /**
  93552. * Define the current local position of the camera in the scene
  93553. */
  93554. position: Vector3;
  93555. /**
  93556. * Current inertia value on the longitudinal axis.
  93557. * The bigger this number the longer it will take for the camera to stop.
  93558. */
  93559. inertialAlphaOffset: number;
  93560. /**
  93561. * Current inertia value on the latitudinal axis.
  93562. * The bigger this number the longer it will take for the camera to stop.
  93563. */
  93564. inertialBetaOffset: number;
  93565. /**
  93566. * Current inertia value on the radius axis.
  93567. * The bigger this number the longer it will take for the camera to stop.
  93568. */
  93569. inertialRadiusOffset: number;
  93570. /**
  93571. * Minimum allowed angle on the longitudinal axis.
  93572. * This can help limiting how the Camera is able to move in the scene.
  93573. */
  93574. lowerAlphaLimit: Nullable<number>;
  93575. /**
  93576. * Maximum allowed angle on the longitudinal axis.
  93577. * This can help limiting how the Camera is able to move in the scene.
  93578. */
  93579. upperAlphaLimit: Nullable<number>;
  93580. /**
  93581. * Minimum allowed angle on the latitudinal axis.
  93582. * This can help limiting how the Camera is able to move in the scene.
  93583. */
  93584. lowerBetaLimit: number;
  93585. /**
  93586. * Maximum allowed angle on the latitudinal axis.
  93587. * This can help limiting how the Camera is able to move in the scene.
  93588. */
  93589. upperBetaLimit: number;
  93590. /**
  93591. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  93592. * This can help limiting how the Camera is able to move in the scene.
  93593. */
  93594. lowerRadiusLimit: Nullable<number>;
  93595. /**
  93596. * Maximum allowed distance of the camera to the target (The camera can not get further).
  93597. * This can help limiting how the Camera is able to move in the scene.
  93598. */
  93599. upperRadiusLimit: Nullable<number>;
  93600. /**
  93601. * Defines the current inertia value used during panning of the camera along the X axis.
  93602. */
  93603. inertialPanningX: number;
  93604. /**
  93605. * Defines the current inertia value used during panning of the camera along the Y axis.
  93606. */
  93607. inertialPanningY: number;
  93608. /**
  93609. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  93610. * Basically if your fingers moves away from more than this distance you will be considered
  93611. * in pinch mode.
  93612. */
  93613. pinchToPanMaxDistance: number;
  93614. /**
  93615. * Defines the maximum distance the camera can pan.
  93616. * This could help keeping the cammera always in your scene.
  93617. */
  93618. panningDistanceLimit: Nullable<number>;
  93619. /**
  93620. * Defines the target of the camera before paning.
  93621. */
  93622. panningOriginTarget: Vector3;
  93623. /**
  93624. * Defines the value of the inertia used during panning.
  93625. * 0 would mean stop inertia and one would mean no decelleration at all.
  93626. */
  93627. panningInertia: number;
  93628. /**
  93629. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  93630. */
  93631. angularSensibilityX: number;
  93632. /**
  93633. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  93634. */
  93635. angularSensibilityY: number;
  93636. /**
  93637. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  93638. */
  93639. pinchPrecision: number;
  93640. /**
  93641. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  93642. * It will be used instead of pinchDeltaPrecision if different from 0.
  93643. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93644. */
  93645. pinchDeltaPercentage: number;
  93646. /**
  93647. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  93648. */
  93649. panningSensibility: number;
  93650. /**
  93651. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  93652. */
  93653. keysUp: number[];
  93654. /**
  93655. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  93656. */
  93657. keysDown: number[];
  93658. /**
  93659. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  93660. */
  93661. keysLeft: number[];
  93662. /**
  93663. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  93664. */
  93665. keysRight: number[];
  93666. /**
  93667. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93668. */
  93669. wheelPrecision: number;
  93670. /**
  93671. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  93672. * It will be used instead of pinchDeltaPrecision if different from 0.
  93673. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93674. */
  93675. wheelDeltaPercentage: number;
  93676. /**
  93677. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  93678. */
  93679. zoomOnFactor: number;
  93680. /**
  93681. * Defines a screen offset for the camera position.
  93682. */
  93683. targetScreenOffset: Vector2;
  93684. /**
  93685. * Allows the camera to be completely reversed.
  93686. * If false the camera can not arrive upside down.
  93687. */
  93688. allowUpsideDown: boolean;
  93689. /**
  93690. * Define if double tap/click is used to restore the previously saved state of the camera.
  93691. */
  93692. useInputToRestoreState: boolean;
  93693. /** @hidden */
  93694. _viewMatrix: Matrix;
  93695. /** @hidden */
  93696. _useCtrlForPanning: boolean;
  93697. /** @hidden */
  93698. _panningMouseButton: number;
  93699. /**
  93700. * Defines the input associated to the camera.
  93701. */
  93702. inputs: ArcRotateCameraInputsManager;
  93703. /** @hidden */
  93704. _reset: () => void;
  93705. /**
  93706. * Defines the allowed panning axis.
  93707. */
  93708. panningAxis: Vector3;
  93709. protected _localDirection: Vector3;
  93710. protected _transformedDirection: Vector3;
  93711. private _bouncingBehavior;
  93712. /**
  93713. * Gets the bouncing behavior of the camera if it has been enabled.
  93714. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93715. */
  93716. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  93717. /**
  93718. * Defines if the bouncing behavior of the camera is enabled on the camera.
  93719. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93720. */
  93721. useBouncingBehavior: boolean;
  93722. private _framingBehavior;
  93723. /**
  93724. * Gets the framing behavior of the camera if it has been enabled.
  93725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93726. */
  93727. readonly framingBehavior: Nullable<FramingBehavior>;
  93728. /**
  93729. * Defines if the framing behavior of the camera is enabled on the camera.
  93730. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93731. */
  93732. useFramingBehavior: boolean;
  93733. private _autoRotationBehavior;
  93734. /**
  93735. * Gets the auto rotation behavior of the camera if it has been enabled.
  93736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93737. */
  93738. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  93739. /**
  93740. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  93741. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93742. */
  93743. useAutoRotationBehavior: boolean;
  93744. /**
  93745. * Observable triggered when the mesh target has been changed on the camera.
  93746. */
  93747. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  93748. /**
  93749. * Event raised when the camera is colliding with a mesh.
  93750. */
  93751. onCollide: (collidedMesh: AbstractMesh) => void;
  93752. /**
  93753. * Defines whether the camera should check collision with the objects oh the scene.
  93754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  93755. */
  93756. checkCollisions: boolean;
  93757. /**
  93758. * Defines the collision radius of the camera.
  93759. * This simulates a sphere around the camera.
  93760. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93761. */
  93762. collisionRadius: Vector3;
  93763. protected _collider: Collider;
  93764. protected _previousPosition: Vector3;
  93765. protected _collisionVelocity: Vector3;
  93766. protected _newPosition: Vector3;
  93767. protected _previousAlpha: number;
  93768. protected _previousBeta: number;
  93769. protected _previousRadius: number;
  93770. protected _collisionTriggered: boolean;
  93771. protected _targetBoundingCenter: Nullable<Vector3>;
  93772. private _computationVector;
  93773. private _tempAxisVector;
  93774. private _tempAxisRotationMatrix;
  93775. /**
  93776. * Instantiates a new ArcRotateCamera in a given scene
  93777. * @param name Defines the name of the camera
  93778. * @param alpha Defines the camera rotation along the logitudinal axis
  93779. * @param beta Defines the camera rotation along the latitudinal axis
  93780. * @param radius Defines the camera distance from its target
  93781. * @param target Defines the camera target
  93782. * @param scene Defines the scene the camera belongs to
  93783. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93784. */
  93785. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93786. /** @hidden */
  93787. _initCache(): void;
  93788. /** @hidden */
  93789. _updateCache(ignoreParentClass?: boolean): void;
  93790. protected _getTargetPosition(): Vector3;
  93791. private _storedAlpha;
  93792. private _storedBeta;
  93793. private _storedRadius;
  93794. private _storedTarget;
  93795. /**
  93796. * Stores the current state of the camera (alpha, beta, radius and target)
  93797. * @returns the camera itself
  93798. */
  93799. storeState(): Camera;
  93800. /**
  93801. * @hidden
  93802. * Restored camera state. You must call storeState() first
  93803. */
  93804. _restoreStateValues(): boolean;
  93805. /** @hidden */
  93806. _isSynchronizedViewMatrix(): boolean;
  93807. /**
  93808. * Attached controls to the current camera.
  93809. * @param element Defines the element the controls should be listened from
  93810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93811. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  93812. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  93813. */
  93814. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  93815. /**
  93816. * Detach the current controls from the camera.
  93817. * The camera will stop reacting to inputs.
  93818. * @param element Defines the element to stop listening the inputs from
  93819. */
  93820. detachControl(element: HTMLElement): void;
  93821. /** @hidden */
  93822. _checkInputs(): void;
  93823. protected _checkLimits(): void;
  93824. /**
  93825. * Rebuilds angles (alpha, beta) and radius from the give position and target
  93826. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  93827. */
  93828. rebuildAnglesAndRadius(updateView?: boolean): void;
  93829. /**
  93830. * Use a position to define the current camera related information like aplha, beta and radius
  93831. * @param position Defines the position to set the camera at
  93832. */
  93833. setPosition(position: Vector3): void;
  93834. /**
  93835. * Defines the target the camera should look at.
  93836. * This will automatically adapt alpha beta and radius to fit within the new target.
  93837. * @param target Defines the new target as a Vector or a mesh
  93838. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  93839. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  93840. */
  93841. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  93842. /** @hidden */
  93843. _getViewMatrix(): Matrix;
  93844. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  93845. /**
  93846. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  93847. * @param meshes Defines the mesh to zoom on
  93848. * @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)
  93849. */
  93850. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  93851. /**
  93852. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  93853. * The target will be changed but the radius
  93854. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  93855. * @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)
  93856. */
  93857. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  93858. min: Vector3;
  93859. max: Vector3;
  93860. distance: number;
  93861. }, doNotUpdateMaxZ?: boolean): void;
  93862. /**
  93863. * @override
  93864. * Override Camera.createRigCamera
  93865. */
  93866. createRigCamera(name: string, cameraIndex: number): Camera;
  93867. /**
  93868. * @hidden
  93869. * @override
  93870. * Override Camera._updateRigCameras
  93871. */
  93872. _updateRigCameras(): void;
  93873. /**
  93874. * Destroy the camera and release the current resources hold by it.
  93875. */
  93876. dispose(): void;
  93877. /**
  93878. * Gets the current object class name.
  93879. * @return the class name
  93880. */
  93881. getClassName(): string;
  93882. }
  93883. }
  93884. declare module BABYLON {
  93885. /**
  93886. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  93887. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93888. */
  93889. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  93890. /**
  93891. * Gets the name of the behavior.
  93892. */
  93893. readonly name: string;
  93894. private _zoomStopsAnimation;
  93895. private _idleRotationSpeed;
  93896. private _idleRotationWaitTime;
  93897. private _idleRotationSpinupTime;
  93898. /**
  93899. * Sets the flag that indicates if user zooming should stop animation.
  93900. */
  93901. /**
  93902. * Gets the flag that indicates if user zooming should stop animation.
  93903. */
  93904. zoomStopsAnimation: boolean;
  93905. /**
  93906. * Sets the default speed at which the camera rotates around the model.
  93907. */
  93908. /**
  93909. * Gets the default speed at which the camera rotates around the model.
  93910. */
  93911. idleRotationSpeed: number;
  93912. /**
  93913. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  93914. */
  93915. /**
  93916. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  93917. */
  93918. idleRotationWaitTime: number;
  93919. /**
  93920. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93921. */
  93922. /**
  93923. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93924. */
  93925. idleRotationSpinupTime: number;
  93926. /**
  93927. * Gets a value indicating if the camera is currently rotating because of this behavior
  93928. */
  93929. readonly rotationInProgress: boolean;
  93930. private _onPrePointerObservableObserver;
  93931. private _onAfterCheckInputsObserver;
  93932. private _attachedCamera;
  93933. private _isPointerDown;
  93934. private _lastFrameTime;
  93935. private _lastInteractionTime;
  93936. private _cameraRotationSpeed;
  93937. /**
  93938. * Initializes the behavior.
  93939. */
  93940. init(): void;
  93941. /**
  93942. * Attaches the behavior to its arc rotate camera.
  93943. * @param camera Defines the camera to attach the behavior to
  93944. */
  93945. attach(camera: ArcRotateCamera): void;
  93946. /**
  93947. * Detaches the behavior from its current arc rotate camera.
  93948. */
  93949. detach(): void;
  93950. /**
  93951. * Returns true if user is scrolling.
  93952. * @return true if user is scrolling.
  93953. */
  93954. private _userIsZooming;
  93955. private _lastFrameRadius;
  93956. private _shouldAnimationStopForInteraction;
  93957. /**
  93958. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93959. */
  93960. private _applyUserInteraction;
  93961. private _userIsMoving;
  93962. }
  93963. }
  93964. declare module BABYLON {
  93965. /**
  93966. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  93967. */
  93968. export class AttachToBoxBehavior implements Behavior<Mesh> {
  93969. private ui;
  93970. /**
  93971. * The name of the behavior
  93972. */
  93973. name: string;
  93974. /**
  93975. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  93976. */
  93977. distanceAwayFromFace: number;
  93978. /**
  93979. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  93980. */
  93981. distanceAwayFromBottomOfFace: number;
  93982. private _faceVectors;
  93983. private _target;
  93984. private _scene;
  93985. private _onRenderObserver;
  93986. private _tmpMatrix;
  93987. private _tmpVector;
  93988. /**
  93989. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  93990. * @param ui The transform node that should be attched to the mesh
  93991. */
  93992. constructor(ui: TransformNode);
  93993. /**
  93994. * Initializes the behavior
  93995. */
  93996. init(): void;
  93997. private _closestFace;
  93998. private _zeroVector;
  93999. private _lookAtTmpMatrix;
  94000. private _lookAtToRef;
  94001. /**
  94002. * Attaches the AttachToBoxBehavior to the passed in mesh
  94003. * @param target The mesh that the specified node will be attached to
  94004. */
  94005. attach(target: Mesh): void;
  94006. /**
  94007. * Detaches the behavior from the mesh
  94008. */
  94009. detach(): void;
  94010. }
  94011. }
  94012. declare module BABYLON {
  94013. /**
  94014. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94015. */
  94016. export class FadeInOutBehavior implements Behavior<Mesh> {
  94017. /**
  94018. * Time in milliseconds to delay before fading in (Default: 0)
  94019. */
  94020. delay: number;
  94021. /**
  94022. * Time in milliseconds for the mesh to fade in (Default: 300)
  94023. */
  94024. fadeInTime: number;
  94025. private _millisecondsPerFrame;
  94026. private _hovered;
  94027. private _hoverValue;
  94028. private _ownerNode;
  94029. /**
  94030. * Instatiates the FadeInOutBehavior
  94031. */
  94032. constructor();
  94033. /**
  94034. * The name of the behavior
  94035. */
  94036. readonly name: string;
  94037. /**
  94038. * Initializes the behavior
  94039. */
  94040. init(): void;
  94041. /**
  94042. * Attaches the fade behavior on the passed in mesh
  94043. * @param ownerNode The mesh that will be faded in/out once attached
  94044. */
  94045. attach(ownerNode: Mesh): void;
  94046. /**
  94047. * Detaches the behavior from the mesh
  94048. */
  94049. detach(): void;
  94050. /**
  94051. * Triggers the mesh to begin fading in or out
  94052. * @param value if the object should fade in or out (true to fade in)
  94053. */
  94054. fadeIn(value: boolean): void;
  94055. private _update;
  94056. private _setAllVisibility;
  94057. }
  94058. }
  94059. declare module BABYLON {
  94060. /**
  94061. * Class containing a set of static utilities functions for managing Pivots
  94062. * @hidden
  94063. */
  94064. export class PivotTools {
  94065. private static _PivotCached;
  94066. private static _OldPivotPoint;
  94067. private static _PivotTranslation;
  94068. private static _PivotTmpVector;
  94069. /** @hidden */
  94070. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94071. /** @hidden */
  94072. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94073. }
  94074. }
  94075. declare module BABYLON {
  94076. /**
  94077. * Class containing static functions to help procedurally build meshes
  94078. */
  94079. export class PlaneBuilder {
  94080. /**
  94081. * Creates a plane mesh
  94082. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94083. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94084. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94088. * @param name defines the name of the mesh
  94089. * @param options defines the options used to create the mesh
  94090. * @param scene defines the hosting scene
  94091. * @returns the plane mesh
  94092. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94093. */
  94094. static CreatePlane(name: string, options: {
  94095. size?: number;
  94096. width?: number;
  94097. height?: number;
  94098. sideOrientation?: number;
  94099. frontUVs?: Vector4;
  94100. backUVs?: Vector4;
  94101. updatable?: boolean;
  94102. sourcePlane?: Plane;
  94103. }, scene: Scene): Mesh;
  94104. }
  94105. }
  94106. declare module BABYLON {
  94107. /**
  94108. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94109. */
  94110. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94111. private static _AnyMouseID;
  94112. private _attachedNode;
  94113. private _dragPlane;
  94114. private _scene;
  94115. private _pointerObserver;
  94116. private _beforeRenderObserver;
  94117. private static _planeScene;
  94118. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94119. /**
  94120. * 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)
  94121. */
  94122. maxDragAngle: number;
  94123. /**
  94124. * @hidden
  94125. */
  94126. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94127. /**
  94128. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94129. */
  94130. currentDraggingPointerID: number;
  94131. /**
  94132. * The last position where the pointer hit the drag plane in world space
  94133. */
  94134. lastDragPosition: Vector3;
  94135. /**
  94136. * If the behavior is currently in a dragging state
  94137. */
  94138. dragging: boolean;
  94139. /**
  94140. * 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)
  94141. */
  94142. dragDeltaRatio: number;
  94143. /**
  94144. * If the drag plane orientation should be updated during the dragging (Default: true)
  94145. */
  94146. updateDragPlane: boolean;
  94147. private _debugMode;
  94148. private _moving;
  94149. /**
  94150. * Fires each time the attached mesh is dragged with the pointer
  94151. * * delta between last drag position and current drag position in world space
  94152. * * dragDistance along the drag axis
  94153. * * dragPlaneNormal normal of the current drag plane used during the drag
  94154. * * dragPlanePoint in world space where the drag intersects the drag plane
  94155. */
  94156. onDragObservable: Observable<{
  94157. delta: Vector3;
  94158. dragPlanePoint: Vector3;
  94159. dragPlaneNormal: Vector3;
  94160. dragDistance: number;
  94161. pointerId: number;
  94162. }>;
  94163. /**
  94164. * Fires each time a drag begins (eg. mouse down on mesh)
  94165. */
  94166. onDragStartObservable: Observable<{
  94167. dragPlanePoint: Vector3;
  94168. pointerId: number;
  94169. }>;
  94170. /**
  94171. * Fires each time a drag ends (eg. mouse release after drag)
  94172. */
  94173. onDragEndObservable: Observable<{
  94174. dragPlanePoint: Vector3;
  94175. pointerId: number;
  94176. }>;
  94177. /**
  94178. * If the attached mesh should be moved when dragged
  94179. */
  94180. moveAttached: boolean;
  94181. /**
  94182. * If the drag behavior will react to drag events (Default: true)
  94183. */
  94184. enabled: boolean;
  94185. /**
  94186. * If camera controls should be detached during the drag
  94187. */
  94188. detachCameraControls: boolean;
  94189. /**
  94190. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94191. */
  94192. useObjectOrienationForDragging: boolean;
  94193. private _options;
  94194. /**
  94195. * Creates a pointer drag behavior that can be attached to a mesh
  94196. * @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)
  94197. */
  94198. constructor(options?: {
  94199. dragAxis?: Vector3;
  94200. dragPlaneNormal?: Vector3;
  94201. });
  94202. /**
  94203. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94204. */
  94205. validateDrag: (targetPosition: Vector3) => boolean;
  94206. /**
  94207. * The name of the behavior
  94208. */
  94209. readonly name: string;
  94210. /**
  94211. * Initializes the behavior
  94212. */
  94213. init(): void;
  94214. private _tmpVector;
  94215. private _alternatePickedPoint;
  94216. private _worldDragAxis;
  94217. private _targetPosition;
  94218. private _attachedElement;
  94219. /**
  94220. * Attaches the drag behavior the passed in mesh
  94221. * @param ownerNode The mesh that will be dragged around once attached
  94222. */
  94223. attach(ownerNode: AbstractMesh): void;
  94224. /**
  94225. * Force relase the drag action by code.
  94226. */
  94227. releaseDrag(): void;
  94228. private _startDragRay;
  94229. private _lastPointerRay;
  94230. /**
  94231. * Simulates the start of a pointer drag event on the behavior
  94232. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94233. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94234. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94235. */
  94236. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94237. private _startDrag;
  94238. private _dragDelta;
  94239. private _moveDrag;
  94240. private _pickWithRayOnDragPlane;
  94241. private _pointA;
  94242. private _pointB;
  94243. private _pointC;
  94244. private _lineA;
  94245. private _lineB;
  94246. private _localAxis;
  94247. private _lookAt;
  94248. private _updateDragPlanePosition;
  94249. /**
  94250. * Detaches the behavior from the mesh
  94251. */
  94252. detach(): void;
  94253. }
  94254. }
  94255. declare module BABYLON {
  94256. /**
  94257. * A behavior that when attached to a mesh will allow the mesh to be scaled
  94258. */
  94259. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  94260. private _dragBehaviorA;
  94261. private _dragBehaviorB;
  94262. private _startDistance;
  94263. private _initialScale;
  94264. private _targetScale;
  94265. private _ownerNode;
  94266. private _sceneRenderObserver;
  94267. /**
  94268. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  94269. */
  94270. constructor();
  94271. /**
  94272. * The name of the behavior
  94273. */
  94274. readonly name: string;
  94275. /**
  94276. * Initializes the behavior
  94277. */
  94278. init(): void;
  94279. private _getCurrentDistance;
  94280. /**
  94281. * Attaches the scale behavior the passed in mesh
  94282. * @param ownerNode The mesh that will be scaled around once attached
  94283. */
  94284. attach(ownerNode: Mesh): void;
  94285. /**
  94286. * Detaches the behavior from the mesh
  94287. */
  94288. detach(): void;
  94289. }
  94290. }
  94291. declare module BABYLON {
  94292. /**
  94293. * 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
  94294. */
  94295. export class SixDofDragBehavior implements Behavior<Mesh> {
  94296. private static _virtualScene;
  94297. private _ownerNode;
  94298. private _sceneRenderObserver;
  94299. private _scene;
  94300. private _targetPosition;
  94301. private _virtualOriginMesh;
  94302. private _virtualDragMesh;
  94303. private _pointerObserver;
  94304. private _moving;
  94305. private _startingOrientation;
  94306. /**
  94307. * 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)
  94308. */
  94309. private zDragFactor;
  94310. /**
  94311. * If the object should rotate to face the drag origin
  94312. */
  94313. rotateDraggedObject: boolean;
  94314. /**
  94315. * If the behavior is currently in a dragging state
  94316. */
  94317. dragging: boolean;
  94318. /**
  94319. * 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)
  94320. */
  94321. dragDeltaRatio: number;
  94322. /**
  94323. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94324. */
  94325. currentDraggingPointerID: number;
  94326. /**
  94327. * If camera controls should be detached during the drag
  94328. */
  94329. detachCameraControls: boolean;
  94330. /**
  94331. * Fires each time a drag starts
  94332. */
  94333. onDragStartObservable: Observable<{}>;
  94334. /**
  94335. * Fires each time a drag ends (eg. mouse release after drag)
  94336. */
  94337. onDragEndObservable: Observable<{}>;
  94338. /**
  94339. * 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
  94340. */
  94341. constructor();
  94342. /**
  94343. * The name of the behavior
  94344. */
  94345. readonly name: string;
  94346. /**
  94347. * Initializes the behavior
  94348. */
  94349. init(): void;
  94350. /**
  94351. * Attaches the scale behavior the passed in mesh
  94352. * @param ownerNode The mesh that will be scaled around once attached
  94353. */
  94354. attach(ownerNode: Mesh): void;
  94355. /**
  94356. * Detaches the behavior from the mesh
  94357. */
  94358. detach(): void;
  94359. }
  94360. }
  94361. declare module BABYLON {
  94362. /**
  94363. * Class used to apply inverse kinematics to bones
  94364. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  94365. */
  94366. export class BoneIKController {
  94367. private static _tmpVecs;
  94368. private static _tmpQuat;
  94369. private static _tmpMats;
  94370. /**
  94371. * Gets or sets the target mesh
  94372. */
  94373. targetMesh: AbstractMesh;
  94374. /** Gets or sets the mesh used as pole */
  94375. poleTargetMesh: AbstractMesh;
  94376. /**
  94377. * Gets or sets the bone used as pole
  94378. */
  94379. poleTargetBone: Nullable<Bone>;
  94380. /**
  94381. * Gets or sets the target position
  94382. */
  94383. targetPosition: Vector3;
  94384. /**
  94385. * Gets or sets the pole target position
  94386. */
  94387. poleTargetPosition: Vector3;
  94388. /**
  94389. * Gets or sets the pole target local offset
  94390. */
  94391. poleTargetLocalOffset: Vector3;
  94392. /**
  94393. * Gets or sets the pole angle
  94394. */
  94395. poleAngle: number;
  94396. /**
  94397. * Gets or sets the mesh associated with the controller
  94398. */
  94399. mesh: AbstractMesh;
  94400. /**
  94401. * 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)
  94402. */
  94403. slerpAmount: number;
  94404. private _bone1Quat;
  94405. private _bone1Mat;
  94406. private _bone2Ang;
  94407. private _bone1;
  94408. private _bone2;
  94409. private _bone1Length;
  94410. private _bone2Length;
  94411. private _maxAngle;
  94412. private _maxReach;
  94413. private _rightHandedSystem;
  94414. private _bendAxis;
  94415. private _slerping;
  94416. private _adjustRoll;
  94417. /**
  94418. * Gets or sets maximum allowed angle
  94419. */
  94420. maxAngle: number;
  94421. /**
  94422. * Creates a new BoneIKController
  94423. * @param mesh defines the mesh to control
  94424. * @param bone defines the bone to control
  94425. * @param options defines options to set up the controller
  94426. */
  94427. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  94428. targetMesh?: AbstractMesh;
  94429. poleTargetMesh?: AbstractMesh;
  94430. poleTargetBone?: Bone;
  94431. poleTargetLocalOffset?: Vector3;
  94432. poleAngle?: number;
  94433. bendAxis?: Vector3;
  94434. maxAngle?: number;
  94435. slerpAmount?: number;
  94436. });
  94437. private _setMaxAngle;
  94438. /**
  94439. * Force the controller to update the bones
  94440. */
  94441. update(): void;
  94442. }
  94443. }
  94444. declare module BABYLON {
  94445. /**
  94446. * Class used to make a bone look toward a point in space
  94447. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  94448. */
  94449. export class BoneLookController {
  94450. private static _tmpVecs;
  94451. private static _tmpQuat;
  94452. private static _tmpMats;
  94453. /**
  94454. * The target Vector3 that the bone will look at
  94455. */
  94456. target: Vector3;
  94457. /**
  94458. * The mesh that the bone is attached to
  94459. */
  94460. mesh: AbstractMesh;
  94461. /**
  94462. * The bone that will be looking to the target
  94463. */
  94464. bone: Bone;
  94465. /**
  94466. * The up axis of the coordinate system that is used when the bone is rotated
  94467. */
  94468. upAxis: Vector3;
  94469. /**
  94470. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  94471. */
  94472. upAxisSpace: Space;
  94473. /**
  94474. * Used to make an adjustment to the yaw of the bone
  94475. */
  94476. adjustYaw: number;
  94477. /**
  94478. * Used to make an adjustment to the pitch of the bone
  94479. */
  94480. adjustPitch: number;
  94481. /**
  94482. * Used to make an adjustment to the roll of the bone
  94483. */
  94484. adjustRoll: number;
  94485. /**
  94486. * 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)
  94487. */
  94488. slerpAmount: number;
  94489. private _minYaw;
  94490. private _maxYaw;
  94491. private _minPitch;
  94492. private _maxPitch;
  94493. private _minYawSin;
  94494. private _minYawCos;
  94495. private _maxYawSin;
  94496. private _maxYawCos;
  94497. private _midYawConstraint;
  94498. private _minPitchTan;
  94499. private _maxPitchTan;
  94500. private _boneQuat;
  94501. private _slerping;
  94502. private _transformYawPitch;
  94503. private _transformYawPitchInv;
  94504. private _firstFrameSkipped;
  94505. private _yawRange;
  94506. private _fowardAxis;
  94507. /**
  94508. * Gets or sets the minimum yaw angle that the bone can look to
  94509. */
  94510. minYaw: number;
  94511. /**
  94512. * Gets or sets the maximum yaw angle that the bone can look to
  94513. */
  94514. maxYaw: number;
  94515. /**
  94516. * Gets or sets the minimum pitch angle that the bone can look to
  94517. */
  94518. minPitch: number;
  94519. /**
  94520. * Gets or sets the maximum pitch angle that the bone can look to
  94521. */
  94522. maxPitch: number;
  94523. /**
  94524. * Create a BoneLookController
  94525. * @param mesh the mesh that the bone belongs to
  94526. * @param bone the bone that will be looking to the target
  94527. * @param target the target Vector3 to look at
  94528. * @param options optional settings:
  94529. * * maxYaw: the maximum angle the bone will yaw to
  94530. * * minYaw: the minimum angle the bone will yaw to
  94531. * * maxPitch: the maximum angle the bone will pitch to
  94532. * * minPitch: the minimum angle the bone will yaw to
  94533. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94534. * * upAxis: the up axis of the coordinate system
  94535. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94536. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94537. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94538. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94539. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94540. * * adjustRoll: used to make an adjustment to the roll of the bone
  94541. **/
  94542. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94543. maxYaw?: number;
  94544. minYaw?: number;
  94545. maxPitch?: number;
  94546. minPitch?: number;
  94547. slerpAmount?: number;
  94548. upAxis?: Vector3;
  94549. upAxisSpace?: Space;
  94550. yawAxis?: Vector3;
  94551. pitchAxis?: Vector3;
  94552. adjustYaw?: number;
  94553. adjustPitch?: number;
  94554. adjustRoll?: number;
  94555. });
  94556. /**
  94557. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  94558. */
  94559. update(): void;
  94560. private _getAngleDiff;
  94561. private _getAngleBetween;
  94562. private _isAngleBetween;
  94563. }
  94564. }
  94565. declare module BABYLON {
  94566. /**
  94567. * Manage the gamepad inputs to control an arc rotate camera.
  94568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94569. */
  94570. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  94571. /**
  94572. * Defines the camera the input is attached to.
  94573. */
  94574. camera: ArcRotateCamera;
  94575. /**
  94576. * Defines the gamepad the input is gathering event from.
  94577. */
  94578. gamepad: Nullable<Gamepad>;
  94579. /**
  94580. * Defines the gamepad rotation sensiblity.
  94581. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94582. */
  94583. gamepadRotationSensibility: number;
  94584. /**
  94585. * Defines the gamepad move sensiblity.
  94586. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94587. */
  94588. gamepadMoveSensibility: number;
  94589. private _onGamepadConnectedObserver;
  94590. private _onGamepadDisconnectedObserver;
  94591. /**
  94592. * Attach the input controls to a specific dom element to get the input from.
  94593. * @param element Defines the element the controls should be listened from
  94594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94595. */
  94596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94597. /**
  94598. * Detach the current controls from the specified dom element.
  94599. * @param element Defines the element to stop listening the inputs from
  94600. */
  94601. detachControl(element: Nullable<HTMLElement>): void;
  94602. /**
  94603. * Update the current camera state depending on the inputs that have been used this frame.
  94604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94605. */
  94606. checkInputs(): void;
  94607. /**
  94608. * Gets the class name of the current intput.
  94609. * @returns the class name
  94610. */
  94611. getClassName(): string;
  94612. /**
  94613. * Get the friendly name associated with the input class.
  94614. * @returns the input friendly name
  94615. */
  94616. getSimpleName(): string;
  94617. }
  94618. }
  94619. declare module BABYLON {
  94620. interface ArcRotateCameraInputsManager {
  94621. /**
  94622. * Add orientation input support to the input manager.
  94623. * @returns the current input manager
  94624. */
  94625. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  94626. }
  94627. /**
  94628. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  94629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94630. */
  94631. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  94632. /**
  94633. * Defines the camera the input is attached to.
  94634. */
  94635. camera: ArcRotateCamera;
  94636. /**
  94637. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  94638. */
  94639. alphaCorrection: number;
  94640. /**
  94641. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  94642. */
  94643. gammaCorrection: number;
  94644. private _alpha;
  94645. private _gamma;
  94646. private _dirty;
  94647. private _deviceOrientationHandler;
  94648. /**
  94649. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  94650. */
  94651. constructor();
  94652. /**
  94653. * Attach the input controls to a specific dom element to get the input from.
  94654. * @param element Defines the element the controls should be listened from
  94655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94656. */
  94657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94658. /** @hidden */
  94659. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  94660. /**
  94661. * Update the current camera state depending on the inputs that have been used this frame.
  94662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94663. */
  94664. checkInputs(): void;
  94665. /**
  94666. * Detach the current controls from the specified dom element.
  94667. * @param element Defines the element to stop listening the inputs from
  94668. */
  94669. detachControl(element: Nullable<HTMLElement>): void;
  94670. /**
  94671. * Gets the class name of the current intput.
  94672. * @returns the class name
  94673. */
  94674. getClassName(): string;
  94675. /**
  94676. * Get the friendly name associated with the input class.
  94677. * @returns the input friendly name
  94678. */
  94679. getSimpleName(): string;
  94680. }
  94681. }
  94682. declare module BABYLON {
  94683. /**
  94684. * Listen to mouse events to control the camera.
  94685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94686. */
  94687. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  94688. /**
  94689. * Defines the camera the input is attached to.
  94690. */
  94691. camera: FlyCamera;
  94692. /**
  94693. * Defines if touch is enabled. (Default is true.)
  94694. */
  94695. touchEnabled: boolean;
  94696. /**
  94697. * Defines the buttons associated with the input to handle camera rotation.
  94698. */
  94699. buttons: number[];
  94700. /**
  94701. * Assign buttons for Yaw control.
  94702. */
  94703. buttonsYaw: number[];
  94704. /**
  94705. * Assign buttons for Pitch control.
  94706. */
  94707. buttonsPitch: number[];
  94708. /**
  94709. * Assign buttons for Roll control.
  94710. */
  94711. buttonsRoll: number[];
  94712. /**
  94713. * Detect if any button is being pressed while mouse is moved.
  94714. * -1 = Mouse locked.
  94715. * 0 = Left button.
  94716. * 1 = Middle Button.
  94717. * 2 = Right Button.
  94718. */
  94719. activeButton: number;
  94720. /**
  94721. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  94722. * Higher values reduce its sensitivity.
  94723. */
  94724. angularSensibility: number;
  94725. private _mousemoveCallback;
  94726. private _observer;
  94727. private _rollObserver;
  94728. private previousPosition;
  94729. private noPreventDefault;
  94730. private element;
  94731. /**
  94732. * Listen to mouse events to control the camera.
  94733. * @param touchEnabled Define if touch is enabled. (Default is true.)
  94734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94735. */
  94736. constructor(touchEnabled?: boolean);
  94737. /**
  94738. * Attach the mouse control to the HTML DOM element.
  94739. * @param element Defines the element that listens to the input events.
  94740. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  94741. */
  94742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94743. /**
  94744. * Detach the current controls from the specified dom element.
  94745. * @param element Defines the element to stop listening the inputs from
  94746. */
  94747. detachControl(element: Nullable<HTMLElement>): void;
  94748. /**
  94749. * Gets the class name of the current input.
  94750. * @returns the class name.
  94751. */
  94752. getClassName(): string;
  94753. /**
  94754. * Get the friendly name associated with the input class.
  94755. * @returns the input's friendly name.
  94756. */
  94757. getSimpleName(): string;
  94758. private _pointerInput;
  94759. private _onMouseMove;
  94760. /**
  94761. * Rotate camera by mouse offset.
  94762. */
  94763. private rotateCamera;
  94764. }
  94765. }
  94766. declare module BABYLON {
  94767. /**
  94768. * Default Inputs manager for the FlyCamera.
  94769. * It groups all the default supported inputs for ease of use.
  94770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94771. */
  94772. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  94773. /**
  94774. * Instantiates a new FlyCameraInputsManager.
  94775. * @param camera Defines the camera the inputs belong to.
  94776. */
  94777. constructor(camera: FlyCamera);
  94778. /**
  94779. * Add keyboard input support to the input manager.
  94780. * @returns the new FlyCameraKeyboardMoveInput().
  94781. */
  94782. addKeyboard(): FlyCameraInputsManager;
  94783. /**
  94784. * Add mouse input support to the input manager.
  94785. * @param touchEnabled Enable touch screen support.
  94786. * @returns the new FlyCameraMouseInput().
  94787. */
  94788. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  94789. }
  94790. }
  94791. declare module BABYLON {
  94792. /**
  94793. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94794. * such as in a 3D Space Shooter or a Flight Simulator.
  94795. */
  94796. export class FlyCamera extends TargetCamera {
  94797. /**
  94798. * Define the collision ellipsoid of the camera.
  94799. * This is helpful for simulating a camera body, like a player's body.
  94800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94801. */
  94802. ellipsoid: Vector3;
  94803. /**
  94804. * Define an offset for the position of the ellipsoid around the camera.
  94805. * This can be helpful if the camera is attached away from the player's body center,
  94806. * such as at its head.
  94807. */
  94808. ellipsoidOffset: Vector3;
  94809. /**
  94810. * Enable or disable collisions of the camera with the rest of the scene objects.
  94811. */
  94812. checkCollisions: boolean;
  94813. /**
  94814. * Enable or disable gravity on the camera.
  94815. */
  94816. applyGravity: boolean;
  94817. /**
  94818. * Define the current direction the camera is moving to.
  94819. */
  94820. cameraDirection: Vector3;
  94821. /**
  94822. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  94823. * This overrides and empties cameraRotation.
  94824. */
  94825. rotationQuaternion: Quaternion;
  94826. /**
  94827. * Track Roll to maintain the wanted Rolling when looking around.
  94828. */
  94829. _trackRoll: number;
  94830. /**
  94831. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  94832. */
  94833. rollCorrect: number;
  94834. /**
  94835. * Mimic a banked turn, Rolling the camera when Yawing.
  94836. * It's recommended to use rollCorrect = 10 for faster banking correction.
  94837. */
  94838. bankedTurn: boolean;
  94839. /**
  94840. * Limit in radians for how much Roll banking will add. (Default: 90°)
  94841. */
  94842. bankedTurnLimit: number;
  94843. /**
  94844. * Value of 0 disables the banked Roll.
  94845. * Value of 1 is equal to the Yaw angle in radians.
  94846. */
  94847. bankedTurnMultiplier: number;
  94848. /**
  94849. * The inputs manager loads all the input sources, such as keyboard and mouse.
  94850. */
  94851. inputs: FlyCameraInputsManager;
  94852. /**
  94853. * Gets the input sensibility for mouse input.
  94854. * Higher values reduce sensitivity.
  94855. */
  94856. /**
  94857. * Sets the input sensibility for a mouse input.
  94858. * Higher values reduce sensitivity.
  94859. */
  94860. angularSensibility: number;
  94861. /**
  94862. * Get the keys for camera movement forward.
  94863. */
  94864. /**
  94865. * Set the keys for camera movement forward.
  94866. */
  94867. keysForward: number[];
  94868. /**
  94869. * Get the keys for camera movement backward.
  94870. */
  94871. keysBackward: number[];
  94872. /**
  94873. * Get the keys for camera movement up.
  94874. */
  94875. /**
  94876. * Set the keys for camera movement up.
  94877. */
  94878. keysUp: number[];
  94879. /**
  94880. * Get the keys for camera movement down.
  94881. */
  94882. /**
  94883. * Set the keys for camera movement down.
  94884. */
  94885. keysDown: number[];
  94886. /**
  94887. * Get the keys for camera movement left.
  94888. */
  94889. /**
  94890. * Set the keys for camera movement left.
  94891. */
  94892. keysLeft: number[];
  94893. /**
  94894. * Set the keys for camera movement right.
  94895. */
  94896. /**
  94897. * Set the keys for camera movement right.
  94898. */
  94899. keysRight: number[];
  94900. /**
  94901. * Event raised when the camera collides with a mesh in the scene.
  94902. */
  94903. onCollide: (collidedMesh: AbstractMesh) => void;
  94904. private _collider;
  94905. private _needMoveForGravity;
  94906. private _oldPosition;
  94907. private _diffPosition;
  94908. private _newPosition;
  94909. /** @hidden */
  94910. _localDirection: Vector3;
  94911. /** @hidden */
  94912. _transformedDirection: Vector3;
  94913. /**
  94914. * Instantiates a FlyCamera.
  94915. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94916. * such as in a 3D Space Shooter or a Flight Simulator.
  94917. * @param name Define the name of the camera in the scene.
  94918. * @param position Define the starting position of the camera in the scene.
  94919. * @param scene Define the scene the camera belongs to.
  94920. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  94921. */
  94922. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94923. /**
  94924. * Attach a control to the HTML DOM element.
  94925. * @param element Defines the element that listens to the input events.
  94926. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  94927. */
  94928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94929. /**
  94930. * Detach a control from the HTML DOM element.
  94931. * The camera will stop reacting to that input.
  94932. * @param element Defines the element that listens to the input events.
  94933. */
  94934. detachControl(element: HTMLElement): void;
  94935. private _collisionMask;
  94936. /**
  94937. * Get the mask that the camera ignores in collision events.
  94938. */
  94939. /**
  94940. * Set the mask that the camera ignores in collision events.
  94941. */
  94942. collisionMask: number;
  94943. /** @hidden */
  94944. _collideWithWorld(displacement: Vector3): void;
  94945. /** @hidden */
  94946. private _onCollisionPositionChange;
  94947. /** @hidden */
  94948. _checkInputs(): void;
  94949. /** @hidden */
  94950. _decideIfNeedsToMove(): boolean;
  94951. /** @hidden */
  94952. _updatePosition(): void;
  94953. /**
  94954. * Restore the Roll to its target value at the rate specified.
  94955. * @param rate - Higher means slower restoring.
  94956. * @hidden
  94957. */
  94958. restoreRoll(rate: number): void;
  94959. /**
  94960. * Destroy the camera and release the current resources held by it.
  94961. */
  94962. dispose(): void;
  94963. /**
  94964. * Get the current object class name.
  94965. * @returns the class name.
  94966. */
  94967. getClassName(): string;
  94968. }
  94969. }
  94970. declare module BABYLON {
  94971. /**
  94972. * Listen to keyboard events to control the camera.
  94973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94974. */
  94975. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  94976. /**
  94977. * Defines the camera the input is attached to.
  94978. */
  94979. camera: FlyCamera;
  94980. /**
  94981. * The list of keyboard keys used to control the forward move of the camera.
  94982. */
  94983. keysForward: number[];
  94984. /**
  94985. * The list of keyboard keys used to control the backward move of the camera.
  94986. */
  94987. keysBackward: number[];
  94988. /**
  94989. * The list of keyboard keys used to control the forward move of the camera.
  94990. */
  94991. keysUp: number[];
  94992. /**
  94993. * The list of keyboard keys used to control the backward move of the camera.
  94994. */
  94995. keysDown: number[];
  94996. /**
  94997. * The list of keyboard keys used to control the right strafe move of the camera.
  94998. */
  94999. keysRight: number[];
  95000. /**
  95001. * The list of keyboard keys used to control the left strafe move of the camera.
  95002. */
  95003. keysLeft: number[];
  95004. private _keys;
  95005. private _onCanvasBlurObserver;
  95006. private _onKeyboardObserver;
  95007. private _engine;
  95008. private _scene;
  95009. /**
  95010. * Attach the input controls to a specific dom element to get the input from.
  95011. * @param element Defines the element the controls should be listened from
  95012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95013. */
  95014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95015. /**
  95016. * Detach the current controls from the specified dom element.
  95017. * @param element Defines the element to stop listening the inputs from
  95018. */
  95019. detachControl(element: Nullable<HTMLElement>): void;
  95020. /**
  95021. * Gets the class name of the current intput.
  95022. * @returns the class name
  95023. */
  95024. getClassName(): string;
  95025. /** @hidden */
  95026. _onLostFocus(e: FocusEvent): void;
  95027. /**
  95028. * Get the friendly name associated with the input class.
  95029. * @returns the input friendly name
  95030. */
  95031. getSimpleName(): string;
  95032. /**
  95033. * Update the current camera state depending on the inputs that have been used this frame.
  95034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95035. */
  95036. checkInputs(): void;
  95037. }
  95038. }
  95039. declare module BABYLON {
  95040. /**
  95041. * Manage the mouse wheel inputs to control a follow camera.
  95042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95043. */
  95044. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95045. /**
  95046. * Defines the camera the input is attached to.
  95047. */
  95048. camera: FollowCamera;
  95049. /**
  95050. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95051. */
  95052. axisControlRadius: boolean;
  95053. /**
  95054. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95055. */
  95056. axisControlHeight: boolean;
  95057. /**
  95058. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95059. */
  95060. axisControlRotation: boolean;
  95061. /**
  95062. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95063. * relation to mouseWheel events.
  95064. */
  95065. wheelPrecision: number;
  95066. /**
  95067. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95068. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95069. */
  95070. wheelDeltaPercentage: number;
  95071. private _wheel;
  95072. private _observer;
  95073. /**
  95074. * Attach the input controls to a specific dom element to get the input from.
  95075. * @param element Defines the element the controls should be listened from
  95076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95077. */
  95078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95079. /**
  95080. * Detach the current controls from the specified dom element.
  95081. * @param element Defines the element to stop listening the inputs from
  95082. */
  95083. detachControl(element: Nullable<HTMLElement>): void;
  95084. /**
  95085. * Gets the class name of the current intput.
  95086. * @returns the class name
  95087. */
  95088. getClassName(): string;
  95089. /**
  95090. * Get the friendly name associated with the input class.
  95091. * @returns the input friendly name
  95092. */
  95093. getSimpleName(): string;
  95094. }
  95095. }
  95096. declare module BABYLON {
  95097. /**
  95098. * Manage the pointers inputs to control an follow camera.
  95099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95100. */
  95101. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95102. /**
  95103. * Defines the camera the input is attached to.
  95104. */
  95105. camera: FollowCamera;
  95106. /**
  95107. * Gets the class name of the current input.
  95108. * @returns the class name
  95109. */
  95110. getClassName(): string;
  95111. /**
  95112. * Defines the pointer angular sensibility along the X axis or how fast is
  95113. * the camera rotating.
  95114. * A negative number will reverse the axis direction.
  95115. */
  95116. angularSensibilityX: number;
  95117. /**
  95118. * Defines the pointer angular sensibility along the Y axis or how fast is
  95119. * the camera rotating.
  95120. * A negative number will reverse the axis direction.
  95121. */
  95122. angularSensibilityY: number;
  95123. /**
  95124. * Defines the pointer pinch precision or how fast is the camera zooming.
  95125. * A negative number will reverse the axis direction.
  95126. */
  95127. pinchPrecision: number;
  95128. /**
  95129. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95130. * from 0.
  95131. * It defines the percentage of current camera.radius to use as delta when
  95132. * pinch zoom is used.
  95133. */
  95134. pinchDeltaPercentage: number;
  95135. /**
  95136. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95137. */
  95138. axisXControlRadius: boolean;
  95139. /**
  95140. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95141. */
  95142. axisXControlHeight: boolean;
  95143. /**
  95144. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95145. */
  95146. axisXControlRotation: boolean;
  95147. /**
  95148. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95149. */
  95150. axisYControlRadius: boolean;
  95151. /**
  95152. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95153. */
  95154. axisYControlHeight: boolean;
  95155. /**
  95156. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95157. */
  95158. axisYControlRotation: boolean;
  95159. /**
  95160. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95161. */
  95162. axisPinchControlRadius: boolean;
  95163. /**
  95164. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95165. */
  95166. axisPinchControlHeight: boolean;
  95167. /**
  95168. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95169. */
  95170. axisPinchControlRotation: boolean;
  95171. /**
  95172. * Log error messages if basic misconfiguration has occurred.
  95173. */
  95174. warningEnable: boolean;
  95175. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95176. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95177. private _warningCounter;
  95178. private _warning;
  95179. }
  95180. }
  95181. declare module BABYLON {
  95182. /**
  95183. * Default Inputs manager for the FollowCamera.
  95184. * It groups all the default supported inputs for ease of use.
  95185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95186. */
  95187. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95188. /**
  95189. * Instantiates a new FollowCameraInputsManager.
  95190. * @param camera Defines the camera the inputs belong to
  95191. */
  95192. constructor(camera: FollowCamera);
  95193. /**
  95194. * Add keyboard input support to the input manager.
  95195. * @returns the current input manager
  95196. */
  95197. addKeyboard(): FollowCameraInputsManager;
  95198. /**
  95199. * Add mouse wheel input support to the input manager.
  95200. * @returns the current input manager
  95201. */
  95202. addMouseWheel(): FollowCameraInputsManager;
  95203. /**
  95204. * Add pointers input support to the input manager.
  95205. * @returns the current input manager
  95206. */
  95207. addPointers(): FollowCameraInputsManager;
  95208. /**
  95209. * Add orientation input support to the input manager.
  95210. * @returns the current input manager
  95211. */
  95212. addVRDeviceOrientation(): FollowCameraInputsManager;
  95213. }
  95214. }
  95215. declare module BABYLON {
  95216. /**
  95217. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95218. * an arc rotate version arcFollowCamera are available.
  95219. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95220. */
  95221. export class FollowCamera extends TargetCamera {
  95222. /**
  95223. * Distance the follow camera should follow an object at
  95224. */
  95225. radius: number;
  95226. /**
  95227. * Minimum allowed distance of the camera to the axis of rotation
  95228. * (The camera can not get closer).
  95229. * This can help limiting how the Camera is able to move in the scene.
  95230. */
  95231. lowerRadiusLimit: Nullable<number>;
  95232. /**
  95233. * Maximum allowed distance of the camera to the axis of rotation
  95234. * (The camera can not get further).
  95235. * This can help limiting how the Camera is able to move in the scene.
  95236. */
  95237. upperRadiusLimit: Nullable<number>;
  95238. /**
  95239. * Define a rotation offset between the camera and the object it follows
  95240. */
  95241. rotationOffset: number;
  95242. /**
  95243. * Minimum allowed angle to camera position relative to target object.
  95244. * This can help limiting how the Camera is able to move in the scene.
  95245. */
  95246. lowerRotationOffsetLimit: Nullable<number>;
  95247. /**
  95248. * Maximum allowed angle to camera position relative to target object.
  95249. * This can help limiting how the Camera is able to move in the scene.
  95250. */
  95251. upperRotationOffsetLimit: Nullable<number>;
  95252. /**
  95253. * Define a height offset between the camera and the object it follows.
  95254. * It can help following an object from the top (like a car chaing a plane)
  95255. */
  95256. heightOffset: number;
  95257. /**
  95258. * Minimum allowed height of camera position relative to target object.
  95259. * This can help limiting how the Camera is able to move in the scene.
  95260. */
  95261. lowerHeightOffsetLimit: Nullable<number>;
  95262. /**
  95263. * Maximum allowed height of camera position relative to target object.
  95264. * This can help limiting how the Camera is able to move in the scene.
  95265. */
  95266. upperHeightOffsetLimit: Nullable<number>;
  95267. /**
  95268. * Define how fast the camera can accelerate to follow it s target.
  95269. */
  95270. cameraAcceleration: number;
  95271. /**
  95272. * Define the speed limit of the camera following an object.
  95273. */
  95274. maxCameraSpeed: number;
  95275. /**
  95276. * Define the target of the camera.
  95277. */
  95278. lockedTarget: Nullable<AbstractMesh>;
  95279. /**
  95280. * Defines the input associated with the camera.
  95281. */
  95282. inputs: FollowCameraInputsManager;
  95283. /**
  95284. * Instantiates the follow camera.
  95285. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95286. * @param name Define the name of the camera in the scene
  95287. * @param position Define the position of the camera
  95288. * @param scene Define the scene the camera belong to
  95289. * @param lockedTarget Define the target of the camera
  95290. */
  95291. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  95292. private _follow;
  95293. /**
  95294. * Attached controls to the current camera.
  95295. * @param element Defines the element the controls should be listened from
  95296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95297. */
  95298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95299. /**
  95300. * Detach the current controls from the camera.
  95301. * The camera will stop reacting to inputs.
  95302. * @param element Defines the element to stop listening the inputs from
  95303. */
  95304. detachControl(element: HTMLElement): void;
  95305. /** @hidden */
  95306. _checkInputs(): void;
  95307. private _checkLimits;
  95308. /**
  95309. * Gets the camera class name.
  95310. * @returns the class name
  95311. */
  95312. getClassName(): string;
  95313. }
  95314. /**
  95315. * Arc Rotate version of the follow camera.
  95316. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  95317. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95318. */
  95319. export class ArcFollowCamera extends TargetCamera {
  95320. /** The longitudinal angle of the camera */
  95321. alpha: number;
  95322. /** The latitudinal angle of the camera */
  95323. beta: number;
  95324. /** The radius of the camera from its target */
  95325. radius: number;
  95326. /** Define the camera target (the messh it should follow) */
  95327. target: Nullable<AbstractMesh>;
  95328. private _cartesianCoordinates;
  95329. /**
  95330. * Instantiates a new ArcFollowCamera
  95331. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95332. * @param name Define the name of the camera
  95333. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  95334. * @param beta Define the rotation angle of the camera around the elevation axis
  95335. * @param radius Define the radius of the camera from its target point
  95336. * @param target Define the target of the camera
  95337. * @param scene Define the scene the camera belongs to
  95338. */
  95339. constructor(name: string,
  95340. /** The longitudinal angle of the camera */
  95341. alpha: number,
  95342. /** The latitudinal angle of the camera */
  95343. beta: number,
  95344. /** The radius of the camera from its target */
  95345. radius: number,
  95346. /** Define the camera target (the messh it should follow) */
  95347. target: Nullable<AbstractMesh>, scene: Scene);
  95348. private _follow;
  95349. /** @hidden */
  95350. _checkInputs(): void;
  95351. /**
  95352. * Returns the class name of the object.
  95353. * It is mostly used internally for serialization purposes.
  95354. */
  95355. getClassName(): string;
  95356. }
  95357. }
  95358. declare module BABYLON {
  95359. /**
  95360. * Manage the keyboard inputs to control the movement of a follow camera.
  95361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95362. */
  95363. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  95364. /**
  95365. * Defines the camera the input is attached to.
  95366. */
  95367. camera: FollowCamera;
  95368. /**
  95369. * Defines the list of key codes associated with the up action (increase heightOffset)
  95370. */
  95371. keysHeightOffsetIncr: number[];
  95372. /**
  95373. * Defines the list of key codes associated with the down action (decrease heightOffset)
  95374. */
  95375. keysHeightOffsetDecr: number[];
  95376. /**
  95377. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  95378. */
  95379. keysHeightOffsetModifierAlt: boolean;
  95380. /**
  95381. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  95382. */
  95383. keysHeightOffsetModifierCtrl: boolean;
  95384. /**
  95385. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  95386. */
  95387. keysHeightOffsetModifierShift: boolean;
  95388. /**
  95389. * Defines the list of key codes associated with the left action (increase rotationOffset)
  95390. */
  95391. keysRotationOffsetIncr: number[];
  95392. /**
  95393. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  95394. */
  95395. keysRotationOffsetDecr: number[];
  95396. /**
  95397. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  95398. */
  95399. keysRotationOffsetModifierAlt: boolean;
  95400. /**
  95401. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  95402. */
  95403. keysRotationOffsetModifierCtrl: boolean;
  95404. /**
  95405. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  95406. */
  95407. keysRotationOffsetModifierShift: boolean;
  95408. /**
  95409. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  95410. */
  95411. keysRadiusIncr: number[];
  95412. /**
  95413. * Defines the list of key codes associated with the zoom-out action (increase radius)
  95414. */
  95415. keysRadiusDecr: number[];
  95416. /**
  95417. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  95418. */
  95419. keysRadiusModifierAlt: boolean;
  95420. /**
  95421. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  95422. */
  95423. keysRadiusModifierCtrl: boolean;
  95424. /**
  95425. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  95426. */
  95427. keysRadiusModifierShift: boolean;
  95428. /**
  95429. * Defines the rate of change of heightOffset.
  95430. */
  95431. heightSensibility: number;
  95432. /**
  95433. * Defines the rate of change of rotationOffset.
  95434. */
  95435. rotationSensibility: number;
  95436. /**
  95437. * Defines the rate of change of radius.
  95438. */
  95439. radiusSensibility: number;
  95440. private _keys;
  95441. private _ctrlPressed;
  95442. private _altPressed;
  95443. private _shiftPressed;
  95444. private _onCanvasBlurObserver;
  95445. private _onKeyboardObserver;
  95446. private _engine;
  95447. private _scene;
  95448. /**
  95449. * Attach the input controls to a specific dom element to get the input from.
  95450. * @param element Defines the element the controls should be listened from
  95451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95452. */
  95453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95454. /**
  95455. * Detach the current controls from the specified dom element.
  95456. * @param element Defines the element to stop listening the inputs from
  95457. */
  95458. detachControl(element: Nullable<HTMLElement>): void;
  95459. /**
  95460. * Update the current camera state depending on the inputs that have been used this frame.
  95461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95462. */
  95463. checkInputs(): void;
  95464. /**
  95465. * Gets the class name of the current input.
  95466. * @returns the class name
  95467. */
  95468. getClassName(): string;
  95469. /**
  95470. * Get the friendly name associated with the input class.
  95471. * @returns the input friendly name
  95472. */
  95473. getSimpleName(): string;
  95474. /**
  95475. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95476. * allow modification of the heightOffset value.
  95477. */
  95478. private _modifierHeightOffset;
  95479. /**
  95480. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95481. * allow modification of the rotationOffset value.
  95482. */
  95483. private _modifierRotationOffset;
  95484. /**
  95485. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95486. * allow modification of the radius value.
  95487. */
  95488. private _modifierRadius;
  95489. }
  95490. }
  95491. declare module BABYLON {
  95492. interface FreeCameraInputsManager {
  95493. /**
  95494. * Add orientation input support to the input manager.
  95495. * @returns the current input manager
  95496. */
  95497. addDeviceOrientation(): FreeCameraInputsManager;
  95498. }
  95499. /**
  95500. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95501. * Screen rotation is taken into account.
  95502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95503. */
  95504. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95505. private _camera;
  95506. private _screenOrientationAngle;
  95507. private _constantTranform;
  95508. private _screenQuaternion;
  95509. private _alpha;
  95510. private _beta;
  95511. private _gamma;
  95512. /**
  95513. * Instantiates a new input
  95514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95515. */
  95516. constructor();
  95517. /**
  95518. * Define the camera controlled by the input.
  95519. */
  95520. camera: FreeCamera;
  95521. /**
  95522. * Attach the input controls to a specific dom element to get the input from.
  95523. * @param element Defines the element the controls should be listened from
  95524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95525. */
  95526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95527. private _orientationChanged;
  95528. private _deviceOrientation;
  95529. /**
  95530. * Detach the current controls from the specified dom element.
  95531. * @param element Defines the element to stop listening the inputs from
  95532. */
  95533. detachControl(element: Nullable<HTMLElement>): void;
  95534. /**
  95535. * Update the current camera state depending on the inputs that have been used this frame.
  95536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95537. */
  95538. checkInputs(): void;
  95539. /**
  95540. * Gets the class name of the current intput.
  95541. * @returns the class name
  95542. */
  95543. getClassName(): string;
  95544. /**
  95545. * Get the friendly name associated with the input class.
  95546. * @returns the input friendly name
  95547. */
  95548. getSimpleName(): string;
  95549. }
  95550. }
  95551. declare module BABYLON {
  95552. /**
  95553. * Manage the gamepad inputs to control a free camera.
  95554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95555. */
  95556. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  95557. /**
  95558. * Define the camera the input is attached to.
  95559. */
  95560. camera: FreeCamera;
  95561. /**
  95562. * Define the Gamepad controlling the input
  95563. */
  95564. gamepad: Nullable<Gamepad>;
  95565. /**
  95566. * Defines the gamepad rotation sensiblity.
  95567. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95568. */
  95569. gamepadAngularSensibility: number;
  95570. /**
  95571. * Defines the gamepad move sensiblity.
  95572. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95573. */
  95574. gamepadMoveSensibility: number;
  95575. private _onGamepadConnectedObserver;
  95576. private _onGamepadDisconnectedObserver;
  95577. private _cameraTransform;
  95578. private _deltaTransform;
  95579. private _vector3;
  95580. private _vector2;
  95581. /**
  95582. * Attach the input controls to a specific dom element to get the input from.
  95583. * @param element Defines the element the controls should be listened from
  95584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95585. */
  95586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95587. /**
  95588. * Detach the current controls from the specified dom element.
  95589. * @param element Defines the element to stop listening the inputs from
  95590. */
  95591. detachControl(element: Nullable<HTMLElement>): void;
  95592. /**
  95593. * Update the current camera state depending on the inputs that have been used this frame.
  95594. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95595. */
  95596. checkInputs(): void;
  95597. /**
  95598. * Gets the class name of the current intput.
  95599. * @returns the class name
  95600. */
  95601. getClassName(): string;
  95602. /**
  95603. * Get the friendly name associated with the input class.
  95604. * @returns the input friendly name
  95605. */
  95606. getSimpleName(): string;
  95607. }
  95608. }
  95609. declare module BABYLON {
  95610. /**
  95611. * Defines the potential axis of a Joystick
  95612. */
  95613. export enum JoystickAxis {
  95614. /** X axis */
  95615. X = 0,
  95616. /** Y axis */
  95617. Y = 1,
  95618. /** Z axis */
  95619. Z = 2
  95620. }
  95621. /**
  95622. * Class used to define virtual joystick (used in touch mode)
  95623. */
  95624. export class VirtualJoystick {
  95625. /**
  95626. * Gets or sets a boolean indicating that left and right values must be inverted
  95627. */
  95628. reverseLeftRight: boolean;
  95629. /**
  95630. * Gets or sets a boolean indicating that up and down values must be inverted
  95631. */
  95632. reverseUpDown: boolean;
  95633. /**
  95634. * Gets the offset value for the position (ie. the change of the position value)
  95635. */
  95636. deltaPosition: Vector3;
  95637. /**
  95638. * Gets a boolean indicating if the virtual joystick was pressed
  95639. */
  95640. pressed: boolean;
  95641. /**
  95642. * Canvas the virtual joystick will render onto, default z-index of this is 5
  95643. */
  95644. static Canvas: Nullable<HTMLCanvasElement>;
  95645. private static _globalJoystickIndex;
  95646. private static vjCanvasContext;
  95647. private static vjCanvasWidth;
  95648. private static vjCanvasHeight;
  95649. private static halfWidth;
  95650. private _action;
  95651. private _axisTargetedByLeftAndRight;
  95652. private _axisTargetedByUpAndDown;
  95653. private _joystickSensibility;
  95654. private _inversedSensibility;
  95655. private _joystickPointerID;
  95656. private _joystickColor;
  95657. private _joystickPointerPos;
  95658. private _joystickPreviousPointerPos;
  95659. private _joystickPointerStartPos;
  95660. private _deltaJoystickVector;
  95661. private _leftJoystick;
  95662. private _touches;
  95663. private _onPointerDownHandlerRef;
  95664. private _onPointerMoveHandlerRef;
  95665. private _onPointerUpHandlerRef;
  95666. private _onResize;
  95667. /**
  95668. * Creates a new virtual joystick
  95669. * @param leftJoystick defines that the joystick is for left hand (false by default)
  95670. */
  95671. constructor(leftJoystick?: boolean);
  95672. /**
  95673. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  95674. * @param newJoystickSensibility defines the new sensibility
  95675. */
  95676. setJoystickSensibility(newJoystickSensibility: number): void;
  95677. private _onPointerDown;
  95678. private _onPointerMove;
  95679. private _onPointerUp;
  95680. /**
  95681. * Change the color of the virtual joystick
  95682. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  95683. */
  95684. setJoystickColor(newColor: string): void;
  95685. /**
  95686. * Defines a callback to call when the joystick is touched
  95687. * @param action defines the callback
  95688. */
  95689. setActionOnTouch(action: () => any): void;
  95690. /**
  95691. * Defines which axis you'd like to control for left & right
  95692. * @param axis defines the axis to use
  95693. */
  95694. setAxisForLeftRight(axis: JoystickAxis): void;
  95695. /**
  95696. * Defines which axis you'd like to control for up & down
  95697. * @param axis defines the axis to use
  95698. */
  95699. setAxisForUpDown(axis: JoystickAxis): void;
  95700. private _drawVirtualJoystick;
  95701. /**
  95702. * Release internal HTML canvas
  95703. */
  95704. releaseCanvas(): void;
  95705. }
  95706. }
  95707. declare module BABYLON {
  95708. interface FreeCameraInputsManager {
  95709. /**
  95710. * Add virtual joystick input support to the input manager.
  95711. * @returns the current input manager
  95712. */
  95713. addVirtualJoystick(): FreeCameraInputsManager;
  95714. }
  95715. /**
  95716. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  95717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95718. */
  95719. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  95720. /**
  95721. * Defines the camera the input is attached to.
  95722. */
  95723. camera: FreeCamera;
  95724. private _leftjoystick;
  95725. private _rightjoystick;
  95726. /**
  95727. * Gets the left stick of the virtual joystick.
  95728. * @returns The virtual Joystick
  95729. */
  95730. getLeftJoystick(): VirtualJoystick;
  95731. /**
  95732. * Gets the right stick of the virtual joystick.
  95733. * @returns The virtual Joystick
  95734. */
  95735. getRightJoystick(): VirtualJoystick;
  95736. /**
  95737. * Update the current camera state depending on the inputs that have been used this frame.
  95738. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95739. */
  95740. checkInputs(): void;
  95741. /**
  95742. * Attach the input controls to a specific dom element to get the input from.
  95743. * @param element Defines the element the controls should be listened from
  95744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95745. */
  95746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95747. /**
  95748. * Detach the current controls from the specified dom element.
  95749. * @param element Defines the element to stop listening the inputs from
  95750. */
  95751. detachControl(element: Nullable<HTMLElement>): void;
  95752. /**
  95753. * Gets the class name of the current intput.
  95754. * @returns the class name
  95755. */
  95756. getClassName(): string;
  95757. /**
  95758. * Get the friendly name associated with the input class.
  95759. * @returns the input friendly name
  95760. */
  95761. getSimpleName(): string;
  95762. }
  95763. }
  95764. declare module BABYLON {
  95765. /**
  95766. * This represents a FPS type of camera controlled by touch.
  95767. * This is like a universal camera minus the Gamepad controls.
  95768. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95769. */
  95770. export class TouchCamera extends FreeCamera {
  95771. /**
  95772. * Defines the touch sensibility for rotation.
  95773. * The higher the faster.
  95774. */
  95775. touchAngularSensibility: number;
  95776. /**
  95777. * Defines the touch sensibility for move.
  95778. * The higher the faster.
  95779. */
  95780. touchMoveSensibility: number;
  95781. /**
  95782. * Instantiates a new touch camera.
  95783. * This represents a FPS type of camera controlled by touch.
  95784. * This is like a universal camera minus the Gamepad controls.
  95785. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95786. * @param name Define the name of the camera in the scene
  95787. * @param position Define the start position of the camera in the scene
  95788. * @param scene Define the scene the camera belongs to
  95789. */
  95790. constructor(name: string, position: Vector3, scene: Scene);
  95791. /**
  95792. * Gets the current object class name.
  95793. * @return the class name
  95794. */
  95795. getClassName(): string;
  95796. /** @hidden */
  95797. _setupInputs(): void;
  95798. }
  95799. }
  95800. declare module BABYLON {
  95801. /**
  95802. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  95803. * being tilted forward or back and left or right.
  95804. */
  95805. export class DeviceOrientationCamera extends FreeCamera {
  95806. private _initialQuaternion;
  95807. private _quaternionCache;
  95808. /**
  95809. * Creates a new device orientation camera
  95810. * @param name The name of the camera
  95811. * @param position The start position camera
  95812. * @param scene The scene the camera belongs to
  95813. */
  95814. constructor(name: string, position: Vector3, scene: Scene);
  95815. /**
  95816. * Gets the current instance class name ("DeviceOrientationCamera").
  95817. * This helps avoiding instanceof at run time.
  95818. * @returns the class name
  95819. */
  95820. getClassName(): string;
  95821. /**
  95822. * @hidden
  95823. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  95824. */
  95825. _checkInputs(): void;
  95826. /**
  95827. * Reset the camera to its default orientation on the specified axis only.
  95828. * @param axis The axis to reset
  95829. */
  95830. resetToCurrentRotation(axis?: Axis): void;
  95831. }
  95832. }
  95833. declare module BABYLON {
  95834. /**
  95835. * 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,
  95836. * which still works and will still be found in many Playgrounds.
  95837. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95838. */
  95839. export class UniversalCamera extends TouchCamera {
  95840. /**
  95841. * Defines the gamepad rotation sensiblity.
  95842. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95843. */
  95844. gamepadAngularSensibility: number;
  95845. /**
  95846. * Defines the gamepad move sensiblity.
  95847. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95848. */
  95849. gamepadMoveSensibility: number;
  95850. /**
  95851. * 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,
  95852. * which still works and will still be found in many Playgrounds.
  95853. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95854. * @param name Define the name of the camera in the scene
  95855. * @param position Define the start position of the camera in the scene
  95856. * @param scene Define the scene the camera belongs to
  95857. */
  95858. constructor(name: string, position: Vector3, scene: Scene);
  95859. /**
  95860. * Gets the current object class name.
  95861. * @return the class name
  95862. */
  95863. getClassName(): string;
  95864. }
  95865. }
  95866. declare module BABYLON {
  95867. /**
  95868. * This represents a FPS type of camera. This is only here for back compat purpose.
  95869. * Please use the UniversalCamera instead as both are identical.
  95870. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95871. */
  95872. export class GamepadCamera extends UniversalCamera {
  95873. /**
  95874. * Instantiates a new Gamepad Camera
  95875. * This represents a FPS type of camera. This is only here for back compat purpose.
  95876. * Please use the UniversalCamera instead as both are identical.
  95877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95878. * @param name Define the name of the camera in the scene
  95879. * @param position Define the start position of the camera in the scene
  95880. * @param scene Define the scene the camera belongs to
  95881. */
  95882. constructor(name: string, position: Vector3, scene: Scene);
  95883. /**
  95884. * Gets the current object class name.
  95885. * @return the class name
  95886. */
  95887. getClassName(): string;
  95888. }
  95889. }
  95890. declare module BABYLON {
  95891. /** @hidden */
  95892. export var passPixelShader: {
  95893. name: string;
  95894. shader: string;
  95895. };
  95896. }
  95897. declare module BABYLON {
  95898. /** @hidden */
  95899. export var passCubePixelShader: {
  95900. name: string;
  95901. shader: string;
  95902. };
  95903. }
  95904. declare module BABYLON {
  95905. /**
  95906. * PassPostProcess which produces an output the same as it's input
  95907. */
  95908. export class PassPostProcess extends PostProcess {
  95909. /**
  95910. * Creates the PassPostProcess
  95911. * @param name The name of the effect.
  95912. * @param options The required width/height ratio to downsize to before computing the render pass.
  95913. * @param camera The camera to apply the render pass to.
  95914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95915. * @param engine The engine which the post process will be applied. (default: current engine)
  95916. * @param reusable If the post process can be reused on the same frame. (default: false)
  95917. * @param textureType The type of texture to be used when performing the post processing.
  95918. * @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)
  95919. */
  95920. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95921. }
  95922. /**
  95923. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  95924. */
  95925. export class PassCubePostProcess extends PostProcess {
  95926. private _face;
  95927. /**
  95928. * Gets or sets the cube face to display.
  95929. * * 0 is +X
  95930. * * 1 is -X
  95931. * * 2 is +Y
  95932. * * 3 is -Y
  95933. * * 4 is +Z
  95934. * * 5 is -Z
  95935. */
  95936. face: number;
  95937. /**
  95938. * Creates the PassCubePostProcess
  95939. * @param name The name of the effect.
  95940. * @param options The required width/height ratio to downsize to before computing the render pass.
  95941. * @param camera The camera to apply the render pass to.
  95942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95943. * @param engine The engine which the post process will be applied. (default: current engine)
  95944. * @param reusable If the post process can be reused on the same frame. (default: false)
  95945. * @param textureType The type of texture to be used when performing the post processing.
  95946. * @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)
  95947. */
  95948. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95949. }
  95950. }
  95951. declare module BABYLON {
  95952. /** @hidden */
  95953. export var anaglyphPixelShader: {
  95954. name: string;
  95955. shader: string;
  95956. };
  95957. }
  95958. declare module BABYLON {
  95959. /**
  95960. * Postprocess used to generate anaglyphic rendering
  95961. */
  95962. export class AnaglyphPostProcess extends PostProcess {
  95963. private _passedProcess;
  95964. /**
  95965. * Creates a new AnaglyphPostProcess
  95966. * @param name defines postprocess name
  95967. * @param options defines creation options or target ratio scale
  95968. * @param rigCameras defines cameras using this postprocess
  95969. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  95970. * @param engine defines hosting engine
  95971. * @param reusable defines if the postprocess will be reused multiple times per frame
  95972. */
  95973. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  95974. }
  95975. }
  95976. declare module BABYLON {
  95977. /**
  95978. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  95979. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95980. */
  95981. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  95982. /**
  95983. * Creates a new AnaglyphArcRotateCamera
  95984. * @param name defines camera name
  95985. * @param alpha defines alpha angle (in radians)
  95986. * @param beta defines beta angle (in radians)
  95987. * @param radius defines radius
  95988. * @param target defines camera target
  95989. * @param interaxialDistance defines distance between each color axis
  95990. * @param scene defines the hosting scene
  95991. */
  95992. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  95993. /**
  95994. * Gets camera class name
  95995. * @returns AnaglyphArcRotateCamera
  95996. */
  95997. getClassName(): string;
  95998. }
  95999. }
  96000. declare module BABYLON {
  96001. /**
  96002. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96003. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96004. */
  96005. export class AnaglyphFreeCamera extends FreeCamera {
  96006. /**
  96007. * Creates a new AnaglyphFreeCamera
  96008. * @param name defines camera name
  96009. * @param position defines initial position
  96010. * @param interaxialDistance defines distance between each color axis
  96011. * @param scene defines the hosting scene
  96012. */
  96013. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96014. /**
  96015. * Gets camera class name
  96016. * @returns AnaglyphFreeCamera
  96017. */
  96018. getClassName(): string;
  96019. }
  96020. }
  96021. declare module BABYLON {
  96022. /**
  96023. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96024. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96025. */
  96026. export class AnaglyphGamepadCamera extends GamepadCamera {
  96027. /**
  96028. * Creates a new AnaglyphGamepadCamera
  96029. * @param name defines camera name
  96030. * @param position defines initial position
  96031. * @param interaxialDistance defines distance between each color axis
  96032. * @param scene defines the hosting scene
  96033. */
  96034. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96035. /**
  96036. * Gets camera class name
  96037. * @returns AnaglyphGamepadCamera
  96038. */
  96039. getClassName(): string;
  96040. }
  96041. }
  96042. declare module BABYLON {
  96043. /**
  96044. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96045. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96046. */
  96047. export class AnaglyphUniversalCamera extends UniversalCamera {
  96048. /**
  96049. * Creates a new AnaglyphUniversalCamera
  96050. * @param name defines camera name
  96051. * @param position defines initial position
  96052. * @param interaxialDistance defines distance between each color axis
  96053. * @param scene defines the hosting scene
  96054. */
  96055. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96056. /**
  96057. * Gets camera class name
  96058. * @returns AnaglyphUniversalCamera
  96059. */
  96060. getClassName(): string;
  96061. }
  96062. }
  96063. declare module BABYLON {
  96064. /** @hidden */
  96065. export var stereoscopicInterlacePixelShader: {
  96066. name: string;
  96067. shader: string;
  96068. };
  96069. }
  96070. declare module BABYLON {
  96071. /**
  96072. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96073. */
  96074. export class StereoscopicInterlacePostProcess extends PostProcess {
  96075. private _stepSize;
  96076. private _passedProcess;
  96077. /**
  96078. * Initializes a StereoscopicInterlacePostProcess
  96079. * @param name The name of the effect.
  96080. * @param rigCameras The rig cameras to be appled to the post process
  96081. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96083. * @param engine The engine which the post process will be applied. (default: current engine)
  96084. * @param reusable If the post process can be reused on the same frame. (default: false)
  96085. */
  96086. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96087. }
  96088. }
  96089. declare module BABYLON {
  96090. /**
  96091. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96092. * @see http://doc.babylonjs.com/features/cameras
  96093. */
  96094. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96095. /**
  96096. * Creates a new StereoscopicArcRotateCamera
  96097. * @param name defines camera name
  96098. * @param alpha defines alpha angle (in radians)
  96099. * @param beta defines beta angle (in radians)
  96100. * @param radius defines radius
  96101. * @param target defines camera target
  96102. * @param interaxialDistance defines distance between each color axis
  96103. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96104. * @param scene defines the hosting scene
  96105. */
  96106. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96107. /**
  96108. * Gets camera class name
  96109. * @returns StereoscopicArcRotateCamera
  96110. */
  96111. getClassName(): string;
  96112. }
  96113. }
  96114. declare module BABYLON {
  96115. /**
  96116. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96117. * @see http://doc.babylonjs.com/features/cameras
  96118. */
  96119. export class StereoscopicFreeCamera extends FreeCamera {
  96120. /**
  96121. * Creates a new StereoscopicFreeCamera
  96122. * @param name defines camera name
  96123. * @param position defines initial position
  96124. * @param interaxialDistance defines distance between each color axis
  96125. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96126. * @param scene defines the hosting scene
  96127. */
  96128. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96129. /**
  96130. * Gets camera class name
  96131. * @returns StereoscopicFreeCamera
  96132. */
  96133. getClassName(): string;
  96134. }
  96135. }
  96136. declare module BABYLON {
  96137. /**
  96138. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96139. * @see http://doc.babylonjs.com/features/cameras
  96140. */
  96141. export class StereoscopicGamepadCamera extends GamepadCamera {
  96142. /**
  96143. * Creates a new StereoscopicGamepadCamera
  96144. * @param name defines camera name
  96145. * @param position defines initial position
  96146. * @param interaxialDistance defines distance between each color axis
  96147. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96148. * @param scene defines the hosting scene
  96149. */
  96150. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96151. /**
  96152. * Gets camera class name
  96153. * @returns StereoscopicGamepadCamera
  96154. */
  96155. getClassName(): string;
  96156. }
  96157. }
  96158. declare module BABYLON {
  96159. /**
  96160. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96161. * @see http://doc.babylonjs.com/features/cameras
  96162. */
  96163. export class StereoscopicUniversalCamera extends UniversalCamera {
  96164. /**
  96165. * Creates a new StereoscopicUniversalCamera
  96166. * @param name defines camera name
  96167. * @param position defines initial position
  96168. * @param interaxialDistance defines distance between each color axis
  96169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96170. * @param scene defines the hosting scene
  96171. */
  96172. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96173. /**
  96174. * Gets camera class name
  96175. * @returns StereoscopicUniversalCamera
  96176. */
  96177. getClassName(): string;
  96178. }
  96179. }
  96180. declare module BABYLON {
  96181. /**
  96182. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96183. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96184. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96185. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96186. */
  96187. export class VirtualJoysticksCamera extends FreeCamera {
  96188. /**
  96189. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96190. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96191. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96192. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96193. * @param name Define the name of the camera in the scene
  96194. * @param position Define the start position of the camera in the scene
  96195. * @param scene Define the scene the camera belongs to
  96196. */
  96197. constructor(name: string, position: Vector3, scene: Scene);
  96198. /**
  96199. * Gets the current object class name.
  96200. * @return the class name
  96201. */
  96202. getClassName(): string;
  96203. }
  96204. }
  96205. declare module BABYLON {
  96206. /**
  96207. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  96208. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96209. */
  96210. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  96211. /**
  96212. * Creates a new VRDeviceOrientationArcRotateCamera
  96213. * @param name defines camera name
  96214. * @param alpha defines the camera rotation along the logitudinal axis
  96215. * @param beta defines the camera rotation along the latitudinal axis
  96216. * @param radius defines the camera distance from its target
  96217. * @param target defines the camera target
  96218. * @param scene defines the scene the camera belongs to
  96219. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96220. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96221. */
  96222. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96223. /**
  96224. * Gets camera class name
  96225. * @returns VRDeviceOrientationArcRotateCamera
  96226. */
  96227. getClassName(): string;
  96228. }
  96229. }
  96230. declare module BABYLON {
  96231. /**
  96232. * Camera used to simulate VR rendering (based on FreeCamera)
  96233. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96234. */
  96235. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  96236. /**
  96237. * Creates a new VRDeviceOrientationFreeCamera
  96238. * @param name defines camera name
  96239. * @param position defines the start position of the camera
  96240. * @param scene defines the scene the camera belongs to
  96241. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96242. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96243. */
  96244. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96245. /**
  96246. * Gets camera class name
  96247. * @returns VRDeviceOrientationFreeCamera
  96248. */
  96249. getClassName(): string;
  96250. }
  96251. }
  96252. declare module BABYLON {
  96253. /**
  96254. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  96255. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96256. */
  96257. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  96258. /**
  96259. * Creates a new VRDeviceOrientationGamepadCamera
  96260. * @param name defines camera name
  96261. * @param position defines the start position of the camera
  96262. * @param scene defines the scene the camera belongs to
  96263. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96264. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96265. */
  96266. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96267. /**
  96268. * Gets camera class name
  96269. * @returns VRDeviceOrientationGamepadCamera
  96270. */
  96271. getClassName(): string;
  96272. }
  96273. }
  96274. declare module BABYLON {
  96275. /**
  96276. * Defines supported buttons for XBox360 compatible gamepads
  96277. */
  96278. export enum Xbox360Button {
  96279. /** A */
  96280. A = 0,
  96281. /** B */
  96282. B = 1,
  96283. /** X */
  96284. X = 2,
  96285. /** Y */
  96286. Y = 3,
  96287. /** Start */
  96288. Start = 4,
  96289. /** Back */
  96290. Back = 5,
  96291. /** Left button */
  96292. LB = 6,
  96293. /** Right button */
  96294. RB = 7,
  96295. /** Left stick */
  96296. LeftStick = 8,
  96297. /** Right stick */
  96298. RightStick = 9
  96299. }
  96300. /** Defines values for XBox360 DPad */
  96301. export enum Xbox360Dpad {
  96302. /** Up */
  96303. Up = 0,
  96304. /** Down */
  96305. Down = 1,
  96306. /** Left */
  96307. Left = 2,
  96308. /** Right */
  96309. Right = 3
  96310. }
  96311. /**
  96312. * Defines a XBox360 gamepad
  96313. */
  96314. export class Xbox360Pad extends Gamepad {
  96315. private _leftTrigger;
  96316. private _rightTrigger;
  96317. private _onlefttriggerchanged;
  96318. private _onrighttriggerchanged;
  96319. private _onbuttondown;
  96320. private _onbuttonup;
  96321. private _ondpaddown;
  96322. private _ondpadup;
  96323. /** Observable raised when a button is pressed */
  96324. onButtonDownObservable: Observable<Xbox360Button>;
  96325. /** Observable raised when a button is released */
  96326. onButtonUpObservable: Observable<Xbox360Button>;
  96327. /** Observable raised when a pad is pressed */
  96328. onPadDownObservable: Observable<Xbox360Dpad>;
  96329. /** Observable raised when a pad is released */
  96330. onPadUpObservable: Observable<Xbox360Dpad>;
  96331. private _buttonA;
  96332. private _buttonB;
  96333. private _buttonX;
  96334. private _buttonY;
  96335. private _buttonBack;
  96336. private _buttonStart;
  96337. private _buttonLB;
  96338. private _buttonRB;
  96339. private _buttonLeftStick;
  96340. private _buttonRightStick;
  96341. private _dPadUp;
  96342. private _dPadDown;
  96343. private _dPadLeft;
  96344. private _dPadRight;
  96345. private _isXboxOnePad;
  96346. /**
  96347. * Creates a new XBox360 gamepad object
  96348. * @param id defines the id of this gamepad
  96349. * @param index defines its index
  96350. * @param gamepad defines the internal HTML gamepad object
  96351. * @param xboxOne defines if it is a XBox One gamepad
  96352. */
  96353. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  96354. /**
  96355. * Defines the callback to call when left trigger is pressed
  96356. * @param callback defines the callback to use
  96357. */
  96358. onlefttriggerchanged(callback: (value: number) => void): void;
  96359. /**
  96360. * Defines the callback to call when right trigger is pressed
  96361. * @param callback defines the callback to use
  96362. */
  96363. onrighttriggerchanged(callback: (value: number) => void): void;
  96364. /**
  96365. * Gets the left trigger value
  96366. */
  96367. /**
  96368. * Sets the left trigger value
  96369. */
  96370. leftTrigger: number;
  96371. /**
  96372. * Gets the right trigger value
  96373. */
  96374. /**
  96375. * Sets the right trigger value
  96376. */
  96377. rightTrigger: number;
  96378. /**
  96379. * Defines the callback to call when a button is pressed
  96380. * @param callback defines the callback to use
  96381. */
  96382. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96383. /**
  96384. * Defines the callback to call when a button is released
  96385. * @param callback defines the callback to use
  96386. */
  96387. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96388. /**
  96389. * Defines the callback to call when a pad is pressed
  96390. * @param callback defines the callback to use
  96391. */
  96392. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96393. /**
  96394. * Defines the callback to call when a pad is released
  96395. * @param callback defines the callback to use
  96396. */
  96397. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96398. private _setButtonValue;
  96399. private _setDPadValue;
  96400. /**
  96401. * Gets the value of the `A` button
  96402. */
  96403. /**
  96404. * Sets the value of the `A` button
  96405. */
  96406. buttonA: number;
  96407. /**
  96408. * Gets the value of the `B` button
  96409. */
  96410. /**
  96411. * Sets the value of the `B` button
  96412. */
  96413. buttonB: number;
  96414. /**
  96415. * Gets the value of the `X` button
  96416. */
  96417. /**
  96418. * Sets the value of the `X` button
  96419. */
  96420. buttonX: number;
  96421. /**
  96422. * Gets the value of the `Y` button
  96423. */
  96424. /**
  96425. * Sets the value of the `Y` button
  96426. */
  96427. buttonY: number;
  96428. /**
  96429. * Gets the value of the `Start` button
  96430. */
  96431. /**
  96432. * Sets the value of the `Start` button
  96433. */
  96434. buttonStart: number;
  96435. /**
  96436. * Gets the value of the `Back` button
  96437. */
  96438. /**
  96439. * Sets the value of the `Back` button
  96440. */
  96441. buttonBack: number;
  96442. /**
  96443. * Gets the value of the `Left` button
  96444. */
  96445. /**
  96446. * Sets the value of the `Left` button
  96447. */
  96448. buttonLB: number;
  96449. /**
  96450. * Gets the value of the `Right` button
  96451. */
  96452. /**
  96453. * Sets the value of the `Right` button
  96454. */
  96455. buttonRB: number;
  96456. /**
  96457. * Gets the value of the Left joystick
  96458. */
  96459. /**
  96460. * Sets the value of the Left joystick
  96461. */
  96462. buttonLeftStick: number;
  96463. /**
  96464. * Gets the value of the Right joystick
  96465. */
  96466. /**
  96467. * Sets the value of the Right joystick
  96468. */
  96469. buttonRightStick: number;
  96470. /**
  96471. * Gets the value of D-pad up
  96472. */
  96473. /**
  96474. * Sets the value of D-pad up
  96475. */
  96476. dPadUp: number;
  96477. /**
  96478. * Gets the value of D-pad down
  96479. */
  96480. /**
  96481. * Sets the value of D-pad down
  96482. */
  96483. dPadDown: number;
  96484. /**
  96485. * Gets the value of D-pad left
  96486. */
  96487. /**
  96488. * Sets the value of D-pad left
  96489. */
  96490. dPadLeft: number;
  96491. /**
  96492. * Gets the value of D-pad right
  96493. */
  96494. /**
  96495. * Sets the value of D-pad right
  96496. */
  96497. dPadRight: number;
  96498. /**
  96499. * Force the gamepad to synchronize with device values
  96500. */
  96501. update(): void;
  96502. /**
  96503. * Disposes the gamepad
  96504. */
  96505. dispose(): void;
  96506. }
  96507. }
  96508. declare module BABYLON {
  96509. /**
  96510. * Base class of materials working in push mode in babylon JS
  96511. * @hidden
  96512. */
  96513. export class PushMaterial extends Material {
  96514. protected _activeEffect: Effect;
  96515. protected _normalMatrix: Matrix;
  96516. /**
  96517. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96518. * This means that the material can keep using a previous shader while a new one is being compiled.
  96519. * This is mostly used when shader parallel compilation is supported (true by default)
  96520. */
  96521. allowShaderHotSwapping: boolean;
  96522. constructor(name: string, scene: Scene);
  96523. getEffect(): Effect;
  96524. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96525. /**
  96526. * Binds the given world matrix to the active effect
  96527. *
  96528. * @param world the matrix to bind
  96529. */
  96530. bindOnlyWorldMatrix(world: Matrix): void;
  96531. /**
  96532. * Binds the given normal matrix to the active effect
  96533. *
  96534. * @param normalMatrix the matrix to bind
  96535. */
  96536. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96537. bind(world: Matrix, mesh?: Mesh): void;
  96538. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96539. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96540. }
  96541. }
  96542. declare module BABYLON {
  96543. /**
  96544. * This groups all the flags used to control the materials channel.
  96545. */
  96546. export class MaterialFlags {
  96547. private static _DiffuseTextureEnabled;
  96548. /**
  96549. * Are diffuse textures enabled in the application.
  96550. */
  96551. static DiffuseTextureEnabled: boolean;
  96552. private static _AmbientTextureEnabled;
  96553. /**
  96554. * Are ambient textures enabled in the application.
  96555. */
  96556. static AmbientTextureEnabled: boolean;
  96557. private static _OpacityTextureEnabled;
  96558. /**
  96559. * Are opacity textures enabled in the application.
  96560. */
  96561. static OpacityTextureEnabled: boolean;
  96562. private static _ReflectionTextureEnabled;
  96563. /**
  96564. * Are reflection textures enabled in the application.
  96565. */
  96566. static ReflectionTextureEnabled: boolean;
  96567. private static _EmissiveTextureEnabled;
  96568. /**
  96569. * Are emissive textures enabled in the application.
  96570. */
  96571. static EmissiveTextureEnabled: boolean;
  96572. private static _SpecularTextureEnabled;
  96573. /**
  96574. * Are specular textures enabled in the application.
  96575. */
  96576. static SpecularTextureEnabled: boolean;
  96577. private static _BumpTextureEnabled;
  96578. /**
  96579. * Are bump textures enabled in the application.
  96580. */
  96581. static BumpTextureEnabled: boolean;
  96582. private static _LightmapTextureEnabled;
  96583. /**
  96584. * Are lightmap textures enabled in the application.
  96585. */
  96586. static LightmapTextureEnabled: boolean;
  96587. private static _RefractionTextureEnabled;
  96588. /**
  96589. * Are refraction textures enabled in the application.
  96590. */
  96591. static RefractionTextureEnabled: boolean;
  96592. private static _ColorGradingTextureEnabled;
  96593. /**
  96594. * Are color grading textures enabled in the application.
  96595. */
  96596. static ColorGradingTextureEnabled: boolean;
  96597. private static _FresnelEnabled;
  96598. /**
  96599. * Are fresnels enabled in the application.
  96600. */
  96601. static FresnelEnabled: boolean;
  96602. private static _ClearCoatTextureEnabled;
  96603. /**
  96604. * Are clear coat textures enabled in the application.
  96605. */
  96606. static ClearCoatTextureEnabled: boolean;
  96607. private static _ClearCoatBumpTextureEnabled;
  96608. /**
  96609. * Are clear coat bump textures enabled in the application.
  96610. */
  96611. static ClearCoatBumpTextureEnabled: boolean;
  96612. private static _ClearCoatTintTextureEnabled;
  96613. /**
  96614. * Are clear coat tint textures enabled in the application.
  96615. */
  96616. static ClearCoatTintTextureEnabled: boolean;
  96617. private static _SheenTextureEnabled;
  96618. /**
  96619. * Are sheen textures enabled in the application.
  96620. */
  96621. static SheenTextureEnabled: boolean;
  96622. private static _AnisotropicTextureEnabled;
  96623. /**
  96624. * Are anisotropic textures enabled in the application.
  96625. */
  96626. static AnisotropicTextureEnabled: boolean;
  96627. }
  96628. }
  96629. declare module BABYLON {
  96630. /** @hidden */
  96631. export var defaultFragmentDeclaration: {
  96632. name: string;
  96633. shader: string;
  96634. };
  96635. }
  96636. declare module BABYLON {
  96637. /** @hidden */
  96638. export var defaultUboDeclaration: {
  96639. name: string;
  96640. shader: string;
  96641. };
  96642. }
  96643. declare module BABYLON {
  96644. /** @hidden */
  96645. export var lightFragmentDeclaration: {
  96646. name: string;
  96647. shader: string;
  96648. };
  96649. }
  96650. declare module BABYLON {
  96651. /** @hidden */
  96652. export var lightUboDeclaration: {
  96653. name: string;
  96654. shader: string;
  96655. };
  96656. }
  96657. declare module BABYLON {
  96658. /** @hidden */
  96659. export var lightsFragmentFunctions: {
  96660. name: string;
  96661. shader: string;
  96662. };
  96663. }
  96664. declare module BABYLON {
  96665. /** @hidden */
  96666. export var shadowsFragmentFunctions: {
  96667. name: string;
  96668. shader: string;
  96669. };
  96670. }
  96671. declare module BABYLON {
  96672. /** @hidden */
  96673. export var fresnelFunction: {
  96674. name: string;
  96675. shader: string;
  96676. };
  96677. }
  96678. declare module BABYLON {
  96679. /** @hidden */
  96680. export var reflectionFunction: {
  96681. name: string;
  96682. shader: string;
  96683. };
  96684. }
  96685. declare module BABYLON {
  96686. /** @hidden */
  96687. export var bumpFragmentFunctions: {
  96688. name: string;
  96689. shader: string;
  96690. };
  96691. }
  96692. declare module BABYLON {
  96693. /** @hidden */
  96694. export var logDepthDeclaration: {
  96695. name: string;
  96696. shader: string;
  96697. };
  96698. }
  96699. declare module BABYLON {
  96700. /** @hidden */
  96701. export var bumpFragment: {
  96702. name: string;
  96703. shader: string;
  96704. };
  96705. }
  96706. declare module BABYLON {
  96707. /** @hidden */
  96708. export var depthPrePass: {
  96709. name: string;
  96710. shader: string;
  96711. };
  96712. }
  96713. declare module BABYLON {
  96714. /** @hidden */
  96715. export var lightFragment: {
  96716. name: string;
  96717. shader: string;
  96718. };
  96719. }
  96720. declare module BABYLON {
  96721. /** @hidden */
  96722. export var logDepthFragment: {
  96723. name: string;
  96724. shader: string;
  96725. };
  96726. }
  96727. declare module BABYLON {
  96728. /** @hidden */
  96729. export var defaultPixelShader: {
  96730. name: string;
  96731. shader: string;
  96732. };
  96733. }
  96734. declare module BABYLON {
  96735. /** @hidden */
  96736. export var defaultVertexDeclaration: {
  96737. name: string;
  96738. shader: string;
  96739. };
  96740. }
  96741. declare module BABYLON {
  96742. /** @hidden */
  96743. export var bumpVertexDeclaration: {
  96744. name: string;
  96745. shader: string;
  96746. };
  96747. }
  96748. declare module BABYLON {
  96749. /** @hidden */
  96750. export var bumpVertex: {
  96751. name: string;
  96752. shader: string;
  96753. };
  96754. }
  96755. declare module BABYLON {
  96756. /** @hidden */
  96757. export var fogVertex: {
  96758. name: string;
  96759. shader: string;
  96760. };
  96761. }
  96762. declare module BABYLON {
  96763. /** @hidden */
  96764. export var shadowsVertex: {
  96765. name: string;
  96766. shader: string;
  96767. };
  96768. }
  96769. declare module BABYLON {
  96770. /** @hidden */
  96771. export var pointCloudVertex: {
  96772. name: string;
  96773. shader: string;
  96774. };
  96775. }
  96776. declare module BABYLON {
  96777. /** @hidden */
  96778. export var logDepthVertex: {
  96779. name: string;
  96780. shader: string;
  96781. };
  96782. }
  96783. declare module BABYLON {
  96784. /** @hidden */
  96785. export var defaultVertexShader: {
  96786. name: string;
  96787. shader: string;
  96788. };
  96789. }
  96790. declare module BABYLON {
  96791. /** @hidden */
  96792. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96793. MAINUV1: boolean;
  96794. MAINUV2: boolean;
  96795. DIFFUSE: boolean;
  96796. DIFFUSEDIRECTUV: number;
  96797. AMBIENT: boolean;
  96798. AMBIENTDIRECTUV: number;
  96799. OPACITY: boolean;
  96800. OPACITYDIRECTUV: number;
  96801. OPACITYRGB: boolean;
  96802. REFLECTION: boolean;
  96803. EMISSIVE: boolean;
  96804. EMISSIVEDIRECTUV: number;
  96805. SPECULAR: boolean;
  96806. SPECULARDIRECTUV: number;
  96807. BUMP: boolean;
  96808. BUMPDIRECTUV: number;
  96809. PARALLAX: boolean;
  96810. PARALLAXOCCLUSION: boolean;
  96811. SPECULAROVERALPHA: boolean;
  96812. CLIPPLANE: boolean;
  96813. CLIPPLANE2: boolean;
  96814. CLIPPLANE3: boolean;
  96815. CLIPPLANE4: boolean;
  96816. ALPHATEST: boolean;
  96817. DEPTHPREPASS: boolean;
  96818. ALPHAFROMDIFFUSE: boolean;
  96819. POINTSIZE: boolean;
  96820. FOG: boolean;
  96821. SPECULARTERM: boolean;
  96822. DIFFUSEFRESNEL: boolean;
  96823. OPACITYFRESNEL: boolean;
  96824. REFLECTIONFRESNEL: boolean;
  96825. REFRACTIONFRESNEL: boolean;
  96826. EMISSIVEFRESNEL: boolean;
  96827. FRESNEL: boolean;
  96828. NORMAL: boolean;
  96829. UV1: boolean;
  96830. UV2: boolean;
  96831. VERTEXCOLOR: boolean;
  96832. VERTEXALPHA: boolean;
  96833. NUM_BONE_INFLUENCERS: number;
  96834. BonesPerMesh: number;
  96835. BONETEXTURE: boolean;
  96836. INSTANCES: boolean;
  96837. GLOSSINESS: boolean;
  96838. ROUGHNESS: boolean;
  96839. EMISSIVEASILLUMINATION: boolean;
  96840. LINKEMISSIVEWITHDIFFUSE: boolean;
  96841. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96842. LIGHTMAP: boolean;
  96843. LIGHTMAPDIRECTUV: number;
  96844. OBJECTSPACE_NORMALMAP: boolean;
  96845. USELIGHTMAPASSHADOWMAP: boolean;
  96846. REFLECTIONMAP_3D: boolean;
  96847. REFLECTIONMAP_SPHERICAL: boolean;
  96848. REFLECTIONMAP_PLANAR: boolean;
  96849. REFLECTIONMAP_CUBIC: boolean;
  96850. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96851. REFLECTIONMAP_PROJECTION: boolean;
  96852. REFLECTIONMAP_SKYBOX: boolean;
  96853. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96854. REFLECTIONMAP_EXPLICIT: boolean;
  96855. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96856. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96857. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96858. INVERTCUBICMAP: boolean;
  96859. LOGARITHMICDEPTH: boolean;
  96860. REFRACTION: boolean;
  96861. REFRACTIONMAP_3D: boolean;
  96862. REFLECTIONOVERALPHA: boolean;
  96863. TWOSIDEDLIGHTING: boolean;
  96864. SHADOWFLOAT: boolean;
  96865. MORPHTARGETS: boolean;
  96866. MORPHTARGETS_NORMAL: boolean;
  96867. MORPHTARGETS_TANGENT: boolean;
  96868. NUM_MORPH_INFLUENCERS: number;
  96869. NONUNIFORMSCALING: boolean;
  96870. PREMULTIPLYALPHA: boolean;
  96871. IMAGEPROCESSING: boolean;
  96872. VIGNETTE: boolean;
  96873. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96874. VIGNETTEBLENDMODEOPAQUE: boolean;
  96875. TONEMAPPING: boolean;
  96876. TONEMAPPING_ACES: boolean;
  96877. CONTRAST: boolean;
  96878. COLORCURVES: boolean;
  96879. COLORGRADING: boolean;
  96880. COLORGRADING3D: boolean;
  96881. SAMPLER3DGREENDEPTH: boolean;
  96882. SAMPLER3DBGRMAP: boolean;
  96883. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96884. MULTIVIEW: boolean;
  96885. /**
  96886. * If the reflection texture on this material is in linear color space
  96887. * @hidden
  96888. */
  96889. IS_REFLECTION_LINEAR: boolean;
  96890. /**
  96891. * If the refraction texture on this material is in linear color space
  96892. * @hidden
  96893. */
  96894. IS_REFRACTION_LINEAR: boolean;
  96895. EXPOSURE: boolean;
  96896. constructor();
  96897. setReflectionMode(modeToEnable: string): void;
  96898. }
  96899. /**
  96900. * This is the default material used in Babylon. It is the best trade off between quality
  96901. * and performances.
  96902. * @see http://doc.babylonjs.com/babylon101/materials
  96903. */
  96904. export class StandardMaterial extends PushMaterial {
  96905. private _diffuseTexture;
  96906. /**
  96907. * The basic texture of the material as viewed under a light.
  96908. */
  96909. diffuseTexture: Nullable<BaseTexture>;
  96910. private _ambientTexture;
  96911. /**
  96912. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96913. */
  96914. ambientTexture: Nullable<BaseTexture>;
  96915. private _opacityTexture;
  96916. /**
  96917. * Define the transparency of the material from a texture.
  96918. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96919. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96920. */
  96921. opacityTexture: Nullable<BaseTexture>;
  96922. private _reflectionTexture;
  96923. /**
  96924. * Define the texture used to display the reflection.
  96925. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96926. */
  96927. reflectionTexture: Nullable<BaseTexture>;
  96928. private _emissiveTexture;
  96929. /**
  96930. * Define texture of the material as if self lit.
  96931. * This will be mixed in the final result even in the absence of light.
  96932. */
  96933. emissiveTexture: Nullable<BaseTexture>;
  96934. private _specularTexture;
  96935. /**
  96936. * Define how the color and intensity of the highlight given by the light in the material.
  96937. */
  96938. specularTexture: Nullable<BaseTexture>;
  96939. private _bumpTexture;
  96940. /**
  96941. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96942. * 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.
  96943. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96944. */
  96945. bumpTexture: Nullable<BaseTexture>;
  96946. private _lightmapTexture;
  96947. /**
  96948. * Complex lighting can be computationally expensive to compute at runtime.
  96949. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96950. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96951. */
  96952. lightmapTexture: Nullable<BaseTexture>;
  96953. private _refractionTexture;
  96954. /**
  96955. * Define the texture used to display the refraction.
  96956. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96957. */
  96958. refractionTexture: Nullable<BaseTexture>;
  96959. /**
  96960. * The color of the material lit by the environmental background lighting.
  96961. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96962. */
  96963. ambientColor: Color3;
  96964. /**
  96965. * The basic color of the material as viewed under a light.
  96966. */
  96967. diffuseColor: Color3;
  96968. /**
  96969. * Define how the color and intensity of the highlight given by the light in the material.
  96970. */
  96971. specularColor: Color3;
  96972. /**
  96973. * Define the color of the material as if self lit.
  96974. * This will be mixed in the final result even in the absence of light.
  96975. */
  96976. emissiveColor: Color3;
  96977. /**
  96978. * Defines how sharp are the highlights in the material.
  96979. * The bigger the value the sharper giving a more glossy feeling to the result.
  96980. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96981. */
  96982. specularPower: number;
  96983. private _useAlphaFromDiffuseTexture;
  96984. /**
  96985. * Does the transparency come from the diffuse texture alpha channel.
  96986. */
  96987. useAlphaFromDiffuseTexture: boolean;
  96988. private _useEmissiveAsIllumination;
  96989. /**
  96990. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96991. */
  96992. useEmissiveAsIllumination: boolean;
  96993. private _linkEmissiveWithDiffuse;
  96994. /**
  96995. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96996. * the emissive level when the final color is close to one.
  96997. */
  96998. linkEmissiveWithDiffuse: boolean;
  96999. private _useSpecularOverAlpha;
  97000. /**
  97001. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97002. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97003. */
  97004. useSpecularOverAlpha: boolean;
  97005. private _useReflectionOverAlpha;
  97006. /**
  97007. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97008. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97009. */
  97010. useReflectionOverAlpha: boolean;
  97011. private _disableLighting;
  97012. /**
  97013. * Does lights from the scene impacts this material.
  97014. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97015. */
  97016. disableLighting: boolean;
  97017. private _useObjectSpaceNormalMap;
  97018. /**
  97019. * Allows using an object space normal map (instead of tangent space).
  97020. */
  97021. useObjectSpaceNormalMap: boolean;
  97022. private _useParallax;
  97023. /**
  97024. * Is parallax enabled or not.
  97025. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97026. */
  97027. useParallax: boolean;
  97028. private _useParallaxOcclusion;
  97029. /**
  97030. * Is parallax occlusion enabled or not.
  97031. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97032. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97033. */
  97034. useParallaxOcclusion: boolean;
  97035. /**
  97036. * 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.
  97037. */
  97038. parallaxScaleBias: number;
  97039. private _roughness;
  97040. /**
  97041. * Helps to define how blurry the reflections should appears in the material.
  97042. */
  97043. roughness: number;
  97044. /**
  97045. * In case of refraction, define the value of the indice of refraction.
  97046. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97047. */
  97048. indexOfRefraction: number;
  97049. /**
  97050. * Invert the refraction texture alongside the y axis.
  97051. * It can be useful with procedural textures or probe for instance.
  97052. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97053. */
  97054. invertRefractionY: boolean;
  97055. /**
  97056. * Defines the alpha limits in alpha test mode.
  97057. */
  97058. alphaCutOff: number;
  97059. private _useLightmapAsShadowmap;
  97060. /**
  97061. * In case of light mapping, define whether the map contains light or shadow informations.
  97062. */
  97063. useLightmapAsShadowmap: boolean;
  97064. private _diffuseFresnelParameters;
  97065. /**
  97066. * Define the diffuse fresnel parameters of the material.
  97067. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97068. */
  97069. diffuseFresnelParameters: FresnelParameters;
  97070. private _opacityFresnelParameters;
  97071. /**
  97072. * Define the opacity fresnel parameters of the material.
  97073. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97074. */
  97075. opacityFresnelParameters: FresnelParameters;
  97076. private _reflectionFresnelParameters;
  97077. /**
  97078. * Define the reflection fresnel parameters of the material.
  97079. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97080. */
  97081. reflectionFresnelParameters: FresnelParameters;
  97082. private _refractionFresnelParameters;
  97083. /**
  97084. * Define the refraction fresnel parameters of the material.
  97085. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97086. */
  97087. refractionFresnelParameters: FresnelParameters;
  97088. private _emissiveFresnelParameters;
  97089. /**
  97090. * Define the emissive fresnel parameters of the material.
  97091. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97092. */
  97093. emissiveFresnelParameters: FresnelParameters;
  97094. private _useReflectionFresnelFromSpecular;
  97095. /**
  97096. * If true automatically deducts the fresnels values from the material specularity.
  97097. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97098. */
  97099. useReflectionFresnelFromSpecular: boolean;
  97100. private _useGlossinessFromSpecularMapAlpha;
  97101. /**
  97102. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97103. */
  97104. useGlossinessFromSpecularMapAlpha: boolean;
  97105. private _maxSimultaneousLights;
  97106. /**
  97107. * Defines the maximum number of lights that can be used in the material
  97108. */
  97109. maxSimultaneousLights: number;
  97110. private _invertNormalMapX;
  97111. /**
  97112. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97113. */
  97114. invertNormalMapX: boolean;
  97115. private _invertNormalMapY;
  97116. /**
  97117. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97118. */
  97119. invertNormalMapY: boolean;
  97120. private _twoSidedLighting;
  97121. /**
  97122. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97123. */
  97124. twoSidedLighting: boolean;
  97125. /**
  97126. * Default configuration related to image processing available in the standard Material.
  97127. */
  97128. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97129. /**
  97130. * Gets the image processing configuration used either in this material.
  97131. */
  97132. /**
  97133. * Sets the Default image processing configuration used either in the this material.
  97134. *
  97135. * If sets to null, the scene one is in use.
  97136. */
  97137. imageProcessingConfiguration: ImageProcessingConfiguration;
  97138. /**
  97139. * Keep track of the image processing observer to allow dispose and replace.
  97140. */
  97141. private _imageProcessingObserver;
  97142. /**
  97143. * Attaches a new image processing configuration to the Standard Material.
  97144. * @param configuration
  97145. */
  97146. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97147. /**
  97148. * Gets wether the color curves effect is enabled.
  97149. */
  97150. /**
  97151. * Sets wether the color curves effect is enabled.
  97152. */
  97153. cameraColorCurvesEnabled: boolean;
  97154. /**
  97155. * Gets wether the color grading effect is enabled.
  97156. */
  97157. /**
  97158. * Gets wether the color grading effect is enabled.
  97159. */
  97160. cameraColorGradingEnabled: boolean;
  97161. /**
  97162. * Gets wether tonemapping is enabled or not.
  97163. */
  97164. /**
  97165. * Sets wether tonemapping is enabled or not
  97166. */
  97167. cameraToneMappingEnabled: boolean;
  97168. /**
  97169. * The camera exposure used on this material.
  97170. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97171. * This corresponds to a photographic exposure.
  97172. */
  97173. /**
  97174. * The camera exposure used on this material.
  97175. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97176. * This corresponds to a photographic exposure.
  97177. */
  97178. cameraExposure: number;
  97179. /**
  97180. * Gets The camera contrast used on this material.
  97181. */
  97182. /**
  97183. * Sets The camera contrast used on this material.
  97184. */
  97185. cameraContrast: number;
  97186. /**
  97187. * Gets the Color Grading 2D Lookup Texture.
  97188. */
  97189. /**
  97190. * Sets the Color Grading 2D Lookup Texture.
  97191. */
  97192. cameraColorGradingTexture: Nullable<BaseTexture>;
  97193. /**
  97194. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97195. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97196. * 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;
  97197. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97198. */
  97199. /**
  97200. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97201. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97202. * 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;
  97203. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97204. */
  97205. cameraColorCurves: Nullable<ColorCurves>;
  97206. /**
  97207. * Custom callback helping to override the default shader used in the material.
  97208. */
  97209. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97210. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97211. protected _worldViewProjectionMatrix: Matrix;
  97212. protected _globalAmbientColor: Color3;
  97213. protected _useLogarithmicDepth: boolean;
  97214. /**
  97215. * Instantiates a new standard material.
  97216. * This is the default material used in Babylon. It is the best trade off between quality
  97217. * and performances.
  97218. * @see http://doc.babylonjs.com/babylon101/materials
  97219. * @param name Define the name of the material in the scene
  97220. * @param scene Define the scene the material belong to
  97221. */
  97222. constructor(name: string, scene: Scene);
  97223. /**
  97224. * Gets a boolean indicating that current material needs to register RTT
  97225. */
  97226. readonly hasRenderTargetTextures: boolean;
  97227. /**
  97228. * Gets the current class name of the material e.g. "StandardMaterial"
  97229. * Mainly use in serialization.
  97230. * @returns the class name
  97231. */
  97232. getClassName(): string;
  97233. /**
  97234. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97235. * You can try switching to logarithmic depth.
  97236. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97237. */
  97238. useLogarithmicDepth: boolean;
  97239. /**
  97240. * Specifies if the material will require alpha blending
  97241. * @returns a boolean specifying if alpha blending is needed
  97242. */
  97243. needAlphaBlending(): boolean;
  97244. /**
  97245. * Specifies if this material should be rendered in alpha test mode
  97246. * @returns a boolean specifying if an alpha test is needed.
  97247. */
  97248. needAlphaTesting(): boolean;
  97249. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97250. /**
  97251. * Get the texture used for alpha test purpose.
  97252. * @returns the diffuse texture in case of the standard material.
  97253. */
  97254. getAlphaTestTexture(): Nullable<BaseTexture>;
  97255. /**
  97256. * Get if the submesh is ready to be used and all its information available.
  97257. * Child classes can use it to update shaders
  97258. * @param mesh defines the mesh to check
  97259. * @param subMesh defines which submesh to check
  97260. * @param useInstances specifies that instances should be used
  97261. * @returns a boolean indicating that the submesh is ready or not
  97262. */
  97263. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97264. /**
  97265. * Builds the material UBO layouts.
  97266. * Used internally during the effect preparation.
  97267. */
  97268. buildUniformLayout(): void;
  97269. /**
  97270. * Unbinds the material from the mesh
  97271. */
  97272. unbind(): void;
  97273. /**
  97274. * Binds the submesh to this material by preparing the effect and shader to draw
  97275. * @param world defines the world transformation matrix
  97276. * @param mesh defines the mesh containing the submesh
  97277. * @param subMesh defines the submesh to bind the material to
  97278. */
  97279. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97280. /**
  97281. * Get the list of animatables in the material.
  97282. * @returns the list of animatables object used in the material
  97283. */
  97284. getAnimatables(): IAnimatable[];
  97285. /**
  97286. * Gets the active textures from the material
  97287. * @returns an array of textures
  97288. */
  97289. getActiveTextures(): BaseTexture[];
  97290. /**
  97291. * Specifies if the material uses a texture
  97292. * @param texture defines the texture to check against the material
  97293. * @returns a boolean specifying if the material uses the texture
  97294. */
  97295. hasTexture(texture: BaseTexture): boolean;
  97296. /**
  97297. * Disposes the material
  97298. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97299. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97300. */
  97301. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97302. /**
  97303. * Makes a duplicate of the material, and gives it a new name
  97304. * @param name defines the new name for the duplicated material
  97305. * @returns the cloned material
  97306. */
  97307. clone(name: string): StandardMaterial;
  97308. /**
  97309. * Serializes this material in a JSON representation
  97310. * @returns the serialized material object
  97311. */
  97312. serialize(): any;
  97313. /**
  97314. * Creates a standard material from parsed material data
  97315. * @param source defines the JSON representation of the material
  97316. * @param scene defines the hosting scene
  97317. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97318. * @returns a new standard material
  97319. */
  97320. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97321. /**
  97322. * Are diffuse textures enabled in the application.
  97323. */
  97324. static DiffuseTextureEnabled: boolean;
  97325. /**
  97326. * Are ambient textures enabled in the application.
  97327. */
  97328. static AmbientTextureEnabled: boolean;
  97329. /**
  97330. * Are opacity textures enabled in the application.
  97331. */
  97332. static OpacityTextureEnabled: boolean;
  97333. /**
  97334. * Are reflection textures enabled in the application.
  97335. */
  97336. static ReflectionTextureEnabled: boolean;
  97337. /**
  97338. * Are emissive textures enabled in the application.
  97339. */
  97340. static EmissiveTextureEnabled: boolean;
  97341. /**
  97342. * Are specular textures enabled in the application.
  97343. */
  97344. static SpecularTextureEnabled: boolean;
  97345. /**
  97346. * Are bump textures enabled in the application.
  97347. */
  97348. static BumpTextureEnabled: boolean;
  97349. /**
  97350. * Are lightmap textures enabled in the application.
  97351. */
  97352. static LightmapTextureEnabled: boolean;
  97353. /**
  97354. * Are refraction textures enabled in the application.
  97355. */
  97356. static RefractionTextureEnabled: boolean;
  97357. /**
  97358. * Are color grading textures enabled in the application.
  97359. */
  97360. static ColorGradingTextureEnabled: boolean;
  97361. /**
  97362. * Are fresnels enabled in the application.
  97363. */
  97364. static FresnelEnabled: boolean;
  97365. }
  97366. }
  97367. declare module BABYLON {
  97368. /**
  97369. * A class extending Texture allowing drawing on a texture
  97370. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97371. */
  97372. export class DynamicTexture extends Texture {
  97373. private _generateMipMaps;
  97374. private _canvas;
  97375. private _context;
  97376. private _engine;
  97377. /**
  97378. * Creates a DynamicTexture
  97379. * @param name defines the name of the texture
  97380. * @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
  97381. * @param scene defines the scene where you want the texture
  97382. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97383. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97384. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97385. */
  97386. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97387. /**
  97388. * Get the current class name of the texture useful for serialization or dynamic coding.
  97389. * @returns "DynamicTexture"
  97390. */
  97391. getClassName(): string;
  97392. /**
  97393. * Gets the current state of canRescale
  97394. */
  97395. readonly canRescale: boolean;
  97396. private _recreate;
  97397. /**
  97398. * Scales the texture
  97399. * @param ratio the scale factor to apply to both width and height
  97400. */
  97401. scale(ratio: number): void;
  97402. /**
  97403. * Resizes the texture
  97404. * @param width the new width
  97405. * @param height the new height
  97406. */
  97407. scaleTo(width: number, height: number): void;
  97408. /**
  97409. * Gets the context of the canvas used by the texture
  97410. * @returns the canvas context of the dynamic texture
  97411. */
  97412. getContext(): CanvasRenderingContext2D;
  97413. /**
  97414. * Clears the texture
  97415. */
  97416. clear(): void;
  97417. /**
  97418. * Updates the texture
  97419. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97420. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  97421. */
  97422. update(invertY?: boolean, premulAlpha?: boolean): void;
  97423. /**
  97424. * Draws text onto the texture
  97425. * @param text defines the text to be drawn
  97426. * @param x defines the placement of the text from the left
  97427. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  97428. * @param font defines the font to be used with font-style, font-size, font-name
  97429. * @param color defines the color used for the text
  97430. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  97431. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97432. * @param update defines whether texture is immediately update (default is true)
  97433. */
  97434. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  97435. /**
  97436. * Clones the texture
  97437. * @returns the clone of the texture.
  97438. */
  97439. clone(): DynamicTexture;
  97440. /**
  97441. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  97442. * @returns a serialized dynamic texture object
  97443. */
  97444. serialize(): any;
  97445. /** @hidden */
  97446. _rebuild(): void;
  97447. }
  97448. }
  97449. declare module BABYLON {
  97450. /** @hidden */
  97451. export var imageProcessingPixelShader: {
  97452. name: string;
  97453. shader: string;
  97454. };
  97455. }
  97456. declare module BABYLON {
  97457. /**
  97458. * ImageProcessingPostProcess
  97459. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  97460. */
  97461. export class ImageProcessingPostProcess extends PostProcess {
  97462. /**
  97463. * Default configuration related to image processing available in the PBR Material.
  97464. */
  97465. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97466. /**
  97467. * Gets the image processing configuration used either in this material.
  97468. */
  97469. /**
  97470. * Sets the Default image processing configuration used either in the this material.
  97471. *
  97472. * If sets to null, the scene one is in use.
  97473. */
  97474. imageProcessingConfiguration: ImageProcessingConfiguration;
  97475. /**
  97476. * Keep track of the image processing observer to allow dispose and replace.
  97477. */
  97478. private _imageProcessingObserver;
  97479. /**
  97480. * Attaches a new image processing configuration to the PBR Material.
  97481. * @param configuration
  97482. */
  97483. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  97484. /**
  97485. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97486. */
  97487. /**
  97488. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97489. */
  97490. colorCurves: Nullable<ColorCurves>;
  97491. /**
  97492. * Gets wether the color curves effect is enabled.
  97493. */
  97494. /**
  97495. * Sets wether the color curves effect is enabled.
  97496. */
  97497. colorCurvesEnabled: boolean;
  97498. /**
  97499. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97500. */
  97501. /**
  97502. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97503. */
  97504. colorGradingTexture: Nullable<BaseTexture>;
  97505. /**
  97506. * Gets wether the color grading effect is enabled.
  97507. */
  97508. /**
  97509. * Gets wether the color grading effect is enabled.
  97510. */
  97511. colorGradingEnabled: boolean;
  97512. /**
  97513. * Gets exposure used in the effect.
  97514. */
  97515. /**
  97516. * Sets exposure used in the effect.
  97517. */
  97518. exposure: number;
  97519. /**
  97520. * Gets wether tonemapping is enabled or not.
  97521. */
  97522. /**
  97523. * Sets wether tonemapping is enabled or not
  97524. */
  97525. toneMappingEnabled: boolean;
  97526. /**
  97527. * Gets the type of tone mapping effect.
  97528. */
  97529. /**
  97530. * Sets the type of tone mapping effect.
  97531. */
  97532. toneMappingType: number;
  97533. /**
  97534. * Gets contrast used in the effect.
  97535. */
  97536. /**
  97537. * Sets contrast used in the effect.
  97538. */
  97539. contrast: number;
  97540. /**
  97541. * Gets Vignette stretch size.
  97542. */
  97543. /**
  97544. * Sets Vignette stretch size.
  97545. */
  97546. vignetteStretch: number;
  97547. /**
  97548. * Gets Vignette centre X Offset.
  97549. */
  97550. /**
  97551. * Sets Vignette centre X Offset.
  97552. */
  97553. vignetteCentreX: number;
  97554. /**
  97555. * Gets Vignette centre Y Offset.
  97556. */
  97557. /**
  97558. * Sets Vignette centre Y Offset.
  97559. */
  97560. vignetteCentreY: number;
  97561. /**
  97562. * Gets Vignette weight or intensity of the vignette effect.
  97563. */
  97564. /**
  97565. * Sets Vignette weight or intensity of the vignette effect.
  97566. */
  97567. vignetteWeight: number;
  97568. /**
  97569. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97570. * if vignetteEnabled is set to true.
  97571. */
  97572. /**
  97573. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97574. * if vignetteEnabled is set to true.
  97575. */
  97576. vignetteColor: Color4;
  97577. /**
  97578. * Gets Camera field of view used by the Vignette effect.
  97579. */
  97580. /**
  97581. * Sets Camera field of view used by the Vignette effect.
  97582. */
  97583. vignetteCameraFov: number;
  97584. /**
  97585. * Gets the vignette blend mode allowing different kind of effect.
  97586. */
  97587. /**
  97588. * Sets the vignette blend mode allowing different kind of effect.
  97589. */
  97590. vignetteBlendMode: number;
  97591. /**
  97592. * Gets wether the vignette effect is enabled.
  97593. */
  97594. /**
  97595. * Sets wether the vignette effect is enabled.
  97596. */
  97597. vignetteEnabled: boolean;
  97598. private _fromLinearSpace;
  97599. /**
  97600. * Gets wether the input of the processing is in Gamma or Linear Space.
  97601. */
  97602. /**
  97603. * Sets wether the input of the processing is in Gamma or Linear Space.
  97604. */
  97605. fromLinearSpace: boolean;
  97606. /**
  97607. * Defines cache preventing GC.
  97608. */
  97609. private _defines;
  97610. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  97611. /**
  97612. * "ImageProcessingPostProcess"
  97613. * @returns "ImageProcessingPostProcess"
  97614. */
  97615. getClassName(): string;
  97616. protected _updateParameters(): void;
  97617. dispose(camera?: Camera): void;
  97618. }
  97619. }
  97620. declare module BABYLON {
  97621. /**
  97622. * Class containing static functions to help procedurally build meshes
  97623. */
  97624. export class GroundBuilder {
  97625. /**
  97626. * Creates a ground mesh
  97627. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  97628. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  97629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97630. * @param name defines the name of the mesh
  97631. * @param options defines the options used to create the mesh
  97632. * @param scene defines the hosting scene
  97633. * @returns the ground mesh
  97634. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  97635. */
  97636. static CreateGround(name: string, options: {
  97637. width?: number;
  97638. height?: number;
  97639. subdivisions?: number;
  97640. subdivisionsX?: number;
  97641. subdivisionsY?: number;
  97642. updatable?: boolean;
  97643. }, scene: any): Mesh;
  97644. /**
  97645. * Creates a tiled ground mesh
  97646. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  97647. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  97648. * * 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
  97649. * * 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
  97650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97651. * @param name defines the name of the mesh
  97652. * @param options defines the options used to create the mesh
  97653. * @param scene defines the hosting scene
  97654. * @returns the tiled ground mesh
  97655. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  97656. */
  97657. static CreateTiledGround(name: string, options: {
  97658. xmin: number;
  97659. zmin: number;
  97660. xmax: number;
  97661. zmax: number;
  97662. subdivisions?: {
  97663. w: number;
  97664. h: number;
  97665. };
  97666. precision?: {
  97667. w: number;
  97668. h: number;
  97669. };
  97670. updatable?: boolean;
  97671. }, scene: Scene): Mesh;
  97672. /**
  97673. * Creates a ground mesh from a height map
  97674. * * The parameter `url` sets the URL of the height map image resource.
  97675. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  97676. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  97677. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  97678. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  97679. * * 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.
  97680. * * 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).
  97681. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97683. * @param name defines the name of the mesh
  97684. * @param url defines the url to the height map
  97685. * @param options defines the options used to create the mesh
  97686. * @param scene defines the hosting scene
  97687. * @returns the ground mesh
  97688. * @see https://doc.babylonjs.com/babylon101/height_map
  97689. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  97690. */
  97691. static CreateGroundFromHeightMap(name: string, url: string, options: {
  97692. width?: number;
  97693. height?: number;
  97694. subdivisions?: number;
  97695. minHeight?: number;
  97696. maxHeight?: number;
  97697. colorFilter?: Color3;
  97698. alphaFilter?: number;
  97699. updatable?: boolean;
  97700. onReady?: (mesh: GroundMesh) => void;
  97701. }, scene: Scene): GroundMesh;
  97702. }
  97703. }
  97704. declare module BABYLON {
  97705. /**
  97706. * Class containing static functions to help procedurally build meshes
  97707. */
  97708. export class TorusBuilder {
  97709. /**
  97710. * Creates a torus mesh
  97711. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  97712. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  97713. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  97714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97717. * @param name defines the name of the mesh
  97718. * @param options defines the options used to create the mesh
  97719. * @param scene defines the hosting scene
  97720. * @returns the torus mesh
  97721. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  97722. */
  97723. static CreateTorus(name: string, options: {
  97724. diameter?: number;
  97725. thickness?: number;
  97726. tessellation?: number;
  97727. updatable?: boolean;
  97728. sideOrientation?: number;
  97729. frontUVs?: Vector4;
  97730. backUVs?: Vector4;
  97731. }, scene: any): Mesh;
  97732. }
  97733. }
  97734. declare module BABYLON {
  97735. /**
  97736. * Class containing static functions to help procedurally build meshes
  97737. */
  97738. export class CylinderBuilder {
  97739. /**
  97740. * Creates a cylinder or a cone mesh
  97741. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  97742. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  97743. * * 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.
  97744. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  97745. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  97746. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  97747. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  97748. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  97749. * * 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).
  97750. * * 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
  97751. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  97752. * * 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
  97753. * * 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.
  97754. * * If `enclose` is false, a ring surface is one element.
  97755. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  97756. * * 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
  97757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97760. * @param name defines the name of the mesh
  97761. * @param options defines the options used to create the mesh
  97762. * @param scene defines the hosting scene
  97763. * @returns the cylinder mesh
  97764. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  97765. */
  97766. static CreateCylinder(name: string, options: {
  97767. height?: number;
  97768. diameterTop?: number;
  97769. diameterBottom?: number;
  97770. diameter?: number;
  97771. tessellation?: number;
  97772. subdivisions?: number;
  97773. arc?: number;
  97774. faceColors?: Color4[];
  97775. faceUV?: Vector4[];
  97776. updatable?: boolean;
  97777. hasRings?: boolean;
  97778. enclose?: boolean;
  97779. sideOrientation?: number;
  97780. frontUVs?: Vector4;
  97781. backUVs?: Vector4;
  97782. }, scene: any): Mesh;
  97783. }
  97784. }
  97785. declare module BABYLON {
  97786. /**
  97787. * Manager for handling gamepads
  97788. */
  97789. export class GamepadManager {
  97790. private _scene?;
  97791. private _babylonGamepads;
  97792. private _oneGamepadConnected;
  97793. /** @hidden */
  97794. _isMonitoring: boolean;
  97795. private _gamepadEventSupported;
  97796. private _gamepadSupport;
  97797. /**
  97798. * observable to be triggered when the gamepad controller has been connected
  97799. */
  97800. onGamepadConnectedObservable: Observable<Gamepad>;
  97801. /**
  97802. * observable to be triggered when the gamepad controller has been disconnected
  97803. */
  97804. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97805. private _onGamepadConnectedEvent;
  97806. private _onGamepadDisconnectedEvent;
  97807. /**
  97808. * Initializes the gamepad manager
  97809. * @param _scene BabylonJS scene
  97810. */
  97811. constructor(_scene?: Scene | undefined);
  97812. /**
  97813. * The gamepads in the game pad manager
  97814. */
  97815. readonly gamepads: Gamepad[];
  97816. /**
  97817. * Get the gamepad controllers based on type
  97818. * @param type The type of gamepad controller
  97819. * @returns Nullable gamepad
  97820. */
  97821. getGamepadByType(type?: number): Nullable<Gamepad>;
  97822. /**
  97823. * Disposes the gamepad manager
  97824. */
  97825. dispose(): void;
  97826. private _addNewGamepad;
  97827. private _startMonitoringGamepads;
  97828. private _stopMonitoringGamepads;
  97829. /** @hidden */
  97830. _checkGamepadsStatus(): void;
  97831. private _updateGamepadObjects;
  97832. }
  97833. }
  97834. declare module BABYLON {
  97835. interface Scene {
  97836. /** @hidden */
  97837. _gamepadManager: Nullable<GamepadManager>;
  97838. /**
  97839. * Gets the gamepad manager associated with the scene
  97840. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97841. */
  97842. gamepadManager: GamepadManager;
  97843. }
  97844. /**
  97845. * Interface representing a free camera inputs manager
  97846. */
  97847. interface FreeCameraInputsManager {
  97848. /**
  97849. * Adds gamepad input support to the FreeCameraInputsManager.
  97850. * @returns the FreeCameraInputsManager
  97851. */
  97852. addGamepad(): FreeCameraInputsManager;
  97853. }
  97854. /**
  97855. * Interface representing an arc rotate camera inputs manager
  97856. */
  97857. interface ArcRotateCameraInputsManager {
  97858. /**
  97859. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97860. * @returns the camera inputs manager
  97861. */
  97862. addGamepad(): ArcRotateCameraInputsManager;
  97863. }
  97864. /**
  97865. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97866. */
  97867. export class GamepadSystemSceneComponent implements ISceneComponent {
  97868. /**
  97869. * The component name helpfull to identify the component in the list of scene components.
  97870. */
  97871. readonly name: string;
  97872. /**
  97873. * The scene the component belongs to.
  97874. */
  97875. scene: Scene;
  97876. /**
  97877. * Creates a new instance of the component for the given scene
  97878. * @param scene Defines the scene to register the component in
  97879. */
  97880. constructor(scene: Scene);
  97881. /**
  97882. * Registers the component in a given scene
  97883. */
  97884. register(): void;
  97885. /**
  97886. * Rebuilds the elements related to this component in case of
  97887. * context lost for instance.
  97888. */
  97889. rebuild(): void;
  97890. /**
  97891. * Disposes the component and the associated ressources
  97892. */
  97893. dispose(): void;
  97894. private _beforeCameraUpdate;
  97895. }
  97896. }
  97897. declare module BABYLON {
  97898. /**
  97899. * Options to modify the vr teleportation behavior.
  97900. */
  97901. export interface VRTeleportationOptions {
  97902. /**
  97903. * The name of the mesh which should be used as the teleportation floor. (default: null)
  97904. */
  97905. floorMeshName?: string;
  97906. /**
  97907. * A list of meshes to be used as the teleportation floor. (default: empty)
  97908. */
  97909. floorMeshes?: Mesh[];
  97910. }
  97911. /**
  97912. * Options to modify the vr experience helper's behavior.
  97913. */
  97914. export interface VRExperienceHelperOptions extends WebVROptions {
  97915. /**
  97916. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  97917. */
  97918. createDeviceOrientationCamera?: boolean;
  97919. /**
  97920. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  97921. */
  97922. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  97923. /**
  97924. * Uses the main button on the controller to toggle the laser casted. (default: true)
  97925. */
  97926. laserToggle?: boolean;
  97927. /**
  97928. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  97929. */
  97930. floorMeshes?: Mesh[];
  97931. /**
  97932. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  97933. */
  97934. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  97935. }
  97936. /**
  97937. * Event containing information after VR has been entered
  97938. */
  97939. export class OnAfterEnteringVRObservableEvent {
  97940. /**
  97941. * If entering vr was successful
  97942. */
  97943. success: boolean;
  97944. }
  97945. /**
  97946. * Helps to quickly add VR support to an existing scene.
  97947. * See http://doc.babylonjs.com/how_to/webvr_helper
  97948. */
  97949. export class VRExperienceHelper {
  97950. /** Options to modify the vr experience helper's behavior. */
  97951. webVROptions: VRExperienceHelperOptions;
  97952. private _scene;
  97953. private _position;
  97954. private _btnVR;
  97955. private _btnVRDisplayed;
  97956. private _webVRsupported;
  97957. private _webVRready;
  97958. private _webVRrequesting;
  97959. private _webVRpresenting;
  97960. private _hasEnteredVR;
  97961. private _fullscreenVRpresenting;
  97962. private _canvas;
  97963. private _webVRCamera;
  97964. private _vrDeviceOrientationCamera;
  97965. private _deviceOrientationCamera;
  97966. private _existingCamera;
  97967. private _onKeyDown;
  97968. private _onVrDisplayPresentChange;
  97969. private _onVRDisplayChanged;
  97970. private _onVRRequestPresentStart;
  97971. private _onVRRequestPresentComplete;
  97972. /**
  97973. * Observable raised right before entering VR.
  97974. */
  97975. onEnteringVRObservable: Observable<VRExperienceHelper>;
  97976. /**
  97977. * Observable raised when entering VR has completed.
  97978. */
  97979. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  97980. /**
  97981. * Observable raised when exiting VR.
  97982. */
  97983. onExitingVRObservable: Observable<VRExperienceHelper>;
  97984. /**
  97985. * Observable raised when controller mesh is loaded.
  97986. */
  97987. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97988. /** Return this.onEnteringVRObservable
  97989. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  97990. */
  97991. readonly onEnteringVR: Observable<VRExperienceHelper>;
  97992. /** Return this.onExitingVRObservable
  97993. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  97994. */
  97995. readonly onExitingVR: Observable<VRExperienceHelper>;
  97996. /** Return this.onControllerMeshLoadedObservable
  97997. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  97998. */
  97999. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98000. private _rayLength;
  98001. private _useCustomVRButton;
  98002. private _teleportationRequested;
  98003. private _teleportActive;
  98004. private _floorMeshName;
  98005. private _floorMeshesCollection;
  98006. private _rotationAllowed;
  98007. private _teleportBackwardsVector;
  98008. private _teleportationTarget;
  98009. private _isDefaultTeleportationTarget;
  98010. private _postProcessMove;
  98011. private _teleportationFillColor;
  98012. private _teleportationBorderColor;
  98013. private _rotationAngle;
  98014. private _haloCenter;
  98015. private _cameraGazer;
  98016. private _padSensibilityUp;
  98017. private _padSensibilityDown;
  98018. private _leftController;
  98019. private _rightController;
  98020. /**
  98021. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98022. */
  98023. onNewMeshSelected: Observable<AbstractMesh>;
  98024. /**
  98025. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98026. */
  98027. onNewMeshPicked: Observable<PickingInfo>;
  98028. private _circleEase;
  98029. /**
  98030. * Observable raised before camera teleportation
  98031. */
  98032. onBeforeCameraTeleport: Observable<Vector3>;
  98033. /**
  98034. * Observable raised after camera teleportation
  98035. */
  98036. onAfterCameraTeleport: Observable<Vector3>;
  98037. /**
  98038. * Observable raised when current selected mesh gets unselected
  98039. */
  98040. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98041. private _raySelectionPredicate;
  98042. /**
  98043. * To be optionaly changed by user to define custom ray selection
  98044. */
  98045. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98046. /**
  98047. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98048. */
  98049. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98050. /**
  98051. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98052. */
  98053. teleportationEnabled: boolean;
  98054. private _defaultHeight;
  98055. private _teleportationInitialized;
  98056. private _interactionsEnabled;
  98057. private _interactionsRequested;
  98058. private _displayGaze;
  98059. private _displayLaserPointer;
  98060. /**
  98061. * The mesh used to display where the user is going to teleport.
  98062. */
  98063. /**
  98064. * Sets the mesh to be used to display where the user is going to teleport.
  98065. */
  98066. teleportationTarget: Mesh;
  98067. /**
  98068. * 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
  98069. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98070. * See http://doc.babylonjs.com/resources/baking_transformations
  98071. */
  98072. gazeTrackerMesh: Mesh;
  98073. /**
  98074. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98075. */
  98076. updateGazeTrackerScale: boolean;
  98077. /**
  98078. * If the gaze trackers color should be updated when selecting meshes
  98079. */
  98080. updateGazeTrackerColor: boolean;
  98081. /**
  98082. * The gaze tracking mesh corresponding to the left controller
  98083. */
  98084. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98085. /**
  98086. * The gaze tracking mesh corresponding to the right controller
  98087. */
  98088. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98089. /**
  98090. * If the ray of the gaze should be displayed.
  98091. */
  98092. /**
  98093. * Sets if the ray of the gaze should be displayed.
  98094. */
  98095. displayGaze: boolean;
  98096. /**
  98097. * If the ray of the LaserPointer should be displayed.
  98098. */
  98099. /**
  98100. * Sets if the ray of the LaserPointer should be displayed.
  98101. */
  98102. displayLaserPointer: boolean;
  98103. /**
  98104. * The deviceOrientationCamera used as the camera when not in VR.
  98105. */
  98106. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98107. /**
  98108. * Based on the current WebVR support, returns the current VR camera used.
  98109. */
  98110. readonly currentVRCamera: Nullable<Camera>;
  98111. /**
  98112. * The webVRCamera which is used when in VR.
  98113. */
  98114. readonly webVRCamera: WebVRFreeCamera;
  98115. /**
  98116. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  98117. */
  98118. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  98119. private readonly _teleportationRequestInitiated;
  98120. /**
  98121. * Defines wether or not Pointer lock should be requested when switching to
  98122. * full screen.
  98123. */
  98124. requestPointerLockOnFullScreen: boolean;
  98125. /**
  98126. * Instantiates a VRExperienceHelper.
  98127. * Helps to quickly add VR support to an existing scene.
  98128. * @param scene The scene the VRExperienceHelper belongs to.
  98129. * @param webVROptions Options to modify the vr experience helper's behavior.
  98130. */
  98131. constructor(scene: Scene,
  98132. /** Options to modify the vr experience helper's behavior. */
  98133. webVROptions?: VRExperienceHelperOptions);
  98134. private _onDefaultMeshLoaded;
  98135. private _onResize;
  98136. private _onFullscreenChange;
  98137. /**
  98138. * Gets a value indicating if we are currently in VR mode.
  98139. */
  98140. readonly isInVRMode: boolean;
  98141. private onVrDisplayPresentChange;
  98142. private onVRDisplayChanged;
  98143. private moveButtonToBottomRight;
  98144. private displayVRButton;
  98145. private updateButtonVisibility;
  98146. private _cachedAngularSensibility;
  98147. /**
  98148. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  98149. * Otherwise, will use the fullscreen API.
  98150. */
  98151. enterVR(): void;
  98152. /**
  98153. * Attempt to exit VR, or fullscreen.
  98154. */
  98155. exitVR(): void;
  98156. /**
  98157. * The position of the vr experience helper.
  98158. */
  98159. /**
  98160. * Sets the position of the vr experience helper.
  98161. */
  98162. position: Vector3;
  98163. /**
  98164. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  98165. */
  98166. enableInteractions(): void;
  98167. private readonly _noControllerIsActive;
  98168. private beforeRender;
  98169. private _isTeleportationFloor;
  98170. /**
  98171. * Adds a floor mesh to be used for teleportation.
  98172. * @param floorMesh the mesh to be used for teleportation.
  98173. */
  98174. addFloorMesh(floorMesh: Mesh): void;
  98175. /**
  98176. * Removes a floor mesh from being used for teleportation.
  98177. * @param floorMesh the mesh to be removed.
  98178. */
  98179. removeFloorMesh(floorMesh: Mesh): void;
  98180. /**
  98181. * Enables interactions and teleportation using the VR controllers and gaze.
  98182. * @param vrTeleportationOptions options to modify teleportation behavior.
  98183. */
  98184. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  98185. private _onNewGamepadConnected;
  98186. private _tryEnableInteractionOnController;
  98187. private _onNewGamepadDisconnected;
  98188. private _enableInteractionOnController;
  98189. private _checkTeleportWithRay;
  98190. private _checkRotate;
  98191. private _checkTeleportBackwards;
  98192. private _enableTeleportationOnController;
  98193. private _createTeleportationCircles;
  98194. private _displayTeleportationTarget;
  98195. private _hideTeleportationTarget;
  98196. private _rotateCamera;
  98197. private _moveTeleportationSelectorTo;
  98198. private _workingVector;
  98199. private _workingQuaternion;
  98200. private _workingMatrix;
  98201. /**
  98202. * Teleports the users feet to the desired location
  98203. * @param location The location where the user's feet should be placed
  98204. */
  98205. teleportCamera(location: Vector3): void;
  98206. private _convertNormalToDirectionOfRay;
  98207. private _castRayAndSelectObject;
  98208. private _notifySelectedMeshUnselected;
  98209. /**
  98210. * Sets the color of the laser ray from the vr controllers.
  98211. * @param color new color for the ray.
  98212. */
  98213. changeLaserColor(color: Color3): void;
  98214. /**
  98215. * Sets the color of the ray from the vr headsets gaze.
  98216. * @param color new color for the ray.
  98217. */
  98218. changeGazeColor(color: Color3): void;
  98219. /**
  98220. * Exits VR and disposes of the vr experience helper
  98221. */
  98222. dispose(): void;
  98223. /**
  98224. * Gets the name of the VRExperienceHelper class
  98225. * @returns "VRExperienceHelper"
  98226. */
  98227. getClassName(): string;
  98228. }
  98229. }
  98230. declare module BABYLON {
  98231. /**
  98232. * Manages an XRSession
  98233. * @see https://doc.babylonjs.com/how_to/webxr
  98234. */
  98235. export class WebXRSessionManager implements IDisposable {
  98236. private scene;
  98237. /**
  98238. * Fires every time a new xrFrame arrives which can be used to update the camera
  98239. */
  98240. onXRFrameObservable: Observable<any>;
  98241. /**
  98242. * Fires when the xr session is ended either by the device or manually done
  98243. */
  98244. onXRSessionEnded: Observable<any>;
  98245. /** @hidden */
  98246. _xrSession: XRSession;
  98247. /** @hidden */
  98248. _frameOfReference: XRFrameOfReference;
  98249. /** @hidden */
  98250. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  98251. /** @hidden */
  98252. _currentXRFrame: Nullable<XRFrame>;
  98253. private _xrNavigator;
  98254. private _xrDevice;
  98255. private _tmpMatrix;
  98256. /**
  98257. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  98258. * @param scene The scene which the session should be created for
  98259. */
  98260. constructor(scene: Scene);
  98261. /**
  98262. * Initializes the manager
  98263. * After initialization enterXR can be called to start an XR session
  98264. * @returns Promise which resolves after it is initialized
  98265. */
  98266. initializeAsync(): Promise<void>;
  98267. /**
  98268. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  98269. * @param sessionCreationOptions xr options to create the session with
  98270. * @param frameOfReferenceType option to configure how the xr pose is expressed
  98271. * @returns Promise which resolves after it enters XR
  98272. */
  98273. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  98274. /**
  98275. * Stops the xrSession and restores the renderloop
  98276. * @returns Promise which resolves after it exits XR
  98277. */
  98278. exitXRAsync(): Promise<void>;
  98279. /**
  98280. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98281. * @param ray ray to cast into the environment
  98282. * @returns Promise which resolves with a collision point in the environment if it exists
  98283. */
  98284. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98285. /**
  98286. * Checks if a session would be supported for the creation options specified
  98287. * @param options creation options to check if they are supported
  98288. * @returns true if supported
  98289. */
  98290. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98291. /**
  98292. * @hidden
  98293. * Converts the render layer of xrSession to a render target
  98294. * @param session session to create render target for
  98295. * @param scene scene the new render target should be created for
  98296. */
  98297. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  98298. /**
  98299. * Disposes of the session manager
  98300. */
  98301. dispose(): void;
  98302. }
  98303. }
  98304. declare module BABYLON {
  98305. /**
  98306. * WebXR Camera which holds the views for the xrSession
  98307. * @see https://doc.babylonjs.com/how_to/webxr
  98308. */
  98309. export class WebXRCamera extends FreeCamera {
  98310. private static _TmpMatrix;
  98311. /**
  98312. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  98313. * @param name the name of the camera
  98314. * @param scene the scene to add the camera to
  98315. */
  98316. constructor(name: string, scene: Scene);
  98317. private _updateNumberOfRigCameras;
  98318. /** @hidden */
  98319. _updateForDualEyeDebugging(pupilDistance?: number): void;
  98320. /**
  98321. * Updates the cameras position from the current pose information of the XR session
  98322. * @param xrSessionManager the session containing pose information
  98323. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  98324. */
  98325. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  98326. }
  98327. }
  98328. declare module BABYLON {
  98329. /**
  98330. * States of the webXR experience
  98331. */
  98332. export enum WebXRState {
  98333. /**
  98334. * Transitioning to being in XR mode
  98335. */
  98336. ENTERING_XR = 0,
  98337. /**
  98338. * Transitioning to non XR mode
  98339. */
  98340. EXITING_XR = 1,
  98341. /**
  98342. * In XR mode and presenting
  98343. */
  98344. IN_XR = 2,
  98345. /**
  98346. * Not entered XR mode
  98347. */
  98348. NOT_IN_XR = 3
  98349. }
  98350. /**
  98351. * Helper class used to enable XR
  98352. * @see https://doc.babylonjs.com/how_to/webxr
  98353. */
  98354. export class WebXRExperienceHelper implements IDisposable {
  98355. private scene;
  98356. /**
  98357. * 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
  98358. */
  98359. container: AbstractMesh;
  98360. /**
  98361. * Camera used to render xr content
  98362. */
  98363. camera: WebXRCamera;
  98364. /**
  98365. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98366. */
  98367. state: WebXRState;
  98368. private _setState;
  98369. private static _TmpVector;
  98370. /**
  98371. * Fires when the state of the experience helper has changed
  98372. */
  98373. onStateChangedObservable: Observable<WebXRState>;
  98374. /** @hidden */
  98375. _sessionManager: WebXRSessionManager;
  98376. private _nonVRCamera;
  98377. private _originalSceneAutoClear;
  98378. private _supported;
  98379. /**
  98380. * Creates the experience helper
  98381. * @param scene the scene to attach the experience helper to
  98382. * @returns a promise for the experience helper
  98383. */
  98384. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98385. /**
  98386. * Creates a WebXRExperienceHelper
  98387. * @param scene The scene the helper should be created in
  98388. */
  98389. private constructor();
  98390. /**
  98391. * Exits XR mode and returns the scene to its original state
  98392. * @returns promise that resolves after xr mode has exited
  98393. */
  98394. exitXRAsync(): Promise<void>;
  98395. /**
  98396. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98397. * @param sessionCreationOptions options for the XR session
  98398. * @param frameOfReference frame of reference of the XR session
  98399. * @returns promise that resolves after xr mode has entered
  98400. */
  98401. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98402. /**
  98403. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98404. * @param ray ray to cast into the environment
  98405. * @returns Promise which resolves with a collision point in the environment if it exists
  98406. */
  98407. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98408. /**
  98409. * Updates the global position of the camera by moving the camera's container
  98410. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  98411. * @param position The desired global position of the camera
  98412. */
  98413. setPositionOfCameraUsingContainer(position: Vector3): void;
  98414. /**
  98415. * Rotates the xr camera by rotating the camera's container around the camera's position
  98416. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  98417. * @param rotation the desired quaternion rotation to apply to the camera
  98418. */
  98419. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  98420. /**
  98421. * Checks if the creation options are supported by the xr session
  98422. * @param options creation options
  98423. * @returns true if supported
  98424. */
  98425. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98426. /**
  98427. * Disposes of the experience helper
  98428. */
  98429. dispose(): void;
  98430. }
  98431. }
  98432. declare module BABYLON {
  98433. /**
  98434. * Button which can be used to enter a different mode of XR
  98435. */
  98436. export class WebXREnterExitUIButton {
  98437. /** button element */
  98438. element: HTMLElement;
  98439. /** XR initialization options for the button */
  98440. initializationOptions: XRSessionCreationOptions;
  98441. /**
  98442. * Creates a WebXREnterExitUIButton
  98443. * @param element button element
  98444. * @param initializationOptions XR initialization options for the button
  98445. */
  98446. constructor(
  98447. /** button element */
  98448. element: HTMLElement,
  98449. /** XR initialization options for the button */
  98450. initializationOptions: XRSessionCreationOptions);
  98451. /**
  98452. * Overwritable function which can be used to update the button's visuals when the state changes
  98453. * @param activeButton the current active button in the UI
  98454. */
  98455. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  98456. }
  98457. /**
  98458. * Options to create the webXR UI
  98459. */
  98460. export class WebXREnterExitUIOptions {
  98461. /**
  98462. * Context to enter xr with
  98463. */
  98464. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  98465. /**
  98466. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  98467. */
  98468. customButtons?: Array<WebXREnterExitUIButton>;
  98469. }
  98470. /**
  98471. * UI to allow the user to enter/exit XR mode
  98472. */
  98473. export class WebXREnterExitUI implements IDisposable {
  98474. private scene;
  98475. private _overlay;
  98476. private _buttons;
  98477. private _activeButton;
  98478. /**
  98479. * Fired every time the active button is changed.
  98480. *
  98481. * When xr is entered via a button that launches xr that button will be the callback parameter
  98482. *
  98483. * When exiting xr the callback parameter will be null)
  98484. */
  98485. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  98486. /**
  98487. * Creates UI to allow the user to enter/exit XR mode
  98488. * @param scene the scene to add the ui to
  98489. * @param helper the xr experience helper to enter/exit xr with
  98490. * @param options options to configure the UI
  98491. * @returns the created ui
  98492. */
  98493. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  98494. private constructor();
  98495. private _updateButtons;
  98496. /**
  98497. * Disposes of the object
  98498. */
  98499. dispose(): void;
  98500. }
  98501. }
  98502. declare module BABYLON {
  98503. /**
  98504. * Represents an XR input
  98505. */
  98506. export class WebXRController {
  98507. /**
  98508. * 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
  98509. */
  98510. grip?: AbstractMesh;
  98511. /**
  98512. * Pointer which can be used to select objects or attach a visible laser to
  98513. */
  98514. pointer: AbstractMesh;
  98515. /**
  98516. * Creates the controller
  98517. * @see https://doc.babylonjs.com/how_to/webxr
  98518. * @param scene the scene which the controller should be associated to
  98519. */
  98520. constructor(scene: Scene);
  98521. /**
  98522. * Disposes of the object
  98523. */
  98524. dispose(): void;
  98525. }
  98526. /**
  98527. * XR input used to track XR inputs such as controllers/rays
  98528. */
  98529. export class WebXRInput implements IDisposable {
  98530. private helper;
  98531. /**
  98532. * XR controllers being tracked
  98533. */
  98534. controllers: Array<WebXRController>;
  98535. private _tmpMatrix;
  98536. private _frameObserver;
  98537. /**
  98538. * Initializes the WebXRInput
  98539. * @param helper experience helper which the input should be created for
  98540. */
  98541. constructor(helper: WebXRExperienceHelper);
  98542. /**
  98543. * Disposes of the object
  98544. */
  98545. dispose(): void;
  98546. }
  98547. }
  98548. declare module BABYLON {
  98549. /**
  98550. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  98551. */
  98552. export class WebXRManagedOutputCanvas implements IDisposable {
  98553. private _canvas;
  98554. /**
  98555. * xrpresent context of the canvas which can be used to display/mirror xr content
  98556. */
  98557. canvasContext: Nullable<WebGLRenderingContext>;
  98558. /**
  98559. * Initializes the canvas to be added/removed upon entering/exiting xr
  98560. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  98561. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  98562. */
  98563. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  98564. /**
  98565. * Disposes of the object
  98566. */
  98567. dispose(): void;
  98568. private _setManagedOutputCanvas;
  98569. private _addCanvas;
  98570. private _removeCanvas;
  98571. }
  98572. }
  98573. declare module BABYLON {
  98574. /**
  98575. * Contains an array of blocks representing the octree
  98576. */
  98577. export interface IOctreeContainer<T> {
  98578. /**
  98579. * Blocks within the octree
  98580. */
  98581. blocks: Array<OctreeBlock<T>>;
  98582. }
  98583. /**
  98584. * Class used to store a cell in an octree
  98585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98586. */
  98587. export class OctreeBlock<T> {
  98588. /**
  98589. * Gets the content of the current block
  98590. */
  98591. entries: T[];
  98592. /**
  98593. * Gets the list of block children
  98594. */
  98595. blocks: Array<OctreeBlock<T>>;
  98596. private _depth;
  98597. private _maxDepth;
  98598. private _capacity;
  98599. private _minPoint;
  98600. private _maxPoint;
  98601. private _boundingVectors;
  98602. private _creationFunc;
  98603. /**
  98604. * Creates a new block
  98605. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  98606. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  98607. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98608. * @param depth defines the current depth of this block in the octree
  98609. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  98610. * @param creationFunc defines a callback to call when an element is added to the block
  98611. */
  98612. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  98613. /**
  98614. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98615. */
  98616. readonly capacity: number;
  98617. /**
  98618. * Gets the minimum vector (in world space) of the block's bounding box
  98619. */
  98620. readonly minPoint: Vector3;
  98621. /**
  98622. * Gets the maximum vector (in world space) of the block's bounding box
  98623. */
  98624. readonly maxPoint: Vector3;
  98625. /**
  98626. * Add a new element to this block
  98627. * @param entry defines the element to add
  98628. */
  98629. addEntry(entry: T): void;
  98630. /**
  98631. * Remove an element from this block
  98632. * @param entry defines the element to remove
  98633. */
  98634. removeEntry(entry: T): void;
  98635. /**
  98636. * Add an array of elements to this block
  98637. * @param entries defines the array of elements to add
  98638. */
  98639. addEntries(entries: T[]): void;
  98640. /**
  98641. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  98642. * @param frustumPlanes defines the frustum planes to test
  98643. * @param selection defines the array to store current content if selection is positive
  98644. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98645. */
  98646. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98647. /**
  98648. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  98649. * @param sphereCenter defines the bounding sphere center
  98650. * @param sphereRadius defines the bounding sphere radius
  98651. * @param selection defines the array to store current content if selection is positive
  98652. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98653. */
  98654. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98655. /**
  98656. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  98657. * @param ray defines the ray to test with
  98658. * @param selection defines the array to store current content if selection is positive
  98659. */
  98660. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  98661. /**
  98662. * Subdivide the content into child blocks (this block will then be empty)
  98663. */
  98664. createInnerBlocks(): void;
  98665. /**
  98666. * @hidden
  98667. */
  98668. 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;
  98669. }
  98670. }
  98671. declare module BABYLON {
  98672. /**
  98673. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  98674. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98675. */
  98676. export class Octree<T> {
  98677. /** 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.) */
  98678. maxDepth: number;
  98679. /**
  98680. * Blocks within the octree containing objects
  98681. */
  98682. blocks: Array<OctreeBlock<T>>;
  98683. /**
  98684. * Content stored in the octree
  98685. */
  98686. dynamicContent: T[];
  98687. private _maxBlockCapacity;
  98688. private _selectionContent;
  98689. private _creationFunc;
  98690. /**
  98691. * Creates a octree
  98692. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98693. * @param creationFunc function to be used to instatiate the octree
  98694. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  98695. * @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.)
  98696. */
  98697. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  98698. /** 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.) */
  98699. maxDepth?: number);
  98700. /**
  98701. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  98702. * @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);
  98703. * @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);
  98704. * @param entries meshes to be added to the octree blocks
  98705. */
  98706. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  98707. /**
  98708. * Adds a mesh to the octree
  98709. * @param entry Mesh to add to the octree
  98710. */
  98711. addMesh(entry: T): void;
  98712. /**
  98713. * Remove an element from the octree
  98714. * @param entry defines the element to remove
  98715. */
  98716. removeMesh(entry: T): void;
  98717. /**
  98718. * Selects an array of meshes within the frustum
  98719. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  98720. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  98721. * @returns array of meshes within the frustum
  98722. */
  98723. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  98724. /**
  98725. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  98726. * @param sphereCenter defines the bounding sphere center
  98727. * @param sphereRadius defines the bounding sphere radius
  98728. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98729. * @returns an array of objects that intersect the sphere
  98730. */
  98731. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  98732. /**
  98733. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  98734. * @param ray defines the ray to test with
  98735. * @returns array of intersected objects
  98736. */
  98737. intersectsRay(ray: Ray): SmartArray<T>;
  98738. /**
  98739. * Adds a mesh into the octree block if it intersects the block
  98740. */
  98741. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  98742. /**
  98743. * Adds a submesh into the octree block if it intersects the block
  98744. */
  98745. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  98746. }
  98747. }
  98748. declare module BABYLON {
  98749. interface Scene {
  98750. /**
  98751. * @hidden
  98752. * Backing Filed
  98753. */
  98754. _selectionOctree: Octree<AbstractMesh>;
  98755. /**
  98756. * Gets the octree used to boost mesh selection (picking)
  98757. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98758. */
  98759. selectionOctree: Octree<AbstractMesh>;
  98760. /**
  98761. * Creates or updates the octree used to boost selection (picking)
  98762. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98763. * @param maxCapacity defines the maximum capacity per leaf
  98764. * @param maxDepth defines the maximum depth of the octree
  98765. * @returns an octree of AbstractMesh
  98766. */
  98767. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  98768. }
  98769. interface AbstractMesh {
  98770. /**
  98771. * @hidden
  98772. * Backing Field
  98773. */
  98774. _submeshesOctree: Octree<SubMesh>;
  98775. /**
  98776. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  98777. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98778. * @param maxCapacity defines the maximum size of each block (64 by default)
  98779. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  98780. * @returns the new octree
  98781. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  98782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98783. */
  98784. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  98785. }
  98786. /**
  98787. * Defines the octree scene component responsible to manage any octrees
  98788. * in a given scene.
  98789. */
  98790. export class OctreeSceneComponent {
  98791. /**
  98792. * The component name helpfull to identify the component in the list of scene components.
  98793. */
  98794. readonly name: string;
  98795. /**
  98796. * The scene the component belongs to.
  98797. */
  98798. scene: Scene;
  98799. /**
  98800. * Indicates if the meshes have been checked to make sure they are isEnabled()
  98801. */
  98802. readonly checksIsEnabled: boolean;
  98803. /**
  98804. * Creates a new instance of the component for the given scene
  98805. * @param scene Defines the scene to register the component in
  98806. */
  98807. constructor(scene: Scene);
  98808. /**
  98809. * Registers the component in a given scene
  98810. */
  98811. register(): void;
  98812. /**
  98813. * Return the list of active meshes
  98814. * @returns the list of active meshes
  98815. */
  98816. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98817. /**
  98818. * Return the list of active sub meshes
  98819. * @param mesh The mesh to get the candidates sub meshes from
  98820. * @returns the list of active sub meshes
  98821. */
  98822. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98823. private _tempRay;
  98824. /**
  98825. * Return the list of sub meshes intersecting with a given local ray
  98826. * @param mesh defines the mesh to find the submesh for
  98827. * @param localRay defines the ray in local space
  98828. * @returns the list of intersecting sub meshes
  98829. */
  98830. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  98831. /**
  98832. * Return the list of sub meshes colliding with a collider
  98833. * @param mesh defines the mesh to find the submesh for
  98834. * @param collider defines the collider to evaluate the collision against
  98835. * @returns the list of colliding sub meshes
  98836. */
  98837. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  98838. /**
  98839. * Rebuilds the elements related to this component in case of
  98840. * context lost for instance.
  98841. */
  98842. rebuild(): void;
  98843. /**
  98844. * Disposes the component and the associated ressources.
  98845. */
  98846. dispose(): void;
  98847. }
  98848. }
  98849. declare module BABYLON {
  98850. /**
  98851. * Class containing static functions to help procedurally build meshes
  98852. */
  98853. export class LinesBuilder {
  98854. /**
  98855. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  98856. * * 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
  98857. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  98858. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  98859. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  98860. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  98861. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  98862. * * 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
  98863. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  98864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  98866. * @param name defines the name of the new line system
  98867. * @param options defines the options used to create the line system
  98868. * @param scene defines the hosting scene
  98869. * @returns a new line system mesh
  98870. */
  98871. static CreateLineSystem(name: string, options: {
  98872. lines: Vector3[][];
  98873. updatable?: boolean;
  98874. instance?: Nullable<LinesMesh>;
  98875. colors?: Nullable<Color4[][]>;
  98876. useVertexAlpha?: boolean;
  98877. }, scene: Nullable<Scene>): LinesMesh;
  98878. /**
  98879. * Creates a line mesh
  98880. * 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
  98881. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98882. * * The parameter `points` is an array successive Vector3
  98883. * * 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
  98884. * * The optional parameter `colors` is an array of successive Color4, one per line point
  98885. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  98886. * * When updating an instance, remember that only point positions can change, not the number of points
  98887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  98889. * @param name defines the name of the new line system
  98890. * @param options defines the options used to create the line system
  98891. * @param scene defines the hosting scene
  98892. * @returns a new line mesh
  98893. */
  98894. static CreateLines(name: string, options: {
  98895. points: Vector3[];
  98896. updatable?: boolean;
  98897. instance?: Nullable<LinesMesh>;
  98898. colors?: Color4[];
  98899. useVertexAlpha?: boolean;
  98900. }, scene?: Nullable<Scene>): LinesMesh;
  98901. /**
  98902. * Creates a dashed line mesh
  98903. * * 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
  98904. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98905. * * The parameter `points` is an array successive Vector3
  98906. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  98907. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  98908. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98909. * * 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
  98910. * * When updating an instance, remember that only point positions can change, not the number of points
  98911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98912. * @param name defines the name of the mesh
  98913. * @param options defines the options used to create the mesh
  98914. * @param scene defines the hosting scene
  98915. * @returns the dashed line mesh
  98916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  98917. */
  98918. static CreateDashedLines(name: string, options: {
  98919. points: Vector3[];
  98920. dashSize?: number;
  98921. gapSize?: number;
  98922. dashNb?: number;
  98923. updatable?: boolean;
  98924. instance?: LinesMesh;
  98925. }, scene?: Nullable<Scene>): LinesMesh;
  98926. }
  98927. }
  98928. declare module BABYLON {
  98929. /**
  98930. * Renders a layer on top of an existing scene
  98931. */
  98932. export class UtilityLayerRenderer implements IDisposable {
  98933. /** the original scene that will be rendered on top of */
  98934. originalScene: Scene;
  98935. private _pointerCaptures;
  98936. private _lastPointerEvents;
  98937. private static _DefaultUtilityLayer;
  98938. private static _DefaultKeepDepthUtilityLayer;
  98939. /**
  98940. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  98941. */
  98942. pickUtilitySceneFirst: boolean;
  98943. /**
  98944. * 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)
  98945. */
  98946. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  98947. /**
  98948. * 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)
  98949. */
  98950. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  98951. /**
  98952. * The scene that is rendered on top of the original scene
  98953. */
  98954. utilityLayerScene: Scene;
  98955. /**
  98956. * If the utility layer should automatically be rendered on top of existing scene
  98957. */
  98958. shouldRender: boolean;
  98959. /**
  98960. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  98961. */
  98962. onlyCheckPointerDownEvents: boolean;
  98963. /**
  98964. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  98965. */
  98966. processAllEvents: boolean;
  98967. /**
  98968. * Observable raised when the pointer move from the utility layer scene to the main scene
  98969. */
  98970. onPointerOutObservable: Observable<number>;
  98971. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  98972. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  98973. private _afterRenderObserver;
  98974. private _sceneDisposeObserver;
  98975. private _originalPointerObserver;
  98976. /**
  98977. * Instantiates a UtilityLayerRenderer
  98978. * @param originalScene the original scene that will be rendered on top of
  98979. * @param handleEvents boolean indicating if the utility layer should handle events
  98980. */
  98981. constructor(
  98982. /** the original scene that will be rendered on top of */
  98983. originalScene: Scene, handleEvents?: boolean);
  98984. private _notifyObservers;
  98985. /**
  98986. * Renders the utility layers scene on top of the original scene
  98987. */
  98988. render(): void;
  98989. /**
  98990. * Disposes of the renderer
  98991. */
  98992. dispose(): void;
  98993. private _updateCamera;
  98994. }
  98995. }
  98996. declare module BABYLON {
  98997. /**
  98998. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  98999. */
  99000. export class Gizmo implements IDisposable {
  99001. /** The utility layer the gizmo will be added to */
  99002. gizmoLayer: UtilityLayerRenderer;
  99003. /**
  99004. * The root mesh of the gizmo
  99005. */
  99006. _rootMesh: Mesh;
  99007. private _attachedMesh;
  99008. /**
  99009. * Ratio for the scale of the gizmo (Default: 1)
  99010. */
  99011. scaleRatio: number;
  99012. private _tmpMatrix;
  99013. /**
  99014. * If a custom mesh has been set (Default: false)
  99015. */
  99016. protected _customMeshSet: boolean;
  99017. /**
  99018. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99019. * * When set, interactions will be enabled
  99020. */
  99021. attachedMesh: Nullable<AbstractMesh>;
  99022. /**
  99023. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99024. * @param mesh The mesh to replace the default mesh of the gizmo
  99025. */
  99026. setCustomMesh(mesh: Mesh): void;
  99027. /**
  99028. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99029. */
  99030. updateGizmoRotationToMatchAttachedMesh: boolean;
  99031. /**
  99032. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99033. */
  99034. updateGizmoPositionToMatchAttachedMesh: boolean;
  99035. /**
  99036. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99037. */
  99038. protected _updateScale: boolean;
  99039. protected _interactionsEnabled: boolean;
  99040. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99041. private _beforeRenderObserver;
  99042. /**
  99043. * Creates a gizmo
  99044. * @param gizmoLayer The utility layer the gizmo will be added to
  99045. */
  99046. constructor(
  99047. /** The utility layer the gizmo will be added to */
  99048. gizmoLayer?: UtilityLayerRenderer);
  99049. private _tempVector;
  99050. /**
  99051. * @hidden
  99052. * Updates the gizmo to match the attached mesh's position/rotation
  99053. */
  99054. protected _update(): void;
  99055. /**
  99056. * Disposes of the gizmo
  99057. */
  99058. dispose(): void;
  99059. }
  99060. }
  99061. declare module BABYLON {
  99062. /**
  99063. * Single axis drag gizmo
  99064. */
  99065. export class AxisDragGizmo extends Gizmo {
  99066. /**
  99067. * Drag behavior responsible for the gizmos dragging interactions
  99068. */
  99069. dragBehavior: PointerDragBehavior;
  99070. private _pointerObserver;
  99071. /**
  99072. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99073. */
  99074. snapDistance: number;
  99075. /**
  99076. * Event that fires each time the gizmo snaps to a new location.
  99077. * * snapDistance is the the change in distance
  99078. */
  99079. onSnapObservable: Observable<{
  99080. snapDistance: number;
  99081. }>;
  99082. /** @hidden */
  99083. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99084. /** @hidden */
  99085. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99086. /**
  99087. * Creates an AxisDragGizmo
  99088. * @param gizmoLayer The utility layer the gizmo will be added to
  99089. * @param dragAxis The axis which the gizmo will be able to drag on
  99090. * @param color The color of the gizmo
  99091. */
  99092. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99093. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99094. /**
  99095. * Disposes of the gizmo
  99096. */
  99097. dispose(): void;
  99098. }
  99099. }
  99100. declare module BABYLON.Debug {
  99101. /**
  99102. * The Axes viewer will show 3 axes in a specific point in space
  99103. */
  99104. export class AxesViewer {
  99105. private _xAxis;
  99106. private _yAxis;
  99107. private _zAxis;
  99108. private _scaleLinesFactor;
  99109. private _instanced;
  99110. /**
  99111. * Gets the hosting scene
  99112. */
  99113. scene: Scene;
  99114. /**
  99115. * Gets or sets a number used to scale line length
  99116. */
  99117. scaleLines: number;
  99118. /** Gets the node hierarchy used to render x-axis */
  99119. readonly xAxis: TransformNode;
  99120. /** Gets the node hierarchy used to render y-axis */
  99121. readonly yAxis: TransformNode;
  99122. /** Gets the node hierarchy used to render z-axis */
  99123. readonly zAxis: TransformNode;
  99124. /**
  99125. * Creates a new AxesViewer
  99126. * @param scene defines the hosting scene
  99127. * @param scaleLines defines a number used to scale line length (1 by default)
  99128. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99129. * @param xAxis defines the node hierarchy used to render the x-axis
  99130. * @param yAxis defines the node hierarchy used to render the y-axis
  99131. * @param zAxis defines the node hierarchy used to render the z-axis
  99132. */
  99133. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99134. /**
  99135. * Force the viewer to update
  99136. * @param position defines the position of the viewer
  99137. * @param xaxis defines the x axis of the viewer
  99138. * @param yaxis defines the y axis of the viewer
  99139. * @param zaxis defines the z axis of the viewer
  99140. */
  99141. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99142. /**
  99143. * Creates an instance of this axes viewer.
  99144. * @returns a new axes viewer with instanced meshes
  99145. */
  99146. createInstance(): AxesViewer;
  99147. /** Releases resources */
  99148. dispose(): void;
  99149. private static _SetRenderingGroupId;
  99150. }
  99151. }
  99152. declare module BABYLON.Debug {
  99153. /**
  99154. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99155. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99156. */
  99157. export class BoneAxesViewer extends AxesViewer {
  99158. /**
  99159. * Gets or sets the target mesh where to display the axes viewer
  99160. */
  99161. mesh: Nullable<Mesh>;
  99162. /**
  99163. * Gets or sets the target bone where to display the axes viewer
  99164. */
  99165. bone: Nullable<Bone>;
  99166. /** Gets current position */
  99167. pos: Vector3;
  99168. /** Gets direction of X axis */
  99169. xaxis: Vector3;
  99170. /** Gets direction of Y axis */
  99171. yaxis: Vector3;
  99172. /** Gets direction of Z axis */
  99173. zaxis: Vector3;
  99174. /**
  99175. * Creates a new BoneAxesViewer
  99176. * @param scene defines the hosting scene
  99177. * @param bone defines the target bone
  99178. * @param mesh defines the target mesh
  99179. * @param scaleLines defines a scaling factor for line length (1 by default)
  99180. */
  99181. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  99182. /**
  99183. * Force the viewer to update
  99184. */
  99185. update(): void;
  99186. /** Releases resources */
  99187. dispose(): void;
  99188. }
  99189. }
  99190. declare module BABYLON {
  99191. /**
  99192. * Interface used to define scene explorer extensibility option
  99193. */
  99194. export interface IExplorerExtensibilityOption {
  99195. /**
  99196. * Define the option label
  99197. */
  99198. label: string;
  99199. /**
  99200. * Defines the action to execute on click
  99201. */
  99202. action: (entity: any) => void;
  99203. }
  99204. /**
  99205. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  99206. */
  99207. export interface IExplorerExtensibilityGroup {
  99208. /**
  99209. * Defines a predicate to test if a given type mut be extended
  99210. */
  99211. predicate: (entity: any) => boolean;
  99212. /**
  99213. * Gets the list of options added to a type
  99214. */
  99215. entries: IExplorerExtensibilityOption[];
  99216. }
  99217. /**
  99218. * Interface used to define the options to use to create the Inspector
  99219. */
  99220. export interface IInspectorOptions {
  99221. /**
  99222. * Display in overlay mode (default: false)
  99223. */
  99224. overlay?: boolean;
  99225. /**
  99226. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  99227. */
  99228. globalRoot?: HTMLElement;
  99229. /**
  99230. * Display the Scene explorer
  99231. */
  99232. showExplorer?: boolean;
  99233. /**
  99234. * Display the property inspector
  99235. */
  99236. showInspector?: boolean;
  99237. /**
  99238. * Display in embed mode (both panes on the right)
  99239. */
  99240. embedMode?: boolean;
  99241. /**
  99242. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  99243. */
  99244. handleResize?: boolean;
  99245. /**
  99246. * Allow the panes to popup (default: true)
  99247. */
  99248. enablePopup?: boolean;
  99249. /**
  99250. * Allow the panes to be closed by users (default: true)
  99251. */
  99252. enableClose?: boolean;
  99253. /**
  99254. * Optional list of extensibility entries
  99255. */
  99256. explorerExtensibility?: IExplorerExtensibilityGroup[];
  99257. /**
  99258. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  99259. */
  99260. inspectorURL?: string;
  99261. }
  99262. interface Scene {
  99263. /**
  99264. * @hidden
  99265. * Backing field
  99266. */
  99267. _debugLayer: DebugLayer;
  99268. /**
  99269. * Gets the debug layer (aka Inspector) associated with the scene
  99270. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99271. */
  99272. debugLayer: DebugLayer;
  99273. }
  99274. /**
  99275. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99276. * what is happening in your scene
  99277. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99278. */
  99279. export class DebugLayer {
  99280. /**
  99281. * Define the url to get the inspector script from.
  99282. * By default it uses the babylonjs CDN.
  99283. * @ignoreNaming
  99284. */
  99285. static InspectorURL: string;
  99286. private _scene;
  99287. private BJSINSPECTOR;
  99288. /**
  99289. * Observable triggered when a property is changed through the inspector.
  99290. */
  99291. onPropertyChangedObservable: Observable<{
  99292. object: any;
  99293. property: string;
  99294. value: any;
  99295. initialValue: any;
  99296. }>;
  99297. /**
  99298. * Instantiates a new debug layer.
  99299. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99300. * what is happening in your scene
  99301. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99302. * @param scene Defines the scene to inspect
  99303. */
  99304. constructor(scene: Scene);
  99305. /** Creates the inspector window. */
  99306. private _createInspector;
  99307. /**
  99308. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  99309. * @param entity defines the entity to select
  99310. * @param lineContainerTitle defines the specific block to highlight
  99311. */
  99312. select(entity: any, lineContainerTitle?: string): void;
  99313. /** Get the inspector from bundle or global */
  99314. private _getGlobalInspector;
  99315. /**
  99316. * Get if the inspector is visible or not.
  99317. * @returns true if visible otherwise, false
  99318. */
  99319. isVisible(): boolean;
  99320. /**
  99321. * Hide the inspector and close its window.
  99322. */
  99323. hide(): void;
  99324. /**
  99325. * Launch the debugLayer.
  99326. * @param config Define the configuration of the inspector
  99327. * @return a promise fulfilled when the debug layer is visible
  99328. */
  99329. show(config?: IInspectorOptions): Promise<DebugLayer>;
  99330. }
  99331. }
  99332. declare module BABYLON {
  99333. /**
  99334. * Class containing static functions to help procedurally build meshes
  99335. */
  99336. export class BoxBuilder {
  99337. /**
  99338. * Creates a box mesh
  99339. * * The parameter `size` sets the size (float) of each box side (default 1)
  99340. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  99341. * * 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)
  99342. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  99343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99346. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  99347. * @param name defines the name of the mesh
  99348. * @param options defines the options used to create the mesh
  99349. * @param scene defines the hosting scene
  99350. * @returns the box mesh
  99351. */
  99352. static CreateBox(name: string, options: {
  99353. size?: number;
  99354. width?: number;
  99355. height?: number;
  99356. depth?: number;
  99357. faceUV?: Vector4[];
  99358. faceColors?: Color4[];
  99359. sideOrientation?: number;
  99360. frontUVs?: Vector4;
  99361. backUVs?: Vector4;
  99362. updatable?: boolean;
  99363. }, scene?: Nullable<Scene>): Mesh;
  99364. }
  99365. }
  99366. declare module BABYLON {
  99367. /**
  99368. * Class containing static functions to help procedurally build meshes
  99369. */
  99370. export class SphereBuilder {
  99371. /**
  99372. * Creates a sphere mesh
  99373. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99374. * * 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`)
  99375. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99376. * * 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
  99377. * * 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)
  99378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99381. * @param name defines the name of the mesh
  99382. * @param options defines the options used to create the mesh
  99383. * @param scene defines the hosting scene
  99384. * @returns the sphere mesh
  99385. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99386. */
  99387. static CreateSphere(name: string, options: {
  99388. segments?: number;
  99389. diameter?: number;
  99390. diameterX?: number;
  99391. diameterY?: number;
  99392. diameterZ?: number;
  99393. arc?: number;
  99394. slice?: number;
  99395. sideOrientation?: number;
  99396. frontUVs?: Vector4;
  99397. backUVs?: Vector4;
  99398. updatable?: boolean;
  99399. }, scene: any): Mesh;
  99400. }
  99401. }
  99402. declare module BABYLON.Debug {
  99403. /**
  99404. * Used to show the physics impostor around the specific mesh
  99405. */
  99406. export class PhysicsViewer {
  99407. /** @hidden */
  99408. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99409. /** @hidden */
  99410. protected _meshes: Array<Nullable<AbstractMesh>>;
  99411. /** @hidden */
  99412. protected _scene: Nullable<Scene>;
  99413. /** @hidden */
  99414. protected _numMeshes: number;
  99415. /** @hidden */
  99416. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99417. private _renderFunction;
  99418. private _utilityLayer;
  99419. private _debugBoxMesh;
  99420. private _debugSphereMesh;
  99421. private _debugMaterial;
  99422. /**
  99423. * Creates a new PhysicsViewer
  99424. * @param scene defines the hosting scene
  99425. */
  99426. constructor(scene: Scene);
  99427. /** @hidden */
  99428. protected _updateDebugMeshes(): void;
  99429. /**
  99430. * Renders a specified physic impostor
  99431. * @param impostor defines the impostor to render
  99432. * @returns the new debug mesh used to render the impostor
  99433. */
  99434. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  99435. /**
  99436. * Hides a specified physic impostor
  99437. * @param impostor defines the impostor to hide
  99438. */
  99439. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99440. private _getDebugMaterial;
  99441. private _getDebugBoxMesh;
  99442. private _getDebugSphereMesh;
  99443. private _getDebugMesh;
  99444. /** Releases all resources */
  99445. dispose(): void;
  99446. }
  99447. }
  99448. declare module BABYLON {
  99449. /**
  99450. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99451. * in order to better appreciate the issue one might have.
  99452. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99453. */
  99454. export class RayHelper {
  99455. /**
  99456. * Defines the ray we are currently tryin to visualize.
  99457. */
  99458. ray: Nullable<Ray>;
  99459. private _renderPoints;
  99460. private _renderLine;
  99461. private _renderFunction;
  99462. private _scene;
  99463. private _updateToMeshFunction;
  99464. private _attachedToMesh;
  99465. private _meshSpaceDirection;
  99466. private _meshSpaceOrigin;
  99467. /**
  99468. * Helper function to create a colored helper in a scene in one line.
  99469. * @param ray Defines the ray we are currently tryin to visualize
  99470. * @param scene Defines the scene the ray is used in
  99471. * @param color Defines the color we want to see the ray in
  99472. * @returns The newly created ray helper.
  99473. */
  99474. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  99475. /**
  99476. * Instantiate a new ray helper.
  99477. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99478. * in order to better appreciate the issue one might have.
  99479. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99480. * @param ray Defines the ray we are currently tryin to visualize
  99481. */
  99482. constructor(ray: Ray);
  99483. /**
  99484. * Shows the ray we are willing to debug.
  99485. * @param scene Defines the scene the ray needs to be rendered in
  99486. * @param color Defines the color the ray needs to be rendered in
  99487. */
  99488. show(scene: Scene, color?: Color3): void;
  99489. /**
  99490. * Hides the ray we are debugging.
  99491. */
  99492. hide(): void;
  99493. private _render;
  99494. /**
  99495. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  99496. * @param mesh Defines the mesh we want the helper attached to
  99497. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  99498. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  99499. * @param length Defines the length of the ray
  99500. */
  99501. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  99502. /**
  99503. * Detach the ray helper from the mesh it has previously been attached to.
  99504. */
  99505. detachFromMesh(): void;
  99506. private _updateToMesh;
  99507. /**
  99508. * Dispose the helper and release its associated resources.
  99509. */
  99510. dispose(): void;
  99511. }
  99512. }
  99513. declare module BABYLON.Debug {
  99514. /**
  99515. * Class used to render a debug view of a given skeleton
  99516. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  99517. */
  99518. export class SkeletonViewer {
  99519. /** defines the skeleton to render */
  99520. skeleton: Skeleton;
  99521. /** defines the mesh attached to the skeleton */
  99522. mesh: AbstractMesh;
  99523. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99524. autoUpdateBonesMatrices: boolean;
  99525. /** defines the rendering group id to use with the viewer */
  99526. renderingGroupId: number;
  99527. /** Gets or sets the color used to render the skeleton */
  99528. color: Color3;
  99529. private _scene;
  99530. private _debugLines;
  99531. private _debugMesh;
  99532. private _isEnabled;
  99533. private _renderFunction;
  99534. private _utilityLayer;
  99535. /**
  99536. * Returns the mesh used to render the bones
  99537. */
  99538. readonly debugMesh: Nullable<LinesMesh>;
  99539. /**
  99540. * Creates a new SkeletonViewer
  99541. * @param skeleton defines the skeleton to render
  99542. * @param mesh defines the mesh attached to the skeleton
  99543. * @param scene defines the hosting scene
  99544. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  99545. * @param renderingGroupId defines the rendering group id to use with the viewer
  99546. */
  99547. constructor(
  99548. /** defines the skeleton to render */
  99549. skeleton: Skeleton,
  99550. /** defines the mesh attached to the skeleton */
  99551. mesh: AbstractMesh, scene: Scene,
  99552. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99553. autoUpdateBonesMatrices?: boolean,
  99554. /** defines the rendering group id to use with the viewer */
  99555. renderingGroupId?: number);
  99556. /** Gets or sets a boolean indicating if the viewer is enabled */
  99557. isEnabled: boolean;
  99558. private _getBonePosition;
  99559. private _getLinesForBonesWithLength;
  99560. private _getLinesForBonesNoLength;
  99561. /** Update the viewer to sync with current skeleton state */
  99562. update(): void;
  99563. /** Release associated resources */
  99564. dispose(): void;
  99565. }
  99566. }
  99567. declare module BABYLON {
  99568. /**
  99569. * Options to create the null engine
  99570. */
  99571. export class NullEngineOptions {
  99572. /**
  99573. * Render width (Default: 512)
  99574. */
  99575. renderWidth: number;
  99576. /**
  99577. * Render height (Default: 256)
  99578. */
  99579. renderHeight: number;
  99580. /**
  99581. * Texture size (Default: 512)
  99582. */
  99583. textureSize: number;
  99584. /**
  99585. * If delta time between frames should be constant
  99586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99587. */
  99588. deterministicLockstep: boolean;
  99589. /**
  99590. * Maximum about of steps between frames (Default: 4)
  99591. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99592. */
  99593. lockstepMaxSteps: number;
  99594. }
  99595. /**
  99596. * The null engine class provides support for headless version of babylon.js.
  99597. * This can be used in server side scenario or for testing purposes
  99598. */
  99599. export class NullEngine extends Engine {
  99600. private _options;
  99601. /**
  99602. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99603. */
  99604. isDeterministicLockStep(): boolean;
  99605. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  99606. getLockstepMaxSteps(): number;
  99607. /**
  99608. * Sets hardware scaling, used to save performance if needed
  99609. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99610. */
  99611. getHardwareScalingLevel(): number;
  99612. constructor(options?: NullEngineOptions);
  99613. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99614. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  99615. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99616. getRenderWidth(useScreen?: boolean): number;
  99617. getRenderHeight(useScreen?: boolean): number;
  99618. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  99619. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  99620. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  99621. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  99622. bindSamplers(effect: Effect): void;
  99623. enableEffect(effect: Effect): void;
  99624. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99625. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  99626. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  99627. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  99628. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  99629. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  99630. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  99631. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  99632. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  99633. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  99634. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  99635. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  99636. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  99637. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  99638. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  99639. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99640. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99641. setFloat(uniform: WebGLUniformLocation, value: number): void;
  99642. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  99643. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  99644. setBool(uniform: WebGLUniformLocation, bool: number): void;
  99645. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  99646. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  99647. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  99648. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99649. bindBuffers(vertexBuffers: {
  99650. [key: string]: VertexBuffer;
  99651. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  99652. wipeCaches(bruteForce?: boolean): void;
  99653. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99654. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99655. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99656. /** @hidden */
  99657. _createTexture(): WebGLTexture;
  99658. /** @hidden */
  99659. _releaseTexture(texture: InternalTexture): void;
  99660. 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;
  99661. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  99662. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  99663. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  99664. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99665. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99666. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  99667. areAllEffectsReady(): boolean;
  99668. /**
  99669. * @hidden
  99670. * Get the current error code of the webGL context
  99671. * @returns the error code
  99672. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99673. */
  99674. getError(): number;
  99675. /** @hidden */
  99676. _getUnpackAlignement(): number;
  99677. /** @hidden */
  99678. _unpackFlipY(value: boolean): void;
  99679. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  99680. /**
  99681. * Updates a dynamic vertex buffer.
  99682. * @param vertexBuffer the vertex buffer to update
  99683. * @param data the data used to update the vertex buffer
  99684. * @param byteOffset the byte offset of the data (optional)
  99685. * @param byteLength the byte length of the data (optional)
  99686. */
  99687. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  99688. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  99689. /** @hidden */
  99690. _bindTexture(channel: number, texture: InternalTexture): void;
  99691. /** @hidden */
  99692. _releaseBuffer(buffer: WebGLBuffer): boolean;
  99693. releaseEffects(): void;
  99694. displayLoadingUI(): void;
  99695. hideLoadingUI(): void;
  99696. /** @hidden */
  99697. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99698. /** @hidden */
  99699. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99700. /** @hidden */
  99701. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99702. /** @hidden */
  99703. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  99704. }
  99705. }
  99706. declare module BABYLON {
  99707. /** @hidden */
  99708. export class _OcclusionDataStorage {
  99709. /** @hidden */
  99710. occlusionInternalRetryCounter: number;
  99711. /** @hidden */
  99712. isOcclusionQueryInProgress: boolean;
  99713. /** @hidden */
  99714. isOccluded: boolean;
  99715. /** @hidden */
  99716. occlusionRetryCount: number;
  99717. /** @hidden */
  99718. occlusionType: number;
  99719. /** @hidden */
  99720. occlusionQueryAlgorithmType: number;
  99721. }
  99722. interface Engine {
  99723. /**
  99724. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  99725. * @return the new query
  99726. */
  99727. createQuery(): WebGLQuery;
  99728. /**
  99729. * Delete and release a webGL query
  99730. * @param query defines the query to delete
  99731. * @return the current engine
  99732. */
  99733. deleteQuery(query: WebGLQuery): Engine;
  99734. /**
  99735. * Check if a given query has resolved and got its value
  99736. * @param query defines the query to check
  99737. * @returns true if the query got its value
  99738. */
  99739. isQueryResultAvailable(query: WebGLQuery): boolean;
  99740. /**
  99741. * Gets the value of a given query
  99742. * @param query defines the query to check
  99743. * @returns the value of the query
  99744. */
  99745. getQueryResult(query: WebGLQuery): number;
  99746. /**
  99747. * Initiates an occlusion query
  99748. * @param algorithmType defines the algorithm to use
  99749. * @param query defines the query to use
  99750. * @returns the current engine
  99751. * @see http://doc.babylonjs.com/features/occlusionquery
  99752. */
  99753. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  99754. /**
  99755. * Ends an occlusion query
  99756. * @see http://doc.babylonjs.com/features/occlusionquery
  99757. * @param algorithmType defines the algorithm to use
  99758. * @returns the current engine
  99759. */
  99760. endOcclusionQuery(algorithmType: number): Engine;
  99761. /**
  99762. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  99763. * Please note that only one query can be issued at a time
  99764. * @returns a time token used to track the time span
  99765. */
  99766. startTimeQuery(): Nullable<_TimeToken>;
  99767. /**
  99768. * Ends a time query
  99769. * @param token defines the token used to measure the time span
  99770. * @returns the time spent (in ns)
  99771. */
  99772. endTimeQuery(token: _TimeToken): int;
  99773. /** @hidden */
  99774. _currentNonTimestampToken: Nullable<_TimeToken>;
  99775. /** @hidden */
  99776. _createTimeQuery(): WebGLQuery;
  99777. /** @hidden */
  99778. _deleteTimeQuery(query: WebGLQuery): void;
  99779. /** @hidden */
  99780. _getGlAlgorithmType(algorithmType: number): number;
  99781. /** @hidden */
  99782. _getTimeQueryResult(query: WebGLQuery): any;
  99783. /** @hidden */
  99784. _getTimeQueryAvailability(query: WebGLQuery): any;
  99785. }
  99786. interface AbstractMesh {
  99787. /**
  99788. * Backing filed
  99789. * @hidden
  99790. */
  99791. __occlusionDataStorage: _OcclusionDataStorage;
  99792. /**
  99793. * Access property
  99794. * @hidden
  99795. */
  99796. _occlusionDataStorage: _OcclusionDataStorage;
  99797. /**
  99798. * 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.
  99799. * The default value is -1 which means don't break the query and wait till the result
  99800. * @see http://doc.babylonjs.com/features/occlusionquery
  99801. */
  99802. occlusionRetryCount: number;
  99803. /**
  99804. * 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:
  99805. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  99806. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  99807. * * 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.
  99808. * @see http://doc.babylonjs.com/features/occlusionquery
  99809. */
  99810. occlusionType: number;
  99811. /**
  99812. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  99813. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  99814. * * 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.
  99815. * @see http://doc.babylonjs.com/features/occlusionquery
  99816. */
  99817. occlusionQueryAlgorithmType: number;
  99818. /**
  99819. * 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
  99820. * @see http://doc.babylonjs.com/features/occlusionquery
  99821. */
  99822. isOccluded: boolean;
  99823. /**
  99824. * Flag to check the progress status of the query
  99825. * @see http://doc.babylonjs.com/features/occlusionquery
  99826. */
  99827. isOcclusionQueryInProgress: boolean;
  99828. }
  99829. }
  99830. declare module BABYLON {
  99831. /** @hidden */
  99832. export var _forceTransformFeedbackToBundle: boolean;
  99833. interface Engine {
  99834. /**
  99835. * Creates a webGL transform feedback object
  99836. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  99837. * @returns the webGL transform feedback object
  99838. */
  99839. createTransformFeedback(): WebGLTransformFeedback;
  99840. /**
  99841. * Delete a webGL transform feedback object
  99842. * @param value defines the webGL transform feedback object to delete
  99843. */
  99844. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  99845. /**
  99846. * Bind a webGL transform feedback object to the webgl context
  99847. * @param value defines the webGL transform feedback object to bind
  99848. */
  99849. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  99850. /**
  99851. * Begins a transform feedback operation
  99852. * @param usePoints defines if points or triangles must be used
  99853. */
  99854. beginTransformFeedback(usePoints: boolean): void;
  99855. /**
  99856. * Ends a transform feedback operation
  99857. */
  99858. endTransformFeedback(): void;
  99859. /**
  99860. * Specify the varyings to use with transform feedback
  99861. * @param program defines the associated webGL program
  99862. * @param value defines the list of strings representing the varying names
  99863. */
  99864. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  99865. /**
  99866. * Bind a webGL buffer for a transform feedback operation
  99867. * @param value defines the webGL buffer to bind
  99868. */
  99869. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  99870. }
  99871. }
  99872. declare module BABYLON {
  99873. /**
  99874. * Gather the list of clipboard event types as constants.
  99875. */
  99876. export class ClipboardEventTypes {
  99877. /**
  99878. * The clipboard event is fired when a copy command is active (pressed).
  99879. */
  99880. static readonly COPY: number;
  99881. /**
  99882. * The clipboard event is fired when a cut command is active (pressed).
  99883. */
  99884. static readonly CUT: number;
  99885. /**
  99886. * The clipboard event is fired when a paste command is active (pressed).
  99887. */
  99888. static readonly PASTE: number;
  99889. }
  99890. /**
  99891. * This class is used to store clipboard related info for the onClipboardObservable event.
  99892. */
  99893. export class ClipboardInfo {
  99894. /**
  99895. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99896. */
  99897. type: number;
  99898. /**
  99899. * Defines the related dom event
  99900. */
  99901. event: ClipboardEvent;
  99902. /**
  99903. *Creates an instance of ClipboardInfo.
  99904. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  99905. * @param event Defines the related dom event
  99906. */
  99907. constructor(
  99908. /**
  99909. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99910. */
  99911. type: number,
  99912. /**
  99913. * Defines the related dom event
  99914. */
  99915. event: ClipboardEvent);
  99916. /**
  99917. * Get the clipboard event's type from the keycode.
  99918. * @param keyCode Defines the keyCode for the current keyboard event.
  99919. * @return {number}
  99920. */
  99921. static GetTypeFromCharacter(keyCode: number): number;
  99922. }
  99923. }
  99924. declare module BABYLON {
  99925. /**
  99926. * Class used to represent data loading progression
  99927. */
  99928. export class SceneLoaderProgressEvent {
  99929. /** defines if data length to load can be evaluated */
  99930. readonly lengthComputable: boolean;
  99931. /** defines the loaded data length */
  99932. readonly loaded: number;
  99933. /** defines the data length to load */
  99934. readonly total: number;
  99935. /**
  99936. * Create a new progress event
  99937. * @param lengthComputable defines if data length to load can be evaluated
  99938. * @param loaded defines the loaded data length
  99939. * @param total defines the data length to load
  99940. */
  99941. constructor(
  99942. /** defines if data length to load can be evaluated */
  99943. lengthComputable: boolean,
  99944. /** defines the loaded data length */
  99945. loaded: number,
  99946. /** defines the data length to load */
  99947. total: number);
  99948. /**
  99949. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  99950. * @param event defines the source event
  99951. * @returns a new SceneLoaderProgressEvent
  99952. */
  99953. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  99954. }
  99955. /**
  99956. * Interface used by SceneLoader plugins to define supported file extensions
  99957. */
  99958. export interface ISceneLoaderPluginExtensions {
  99959. /**
  99960. * Defines the list of supported extensions
  99961. */
  99962. [extension: string]: {
  99963. isBinary: boolean;
  99964. };
  99965. }
  99966. /**
  99967. * Interface used by SceneLoader plugin factory
  99968. */
  99969. export interface ISceneLoaderPluginFactory {
  99970. /**
  99971. * Defines the name of the factory
  99972. */
  99973. name: string;
  99974. /**
  99975. * Function called to create a new plugin
  99976. * @return the new plugin
  99977. */
  99978. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  99979. /**
  99980. * Boolean indicating if the plugin can direct load specific data
  99981. */
  99982. canDirectLoad?: (data: string) => boolean;
  99983. }
  99984. /**
  99985. * Interface used to define a SceneLoader plugin
  99986. */
  99987. export interface ISceneLoaderPlugin {
  99988. /**
  99989. * The friendly name of this plugin.
  99990. */
  99991. name: string;
  99992. /**
  99993. * The file extensions supported by this plugin.
  99994. */
  99995. extensions: string | ISceneLoaderPluginExtensions;
  99996. /**
  99997. * Import meshes into a scene.
  99998. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99999. * @param scene The scene to import into
  100000. * @param data The data to import
  100001. * @param rootUrl The root url for scene and resources
  100002. * @param meshes The meshes array to import into
  100003. * @param particleSystems The particle systems array to import into
  100004. * @param skeletons The skeletons array to import into
  100005. * @param onError The callback when import fails
  100006. * @returns True if successful or false otherwise
  100007. */
  100008. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100009. /**
  100010. * Load into a scene.
  100011. * @param scene The scene to load into
  100012. * @param data The data to import
  100013. * @param rootUrl The root url for scene and resources
  100014. * @param onError The callback when import fails
  100015. * @returns true if successful or false otherwise
  100016. */
  100017. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100018. /**
  100019. * The callback that returns true if the data can be directly loaded.
  100020. */
  100021. canDirectLoad?: (data: string) => boolean;
  100022. /**
  100023. * The callback that allows custom handling of the root url based on the response url.
  100024. */
  100025. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100026. /**
  100027. * Load into an asset container.
  100028. * @param scene The scene to load into
  100029. * @param data The data to import
  100030. * @param rootUrl The root url for scene and resources
  100031. * @param onError The callback when import fails
  100032. * @returns The loaded asset container
  100033. */
  100034. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100035. }
  100036. /**
  100037. * Interface used to define an async SceneLoader plugin
  100038. */
  100039. export interface ISceneLoaderPluginAsync {
  100040. /**
  100041. * The friendly name of this plugin.
  100042. */
  100043. name: string;
  100044. /**
  100045. * The file extensions supported by this plugin.
  100046. */
  100047. extensions: string | ISceneLoaderPluginExtensions;
  100048. /**
  100049. * Import meshes into a scene.
  100050. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100051. * @param scene The scene to import into
  100052. * @param data The data to import
  100053. * @param rootUrl The root url for scene and resources
  100054. * @param onProgress The callback when the load progresses
  100055. * @param fileName Defines the name of the file to load
  100056. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100057. */
  100058. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100059. meshes: AbstractMesh[];
  100060. particleSystems: IParticleSystem[];
  100061. skeletons: Skeleton[];
  100062. animationGroups: AnimationGroup[];
  100063. }>;
  100064. /**
  100065. * Load into a scene.
  100066. * @param scene The scene to load into
  100067. * @param data The data to import
  100068. * @param rootUrl The root url for scene and resources
  100069. * @param onProgress The callback when the load progresses
  100070. * @param fileName Defines the name of the file to load
  100071. * @returns Nothing
  100072. */
  100073. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100074. /**
  100075. * The callback that returns true if the data can be directly loaded.
  100076. */
  100077. canDirectLoad?: (data: string) => boolean;
  100078. /**
  100079. * The callback that allows custom handling of the root url based on the response url.
  100080. */
  100081. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100082. /**
  100083. * Load into an asset container.
  100084. * @param scene The scene to load into
  100085. * @param data The data to import
  100086. * @param rootUrl The root url for scene and resources
  100087. * @param onProgress The callback when the load progresses
  100088. * @param fileName Defines the name of the file to load
  100089. * @returns The loaded asset container
  100090. */
  100091. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100092. }
  100093. /**
  100094. * Class used to load scene from various file formats using registered plugins
  100095. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100096. */
  100097. export class SceneLoader {
  100098. /**
  100099. * No logging while loading
  100100. */
  100101. static readonly NO_LOGGING: number;
  100102. /**
  100103. * Minimal logging while loading
  100104. */
  100105. static readonly MINIMAL_LOGGING: number;
  100106. /**
  100107. * Summary logging while loading
  100108. */
  100109. static readonly SUMMARY_LOGGING: number;
  100110. /**
  100111. * Detailled logging while loading
  100112. */
  100113. static readonly DETAILED_LOGGING: number;
  100114. /**
  100115. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  100116. */
  100117. static ForceFullSceneLoadingForIncremental: boolean;
  100118. /**
  100119. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  100120. */
  100121. static ShowLoadingScreen: boolean;
  100122. /**
  100123. * Defines the current logging level (while loading the scene)
  100124. * @ignorenaming
  100125. */
  100126. static loggingLevel: number;
  100127. /**
  100128. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  100129. */
  100130. static CleanBoneMatrixWeights: boolean;
  100131. /**
  100132. * Event raised when a plugin is used to load a scene
  100133. */
  100134. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  100135. private static _registeredPlugins;
  100136. private static _getDefaultPlugin;
  100137. private static _getPluginForExtension;
  100138. private static _getPluginForDirectLoad;
  100139. private static _getPluginForFilename;
  100140. private static _getDirectLoad;
  100141. private static _loadData;
  100142. private static _getFileInfo;
  100143. /**
  100144. * Gets a plugin that can load the given extension
  100145. * @param extension defines the extension to load
  100146. * @returns a plugin or null if none works
  100147. */
  100148. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  100149. /**
  100150. * Gets a boolean indicating that the given extension can be loaded
  100151. * @param extension defines the extension to load
  100152. * @returns true if the extension is supported
  100153. */
  100154. static IsPluginForExtensionAvailable(extension: string): boolean;
  100155. /**
  100156. * Adds a new plugin to the list of registered plugins
  100157. * @param plugin defines the plugin to add
  100158. */
  100159. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  100160. /**
  100161. * Import meshes into a scene
  100162. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100163. * @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)
  100164. * @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)
  100165. * @param scene the instance of BABYLON.Scene to append to
  100166. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  100167. * @param onProgress a callback with a progress event for each file being loaded
  100168. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100169. * @param pluginExtension the extension used to determine the plugin
  100170. * @returns The loaded plugin
  100171. */
  100172. 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>;
  100173. /**
  100174. * Import meshes into a scene
  100175. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100176. * @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)
  100177. * @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)
  100178. * @param scene the instance of BABYLON.Scene to append to
  100179. * @param onProgress a callback with a progress event for each file being loaded
  100180. * @param pluginExtension the extension used to determine the plugin
  100181. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  100182. */
  100183. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  100184. meshes: AbstractMesh[];
  100185. particleSystems: IParticleSystem[];
  100186. skeletons: Skeleton[];
  100187. animationGroups: AnimationGroup[];
  100188. }>;
  100189. /**
  100190. * Load a scene
  100191. * @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)
  100192. * @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)
  100193. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100194. * @param onSuccess a callback with the scene when import succeeds
  100195. * @param onProgress a callback with a progress event for each file being loaded
  100196. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100197. * @param pluginExtension the extension used to determine the plugin
  100198. * @returns The loaded plugin
  100199. */
  100200. 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>;
  100201. /**
  100202. * Load a scene
  100203. * @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)
  100204. * @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)
  100205. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100206. * @param onProgress a callback with a progress event for each file being loaded
  100207. * @param pluginExtension the extension used to determine the plugin
  100208. * @returns The loaded scene
  100209. */
  100210. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100211. /**
  100212. * Append a scene
  100213. * @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)
  100214. * @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)
  100215. * @param scene is the instance of BABYLON.Scene to append to
  100216. * @param onSuccess a callback with the scene when import succeeds
  100217. * @param onProgress a callback with a progress event for each file being loaded
  100218. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100219. * @param pluginExtension the extension used to determine the plugin
  100220. * @returns The loaded plugin
  100221. */
  100222. 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>;
  100223. /**
  100224. * Append a scene
  100225. * @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)
  100226. * @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)
  100227. * @param scene is the instance of BABYLON.Scene to append to
  100228. * @param onProgress a callback with a progress event for each file being loaded
  100229. * @param pluginExtension the extension used to determine the plugin
  100230. * @returns The given scene
  100231. */
  100232. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100233. /**
  100234. * Load a scene into an asset container
  100235. * @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)
  100236. * @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)
  100237. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  100238. * @param onSuccess a callback with the scene when import succeeds
  100239. * @param onProgress a callback with a progress event for each file being loaded
  100240. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100241. * @param pluginExtension the extension used to determine the plugin
  100242. * @returns The loaded plugin
  100243. */
  100244. 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>;
  100245. /**
  100246. * Load a scene into an asset container
  100247. * @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)
  100248. * @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)
  100249. * @param scene is the instance of Scene to append to
  100250. * @param onProgress a callback with a progress event for each file being loaded
  100251. * @param pluginExtension the extension used to determine the plugin
  100252. * @returns The loaded asset container
  100253. */
  100254. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  100255. }
  100256. }
  100257. declare module BABYLON {
  100258. /**
  100259. * Google Daydream controller
  100260. */
  100261. export class DaydreamController extends WebVRController {
  100262. /**
  100263. * Base Url for the controller model.
  100264. */
  100265. static MODEL_BASE_URL: string;
  100266. /**
  100267. * File name for the controller model.
  100268. */
  100269. static MODEL_FILENAME: string;
  100270. /**
  100271. * Gamepad Id prefix used to identify Daydream Controller.
  100272. */
  100273. static readonly GAMEPAD_ID_PREFIX: string;
  100274. /**
  100275. * Creates a new DaydreamController from a gamepad
  100276. * @param vrGamepad the gamepad that the controller should be created from
  100277. */
  100278. constructor(vrGamepad: any);
  100279. /**
  100280. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100281. * @param scene scene in which to add meshes
  100282. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100283. */
  100284. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100285. /**
  100286. * Called once for each button that changed state since the last frame
  100287. * @param buttonIdx Which button index changed
  100288. * @param state New state of the button
  100289. * @param changes Which properties on the state changed since last frame
  100290. */
  100291. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100292. }
  100293. }
  100294. declare module BABYLON {
  100295. /**
  100296. * Gear VR Controller
  100297. */
  100298. export class GearVRController extends WebVRController {
  100299. /**
  100300. * Base Url for the controller model.
  100301. */
  100302. static MODEL_BASE_URL: string;
  100303. /**
  100304. * File name for the controller model.
  100305. */
  100306. static MODEL_FILENAME: string;
  100307. /**
  100308. * Gamepad Id prefix used to identify this controller.
  100309. */
  100310. static readonly GAMEPAD_ID_PREFIX: string;
  100311. private readonly _buttonIndexToObservableNameMap;
  100312. /**
  100313. * Creates a new GearVRController from a gamepad
  100314. * @param vrGamepad the gamepad that the controller should be created from
  100315. */
  100316. constructor(vrGamepad: any);
  100317. /**
  100318. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100319. * @param scene scene in which to add meshes
  100320. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100321. */
  100322. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100323. /**
  100324. * Called once for each button that changed state since the last frame
  100325. * @param buttonIdx Which button index changed
  100326. * @param state New state of the button
  100327. * @param changes Which properties on the state changed since last frame
  100328. */
  100329. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100330. }
  100331. }
  100332. declare module BABYLON {
  100333. /**
  100334. * Generic Controller
  100335. */
  100336. export class GenericController extends WebVRController {
  100337. /**
  100338. * Base Url for the controller model.
  100339. */
  100340. static readonly MODEL_BASE_URL: string;
  100341. /**
  100342. * File name for the controller model.
  100343. */
  100344. static readonly MODEL_FILENAME: string;
  100345. /**
  100346. * Creates a new GenericController from a gamepad
  100347. * @param vrGamepad the gamepad that the controller should be created from
  100348. */
  100349. constructor(vrGamepad: any);
  100350. /**
  100351. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100352. * @param scene scene in which to add meshes
  100353. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100354. */
  100355. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100356. /**
  100357. * Called once for each button that changed state since the last frame
  100358. * @param buttonIdx Which button index changed
  100359. * @param state New state of the button
  100360. * @param changes Which properties on the state changed since last frame
  100361. */
  100362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100363. }
  100364. }
  100365. declare module BABYLON {
  100366. /**
  100367. * Oculus Touch Controller
  100368. */
  100369. export class OculusTouchController extends WebVRController {
  100370. /**
  100371. * Base Url for the controller model.
  100372. */
  100373. static MODEL_BASE_URL: string;
  100374. /**
  100375. * File name for the left controller model.
  100376. */
  100377. static MODEL_LEFT_FILENAME: string;
  100378. /**
  100379. * File name for the right controller model.
  100380. */
  100381. static MODEL_RIGHT_FILENAME: string;
  100382. /**
  100383. * Fired when the secondary trigger on this controller is modified
  100384. */
  100385. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100386. /**
  100387. * Fired when the thumb rest on this controller is modified
  100388. */
  100389. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100390. /**
  100391. * Creates a new OculusTouchController from a gamepad
  100392. * @param vrGamepad the gamepad that the controller should be created from
  100393. */
  100394. constructor(vrGamepad: any);
  100395. /**
  100396. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100397. * @param scene scene in which to add meshes
  100398. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100399. */
  100400. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100401. /**
  100402. * Fired when the A button on this controller is modified
  100403. */
  100404. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100405. /**
  100406. * Fired when the B button on this controller is modified
  100407. */
  100408. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100409. /**
  100410. * Fired when the X button on this controller is modified
  100411. */
  100412. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100413. /**
  100414. * Fired when the Y button on this controller is modified
  100415. */
  100416. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100417. /**
  100418. * Called once for each button that changed state since the last frame
  100419. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  100420. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  100421. * 2) secondary trigger (same)
  100422. * 3) A (right) X (left), touch, pressed = value
  100423. * 4) B / Y
  100424. * 5) thumb rest
  100425. * @param buttonIdx Which button index changed
  100426. * @param state New state of the button
  100427. * @param changes Which properties on the state changed since last frame
  100428. */
  100429. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100430. }
  100431. }
  100432. declare module BABYLON {
  100433. /**
  100434. * Vive Controller
  100435. */
  100436. export class ViveController extends WebVRController {
  100437. /**
  100438. * Base Url for the controller model.
  100439. */
  100440. static MODEL_BASE_URL: string;
  100441. /**
  100442. * File name for the controller model.
  100443. */
  100444. static MODEL_FILENAME: string;
  100445. /**
  100446. * Creates a new ViveController from a gamepad
  100447. * @param vrGamepad the gamepad that the controller should be created from
  100448. */
  100449. constructor(vrGamepad: any);
  100450. /**
  100451. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100452. * @param scene scene in which to add meshes
  100453. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100454. */
  100455. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100456. /**
  100457. * Fired when the left button on this controller is modified
  100458. */
  100459. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100460. /**
  100461. * Fired when the right button on this controller is modified
  100462. */
  100463. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100464. /**
  100465. * Fired when the menu button on this controller is modified
  100466. */
  100467. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100468. /**
  100469. * Called once for each button that changed state since the last frame
  100470. * Vive mapping:
  100471. * 0: touchpad
  100472. * 1: trigger
  100473. * 2: left AND right buttons
  100474. * 3: menu button
  100475. * @param buttonIdx Which button index changed
  100476. * @param state New state of the button
  100477. * @param changes Which properties on the state changed since last frame
  100478. */
  100479. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100480. }
  100481. }
  100482. declare module BABYLON {
  100483. /**
  100484. * Defines the WindowsMotionController object that the state of the windows motion controller
  100485. */
  100486. export class WindowsMotionController extends WebVRController {
  100487. /**
  100488. * The base url used to load the left and right controller models
  100489. */
  100490. static MODEL_BASE_URL: string;
  100491. /**
  100492. * The name of the left controller model file
  100493. */
  100494. static MODEL_LEFT_FILENAME: string;
  100495. /**
  100496. * The name of the right controller model file
  100497. */
  100498. static MODEL_RIGHT_FILENAME: string;
  100499. /**
  100500. * The controller name prefix for this controller type
  100501. */
  100502. static readonly GAMEPAD_ID_PREFIX: string;
  100503. /**
  100504. * The controller id pattern for this controller type
  100505. */
  100506. private static readonly GAMEPAD_ID_PATTERN;
  100507. private _loadedMeshInfo;
  100508. private readonly _mapping;
  100509. /**
  100510. * Fired when the trackpad on this controller is clicked
  100511. */
  100512. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  100513. /**
  100514. * Fired when the trackpad on this controller is modified
  100515. */
  100516. onTrackpadValuesChangedObservable: Observable<StickValues>;
  100517. /**
  100518. * The current x and y values of this controller's trackpad
  100519. */
  100520. trackpad: StickValues;
  100521. /**
  100522. * Creates a new WindowsMotionController from a gamepad
  100523. * @param vrGamepad the gamepad that the controller should be created from
  100524. */
  100525. constructor(vrGamepad: any);
  100526. /**
  100527. * Fired when the trigger on this controller is modified
  100528. */
  100529. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100530. /**
  100531. * Fired when the menu button on this controller is modified
  100532. */
  100533. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100534. /**
  100535. * Fired when the grip button on this controller is modified
  100536. */
  100537. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100538. /**
  100539. * Fired when the thumbstick button on this controller is modified
  100540. */
  100541. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100542. /**
  100543. * Fired when the touchpad button on this controller is modified
  100544. */
  100545. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100546. /**
  100547. * Fired when the touchpad values on this controller are modified
  100548. */
  100549. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  100550. private _updateTrackpad;
  100551. /**
  100552. * Called once per frame by the engine.
  100553. */
  100554. update(): void;
  100555. /**
  100556. * Called once for each button that changed state since the last frame
  100557. * @param buttonIdx Which button index changed
  100558. * @param state New state of the button
  100559. * @param changes Which properties on the state changed since last frame
  100560. */
  100561. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100562. /**
  100563. * Moves the buttons on the controller mesh based on their current state
  100564. * @param buttonName the name of the button to move
  100565. * @param buttonValue the value of the button which determines the buttons new position
  100566. */
  100567. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  100568. /**
  100569. * Moves the axis on the controller mesh based on its current state
  100570. * @param axis the index of the axis
  100571. * @param axisValue the value of the axis which determines the meshes new position
  100572. * @hidden
  100573. */
  100574. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  100575. /**
  100576. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100577. * @param scene scene in which to add meshes
  100578. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100579. */
  100580. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  100581. /**
  100582. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  100583. * can be transformed by button presses and axes values, based on this._mapping.
  100584. *
  100585. * @param scene scene in which the meshes exist
  100586. * @param meshes list of meshes that make up the controller model to process
  100587. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  100588. */
  100589. private processModel;
  100590. private createMeshInfo;
  100591. /**
  100592. * Gets the ray of the controller in the direction the controller is pointing
  100593. * @param length the length the resulting ray should be
  100594. * @returns a ray in the direction the controller is pointing
  100595. */
  100596. getForwardRay(length?: number): Ray;
  100597. /**
  100598. * Disposes of the controller
  100599. */
  100600. dispose(): void;
  100601. }
  100602. }
  100603. declare module BABYLON {
  100604. /**
  100605. * Single axis scale gizmo
  100606. */
  100607. export class AxisScaleGizmo extends Gizmo {
  100608. private _coloredMaterial;
  100609. /**
  100610. * Drag behavior responsible for the gizmos dragging interactions
  100611. */
  100612. dragBehavior: PointerDragBehavior;
  100613. private _pointerObserver;
  100614. /**
  100615. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100616. */
  100617. snapDistance: number;
  100618. /**
  100619. * Event that fires each time the gizmo snaps to a new location.
  100620. * * snapDistance is the the change in distance
  100621. */
  100622. onSnapObservable: Observable<{
  100623. snapDistance: number;
  100624. }>;
  100625. /**
  100626. * If the scaling operation should be done on all axis (default: false)
  100627. */
  100628. uniformScaling: boolean;
  100629. /**
  100630. * Creates an AxisScaleGizmo
  100631. * @param gizmoLayer The utility layer the gizmo will be added to
  100632. * @param dragAxis The axis which the gizmo will be able to scale on
  100633. * @param color The color of the gizmo
  100634. */
  100635. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100637. /**
  100638. * Disposes of the gizmo
  100639. */
  100640. dispose(): void;
  100641. /**
  100642. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100643. * @param mesh The mesh to replace the default mesh of the gizmo
  100644. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  100645. */
  100646. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  100647. }
  100648. }
  100649. declare module BABYLON {
  100650. /**
  100651. * Bounding box gizmo
  100652. */
  100653. export class BoundingBoxGizmo extends Gizmo {
  100654. private _lineBoundingBox;
  100655. private _rotateSpheresParent;
  100656. private _scaleBoxesParent;
  100657. private _boundingDimensions;
  100658. private _renderObserver;
  100659. private _pointerObserver;
  100660. private _scaleDragSpeed;
  100661. private _tmpQuaternion;
  100662. private _tmpVector;
  100663. private _tmpRotationMatrix;
  100664. /**
  100665. * 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)
  100666. */
  100667. ignoreChildren: boolean;
  100668. /**
  100669. * 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)
  100670. */
  100671. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  100672. /**
  100673. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  100674. */
  100675. rotationSphereSize: number;
  100676. /**
  100677. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  100678. */
  100679. scaleBoxSize: number;
  100680. /**
  100681. * 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)
  100682. */
  100683. fixedDragMeshScreenSize: boolean;
  100684. /**
  100685. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  100686. */
  100687. fixedDragMeshScreenSizeDistanceFactor: number;
  100688. /**
  100689. * Fired when a rotation sphere or scale box is dragged
  100690. */
  100691. onDragStartObservable: Observable<{}>;
  100692. /**
  100693. * Fired when a scale box is dragged
  100694. */
  100695. onScaleBoxDragObservable: Observable<{}>;
  100696. /**
  100697. * Fired when a scale box drag is ended
  100698. */
  100699. onScaleBoxDragEndObservable: Observable<{}>;
  100700. /**
  100701. * Fired when a rotation sphere is dragged
  100702. */
  100703. onRotationSphereDragObservable: Observable<{}>;
  100704. /**
  100705. * Fired when a rotation sphere drag is ended
  100706. */
  100707. onRotationSphereDragEndObservable: Observable<{}>;
  100708. /**
  100709. * 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)
  100710. */
  100711. scalePivot: Nullable<Vector3>;
  100712. private _anchorMesh;
  100713. private _existingMeshScale;
  100714. private _dragMesh;
  100715. private pointerDragBehavior;
  100716. private coloredMaterial;
  100717. private hoverColoredMaterial;
  100718. /**
  100719. * Sets the color of the bounding box gizmo
  100720. * @param color the color to set
  100721. */
  100722. setColor(color: Color3): void;
  100723. /**
  100724. * Creates an BoundingBoxGizmo
  100725. * @param gizmoLayer The utility layer the gizmo will be added to
  100726. * @param color The color of the gizmo
  100727. */
  100728. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100729. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100730. private _selectNode;
  100731. /**
  100732. * Updates the bounding box information for the Gizmo
  100733. */
  100734. updateBoundingBox(): void;
  100735. private _updateRotationSpheres;
  100736. private _updateScaleBoxes;
  100737. /**
  100738. * Enables rotation on the specified axis and disables rotation on the others
  100739. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  100740. */
  100741. setEnabledRotationAxis(axis: string): void;
  100742. /**
  100743. * Enables/disables scaling
  100744. * @param enable if scaling should be enabled
  100745. */
  100746. setEnabledScaling(enable: boolean): void;
  100747. private _updateDummy;
  100748. /**
  100749. * Enables a pointer drag behavior on the bounding box of the gizmo
  100750. */
  100751. enableDragBehavior(): void;
  100752. /**
  100753. * Disposes of the gizmo
  100754. */
  100755. dispose(): void;
  100756. /**
  100757. * 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)
  100758. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  100759. * @returns the bounding box mesh with the passed in mesh as a child
  100760. */
  100761. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  100762. /**
  100763. * CustomMeshes are not supported by this gizmo
  100764. * @param mesh The mesh to replace the default mesh of the gizmo
  100765. */
  100766. setCustomMesh(mesh: Mesh): void;
  100767. }
  100768. }
  100769. declare module BABYLON {
  100770. /**
  100771. * Single plane rotation gizmo
  100772. */
  100773. export class PlaneRotationGizmo extends Gizmo {
  100774. /**
  100775. * Drag behavior responsible for the gizmos dragging interactions
  100776. */
  100777. dragBehavior: PointerDragBehavior;
  100778. private _pointerObserver;
  100779. /**
  100780. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  100781. */
  100782. snapDistance: number;
  100783. /**
  100784. * Event that fires each time the gizmo snaps to a new location.
  100785. * * snapDistance is the the change in distance
  100786. */
  100787. onSnapObservable: Observable<{
  100788. snapDistance: number;
  100789. }>;
  100790. /**
  100791. * Creates a PlaneRotationGizmo
  100792. * @param gizmoLayer The utility layer the gizmo will be added to
  100793. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  100794. * @param color The color of the gizmo
  100795. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100796. */
  100797. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100798. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100799. /**
  100800. * Disposes of the gizmo
  100801. */
  100802. dispose(): void;
  100803. }
  100804. }
  100805. declare module BABYLON {
  100806. /**
  100807. * Gizmo that enables rotating a mesh along 3 axis
  100808. */
  100809. export class RotationGizmo extends Gizmo {
  100810. /**
  100811. * Internal gizmo used for interactions on the x axis
  100812. */
  100813. xGizmo: PlaneRotationGizmo;
  100814. /**
  100815. * Internal gizmo used for interactions on the y axis
  100816. */
  100817. yGizmo: PlaneRotationGizmo;
  100818. /**
  100819. * Internal gizmo used for interactions on the z axis
  100820. */
  100821. zGizmo: PlaneRotationGizmo;
  100822. /** Fires an event when any of it's sub gizmos are dragged */
  100823. onDragStartObservable: Observable<{}>;
  100824. /** Fires an event when any of it's sub gizmos are released from dragging */
  100825. onDragEndObservable: Observable<{}>;
  100826. attachedMesh: Nullable<AbstractMesh>;
  100827. /**
  100828. * Creates a RotationGizmo
  100829. * @param gizmoLayer The utility layer the gizmo will be added to
  100830. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100831. */
  100832. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100833. updateGizmoRotationToMatchAttachedMesh: boolean;
  100834. /**
  100835. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100836. */
  100837. snapDistance: number;
  100838. /**
  100839. * Ratio for the scale of the gizmo (Default: 1)
  100840. */
  100841. scaleRatio: number;
  100842. /**
  100843. * Disposes of the gizmo
  100844. */
  100845. dispose(): void;
  100846. /**
  100847. * CustomMeshes are not supported by this gizmo
  100848. * @param mesh The mesh to replace the default mesh of the gizmo
  100849. */
  100850. setCustomMesh(mesh: Mesh): void;
  100851. }
  100852. }
  100853. declare module BABYLON {
  100854. /**
  100855. * Gizmo that enables dragging a mesh along 3 axis
  100856. */
  100857. export class PositionGizmo extends Gizmo {
  100858. /**
  100859. * Internal gizmo used for interactions on the x axis
  100860. */
  100861. xGizmo: AxisDragGizmo;
  100862. /**
  100863. * Internal gizmo used for interactions on the y axis
  100864. */
  100865. yGizmo: AxisDragGizmo;
  100866. /**
  100867. * Internal gizmo used for interactions on the z axis
  100868. */
  100869. zGizmo: AxisDragGizmo;
  100870. /** Fires an event when any of it's sub gizmos are dragged */
  100871. onDragStartObservable: Observable<{}>;
  100872. /** Fires an event when any of it's sub gizmos are released from dragging */
  100873. onDragEndObservable: Observable<{}>;
  100874. attachedMesh: Nullable<AbstractMesh>;
  100875. /**
  100876. * Creates a PositionGizmo
  100877. * @param gizmoLayer The utility layer the gizmo will be added to
  100878. */
  100879. constructor(gizmoLayer?: UtilityLayerRenderer);
  100880. updateGizmoRotationToMatchAttachedMesh: boolean;
  100881. /**
  100882. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100883. */
  100884. snapDistance: number;
  100885. /**
  100886. * Ratio for the scale of the gizmo (Default: 1)
  100887. */
  100888. scaleRatio: number;
  100889. /**
  100890. * Disposes of the gizmo
  100891. */
  100892. dispose(): void;
  100893. /**
  100894. * CustomMeshes are not supported by this gizmo
  100895. * @param mesh The mesh to replace the default mesh of the gizmo
  100896. */
  100897. setCustomMesh(mesh: Mesh): void;
  100898. }
  100899. }
  100900. declare module BABYLON {
  100901. /**
  100902. * Class containing static functions to help procedurally build meshes
  100903. */
  100904. export class PolyhedronBuilder {
  100905. /**
  100906. * Creates a polyhedron mesh
  100907. * * 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
  100908. * * The parameter `size` (positive float, default 1) sets the polygon size
  100909. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100910. * * 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`
  100911. * * 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
  100912. * * 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)`)
  100913. * * 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
  100914. * * 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
  100915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100918. * @param name defines the name of the mesh
  100919. * @param options defines the options used to create the mesh
  100920. * @param scene defines the hosting scene
  100921. * @returns the polyhedron mesh
  100922. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  100923. */
  100924. static CreatePolyhedron(name: string, options: {
  100925. type?: number;
  100926. size?: number;
  100927. sizeX?: number;
  100928. sizeY?: number;
  100929. sizeZ?: number;
  100930. custom?: any;
  100931. faceUV?: Vector4[];
  100932. faceColors?: Color4[];
  100933. flat?: boolean;
  100934. updatable?: boolean;
  100935. sideOrientation?: number;
  100936. frontUVs?: Vector4;
  100937. backUVs?: Vector4;
  100938. }, scene: Scene): Mesh;
  100939. }
  100940. }
  100941. declare module BABYLON {
  100942. /**
  100943. * Gizmo that enables scaling a mesh along 3 axis
  100944. */
  100945. export class ScaleGizmo extends Gizmo {
  100946. /**
  100947. * Internal gizmo used for interactions on the x axis
  100948. */
  100949. xGizmo: AxisScaleGizmo;
  100950. /**
  100951. * Internal gizmo used for interactions on the y axis
  100952. */
  100953. yGizmo: AxisScaleGizmo;
  100954. /**
  100955. * Internal gizmo used for interactions on the z axis
  100956. */
  100957. zGizmo: AxisScaleGizmo;
  100958. /**
  100959. * Internal gizmo used to scale all axis equally
  100960. */
  100961. uniformScaleGizmo: AxisScaleGizmo;
  100962. /** Fires an event when any of it's sub gizmos are dragged */
  100963. onDragStartObservable: Observable<{}>;
  100964. /** Fires an event when any of it's sub gizmos are released from dragging */
  100965. onDragEndObservable: Observable<{}>;
  100966. attachedMesh: Nullable<AbstractMesh>;
  100967. /**
  100968. * Creates a ScaleGizmo
  100969. * @param gizmoLayer The utility layer the gizmo will be added to
  100970. */
  100971. constructor(gizmoLayer?: UtilityLayerRenderer);
  100972. updateGizmoRotationToMatchAttachedMesh: boolean;
  100973. /**
  100974. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100975. */
  100976. snapDistance: number;
  100977. /**
  100978. * Ratio for the scale of the gizmo (Default: 1)
  100979. */
  100980. scaleRatio: number;
  100981. /**
  100982. * Disposes of the gizmo
  100983. */
  100984. dispose(): void;
  100985. }
  100986. }
  100987. declare module BABYLON {
  100988. /**
  100989. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  100990. */
  100991. export class GizmoManager implements IDisposable {
  100992. private scene;
  100993. /**
  100994. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  100995. */
  100996. gizmos: {
  100997. positionGizmo: Nullable<PositionGizmo>;
  100998. rotationGizmo: Nullable<RotationGizmo>;
  100999. scaleGizmo: Nullable<ScaleGizmo>;
  101000. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101001. };
  101002. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101003. clearGizmoOnEmptyPointerEvent: boolean;
  101004. /** Fires an event when the manager is attached to a mesh */
  101005. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101006. private _gizmosEnabled;
  101007. private _pointerObserver;
  101008. private _attachedMesh;
  101009. private _boundingBoxColor;
  101010. private _defaultUtilityLayer;
  101011. private _defaultKeepDepthUtilityLayer;
  101012. /**
  101013. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101014. */
  101015. boundingBoxDragBehavior: SixDofDragBehavior;
  101016. /**
  101017. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101018. */
  101019. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101020. /**
  101021. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101022. */
  101023. usePointerToAttachGizmos: boolean;
  101024. /**
  101025. * Instatiates a gizmo manager
  101026. * @param scene the scene to overlay the gizmos on top of
  101027. */
  101028. constructor(scene: Scene);
  101029. /**
  101030. * Attaches a set of gizmos to the specified mesh
  101031. * @param mesh The mesh the gizmo's should be attached to
  101032. */
  101033. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101034. /**
  101035. * If the position gizmo is enabled
  101036. */
  101037. positionGizmoEnabled: boolean;
  101038. /**
  101039. * If the rotation gizmo is enabled
  101040. */
  101041. rotationGizmoEnabled: boolean;
  101042. /**
  101043. * If the scale gizmo is enabled
  101044. */
  101045. scaleGizmoEnabled: boolean;
  101046. /**
  101047. * If the boundingBox gizmo is enabled
  101048. */
  101049. boundingBoxGizmoEnabled: boolean;
  101050. /**
  101051. * Disposes of the gizmo manager
  101052. */
  101053. dispose(): void;
  101054. }
  101055. }
  101056. declare module BABYLON {
  101057. /**
  101058. * Gizmo that enables viewing a light
  101059. */
  101060. export class LightGizmo extends Gizmo {
  101061. private _box;
  101062. /**
  101063. * Creates a LightGizmo
  101064. * @param gizmoLayer The utility layer the gizmo will be added to
  101065. */
  101066. constructor(gizmoLayer?: UtilityLayerRenderer);
  101067. private _light;
  101068. /**
  101069. * The light that the gizmo is attached to
  101070. */
  101071. light: Nullable<Light>;
  101072. /**
  101073. * @hidden
  101074. * Updates the gizmo to match the attached mesh's position/rotation
  101075. */
  101076. protected _update(): void;
  101077. }
  101078. }
  101079. declare module BABYLON {
  101080. /** @hidden */
  101081. export var backgroundFragmentDeclaration: {
  101082. name: string;
  101083. shader: string;
  101084. };
  101085. }
  101086. declare module BABYLON {
  101087. /** @hidden */
  101088. export var backgroundUboDeclaration: {
  101089. name: string;
  101090. shader: string;
  101091. };
  101092. }
  101093. declare module BABYLON {
  101094. /** @hidden */
  101095. export var backgroundPixelShader: {
  101096. name: string;
  101097. shader: string;
  101098. };
  101099. }
  101100. declare module BABYLON {
  101101. /** @hidden */
  101102. export var backgroundVertexDeclaration: {
  101103. name: string;
  101104. shader: string;
  101105. };
  101106. }
  101107. declare module BABYLON {
  101108. /** @hidden */
  101109. export var backgroundVertexShader: {
  101110. name: string;
  101111. shader: string;
  101112. };
  101113. }
  101114. declare module BABYLON {
  101115. /**
  101116. * Background material used to create an efficient environement around your scene.
  101117. */
  101118. export class BackgroundMaterial extends PushMaterial {
  101119. /**
  101120. * Standard reflectance value at parallel view angle.
  101121. */
  101122. static StandardReflectance0: number;
  101123. /**
  101124. * Standard reflectance value at grazing angle.
  101125. */
  101126. static StandardReflectance90: number;
  101127. protected _primaryColor: Color3;
  101128. /**
  101129. * Key light Color (multiply against the environement texture)
  101130. */
  101131. primaryColor: Color3;
  101132. protected __perceptualColor: Nullable<Color3>;
  101133. /**
  101134. * Experimental Internal Use Only.
  101135. *
  101136. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  101137. * This acts as a helper to set the primary color to a more "human friendly" value.
  101138. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  101139. * output color as close as possible from the chosen value.
  101140. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  101141. * part of lighting setup.)
  101142. */
  101143. _perceptualColor: Nullable<Color3>;
  101144. protected _primaryColorShadowLevel: float;
  101145. /**
  101146. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  101147. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  101148. */
  101149. primaryColorShadowLevel: float;
  101150. protected _primaryColorHighlightLevel: float;
  101151. /**
  101152. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  101153. * The primary color is used at the level chosen to define what the white area would look.
  101154. */
  101155. primaryColorHighlightLevel: float;
  101156. protected _reflectionTexture: Nullable<BaseTexture>;
  101157. /**
  101158. * Reflection Texture used in the material.
  101159. * Should be author in a specific way for the best result (refer to the documentation).
  101160. */
  101161. reflectionTexture: Nullable<BaseTexture>;
  101162. protected _reflectionBlur: float;
  101163. /**
  101164. * Reflection Texture level of blur.
  101165. *
  101166. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  101167. * texture twice.
  101168. */
  101169. reflectionBlur: float;
  101170. protected _diffuseTexture: Nullable<BaseTexture>;
  101171. /**
  101172. * Diffuse Texture used in the material.
  101173. * Should be author in a specific way for the best result (refer to the documentation).
  101174. */
  101175. diffuseTexture: Nullable<BaseTexture>;
  101176. protected _shadowLights: Nullable<IShadowLight[]>;
  101177. /**
  101178. * Specify the list of lights casting shadow on the material.
  101179. * All scene shadow lights will be included if null.
  101180. */
  101181. shadowLights: Nullable<IShadowLight[]>;
  101182. protected _shadowLevel: float;
  101183. /**
  101184. * Helps adjusting the shadow to a softer level if required.
  101185. * 0 means black shadows and 1 means no shadows.
  101186. */
  101187. shadowLevel: float;
  101188. protected _sceneCenter: Vector3;
  101189. /**
  101190. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  101191. * It is usually zero but might be interesting to modify according to your setup.
  101192. */
  101193. sceneCenter: Vector3;
  101194. protected _opacityFresnel: boolean;
  101195. /**
  101196. * This helps specifying that the material is falling off to the sky box at grazing angle.
  101197. * This helps ensuring a nice transition when the camera goes under the ground.
  101198. */
  101199. opacityFresnel: boolean;
  101200. protected _reflectionFresnel: boolean;
  101201. /**
  101202. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  101203. * This helps adding a mirror texture on the ground.
  101204. */
  101205. reflectionFresnel: boolean;
  101206. protected _reflectionFalloffDistance: number;
  101207. /**
  101208. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  101209. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  101210. */
  101211. reflectionFalloffDistance: number;
  101212. protected _reflectionAmount: number;
  101213. /**
  101214. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  101215. */
  101216. reflectionAmount: number;
  101217. protected _reflectionReflectance0: number;
  101218. /**
  101219. * This specifies the weight of the reflection at grazing angle.
  101220. */
  101221. reflectionReflectance0: number;
  101222. protected _reflectionReflectance90: number;
  101223. /**
  101224. * This specifies the weight of the reflection at a perpendicular point of view.
  101225. */
  101226. reflectionReflectance90: number;
  101227. /**
  101228. * Sets the reflection reflectance fresnel values according to the default standard
  101229. * empirically know to work well :-)
  101230. */
  101231. reflectionStandardFresnelWeight: number;
  101232. protected _useRGBColor: boolean;
  101233. /**
  101234. * Helps to directly use the maps channels instead of their level.
  101235. */
  101236. useRGBColor: boolean;
  101237. protected _enableNoise: boolean;
  101238. /**
  101239. * This helps reducing the banding effect that could occur on the background.
  101240. */
  101241. enableNoise: boolean;
  101242. /**
  101243. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101244. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  101245. * Recommended to be keep at 1.0 except for special cases.
  101246. */
  101247. fovMultiplier: number;
  101248. private _fovMultiplier;
  101249. /**
  101250. * Enable the FOV adjustment feature controlled by fovMultiplier.
  101251. */
  101252. useEquirectangularFOV: boolean;
  101253. private _maxSimultaneousLights;
  101254. /**
  101255. * Number of Simultaneous lights allowed on the material.
  101256. */
  101257. maxSimultaneousLights: int;
  101258. /**
  101259. * Default configuration related to image processing available in the Background Material.
  101260. */
  101261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101262. /**
  101263. * Keep track of the image processing observer to allow dispose and replace.
  101264. */
  101265. private _imageProcessingObserver;
  101266. /**
  101267. * Attaches a new image processing configuration to the PBR Material.
  101268. * @param configuration (if null the scene configuration will be use)
  101269. */
  101270. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101271. /**
  101272. * Gets the image processing configuration used either in this material.
  101273. */
  101274. /**
  101275. * Sets the Default image processing configuration used either in the this material.
  101276. *
  101277. * If sets to null, the scene one is in use.
  101278. */
  101279. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  101280. /**
  101281. * Gets wether the color curves effect is enabled.
  101282. */
  101283. /**
  101284. * Sets wether the color curves effect is enabled.
  101285. */
  101286. cameraColorCurvesEnabled: boolean;
  101287. /**
  101288. * Gets wether the color grading effect is enabled.
  101289. */
  101290. /**
  101291. * Gets wether the color grading effect is enabled.
  101292. */
  101293. cameraColorGradingEnabled: boolean;
  101294. /**
  101295. * Gets wether tonemapping is enabled or not.
  101296. */
  101297. /**
  101298. * Sets wether tonemapping is enabled or not
  101299. */
  101300. cameraToneMappingEnabled: boolean;
  101301. /**
  101302. * The camera exposure used on this material.
  101303. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101304. * This corresponds to a photographic exposure.
  101305. */
  101306. /**
  101307. * The camera exposure used on this material.
  101308. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101309. * This corresponds to a photographic exposure.
  101310. */
  101311. cameraExposure: float;
  101312. /**
  101313. * Gets The camera contrast used on this material.
  101314. */
  101315. /**
  101316. * Sets The camera contrast used on this material.
  101317. */
  101318. cameraContrast: float;
  101319. /**
  101320. * Gets the Color Grading 2D Lookup Texture.
  101321. */
  101322. /**
  101323. * Sets the Color Grading 2D Lookup Texture.
  101324. */
  101325. cameraColorGradingTexture: Nullable<BaseTexture>;
  101326. /**
  101327. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101328. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101329. * 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;
  101330. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101331. */
  101332. /**
  101333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101335. * 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;
  101336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101337. */
  101338. cameraColorCurves: Nullable<ColorCurves>;
  101339. /**
  101340. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  101341. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  101342. */
  101343. switchToBGR: boolean;
  101344. private _renderTargets;
  101345. private _reflectionControls;
  101346. private _white;
  101347. private _primaryShadowColor;
  101348. private _primaryHighlightColor;
  101349. /**
  101350. * Instantiates a Background Material in the given scene
  101351. * @param name The friendly name of the material
  101352. * @param scene The scene to add the material to
  101353. */
  101354. constructor(name: string, scene: Scene);
  101355. /**
  101356. * Gets a boolean indicating that current material needs to register RTT
  101357. */
  101358. readonly hasRenderTargetTextures: boolean;
  101359. /**
  101360. * The entire material has been created in order to prevent overdraw.
  101361. * @returns false
  101362. */
  101363. needAlphaTesting(): boolean;
  101364. /**
  101365. * The entire material has been created in order to prevent overdraw.
  101366. * @returns true if blending is enable
  101367. */
  101368. needAlphaBlending(): boolean;
  101369. /**
  101370. * Checks wether the material is ready to be rendered for a given mesh.
  101371. * @param mesh The mesh to render
  101372. * @param subMesh The submesh to check against
  101373. * @param useInstances Specify wether or not the material is used with instances
  101374. * @returns true if all the dependencies are ready (Textures, Effects...)
  101375. */
  101376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101377. /**
  101378. * Compute the primary color according to the chosen perceptual color.
  101379. */
  101380. private _computePrimaryColorFromPerceptualColor;
  101381. /**
  101382. * Compute the highlights and shadow colors according to their chosen levels.
  101383. */
  101384. private _computePrimaryColors;
  101385. /**
  101386. * Build the uniform buffer used in the material.
  101387. */
  101388. buildUniformLayout(): void;
  101389. /**
  101390. * Unbind the material.
  101391. */
  101392. unbind(): void;
  101393. /**
  101394. * Bind only the world matrix to the material.
  101395. * @param world The world matrix to bind.
  101396. */
  101397. bindOnlyWorldMatrix(world: Matrix): void;
  101398. /**
  101399. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  101400. * @param world The world matrix to bind.
  101401. * @param subMesh The submesh to bind for.
  101402. */
  101403. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101404. /**
  101405. * Dispose the material.
  101406. * @param forceDisposeEffect Force disposal of the associated effect.
  101407. * @param forceDisposeTextures Force disposal of the associated textures.
  101408. */
  101409. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101410. /**
  101411. * Clones the material.
  101412. * @param name The cloned name.
  101413. * @returns The cloned material.
  101414. */
  101415. clone(name: string): BackgroundMaterial;
  101416. /**
  101417. * Serializes the current material to its JSON representation.
  101418. * @returns The JSON representation.
  101419. */
  101420. serialize(): any;
  101421. /**
  101422. * Gets the class name of the material
  101423. * @returns "BackgroundMaterial"
  101424. */
  101425. getClassName(): string;
  101426. /**
  101427. * Parse a JSON input to create back a background material.
  101428. * @param source The JSON data to parse
  101429. * @param scene The scene to create the parsed material in
  101430. * @param rootUrl The root url of the assets the material depends upon
  101431. * @returns the instantiated BackgroundMaterial.
  101432. */
  101433. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  101434. }
  101435. }
  101436. declare module BABYLON {
  101437. /**
  101438. * Represents the different options available during the creation of
  101439. * a Environment helper.
  101440. *
  101441. * This can control the default ground, skybox and image processing setup of your scene.
  101442. */
  101443. export interface IEnvironmentHelperOptions {
  101444. /**
  101445. * Specifies wether or not to create a ground.
  101446. * True by default.
  101447. */
  101448. createGround: boolean;
  101449. /**
  101450. * Specifies the ground size.
  101451. * 15 by default.
  101452. */
  101453. groundSize: number;
  101454. /**
  101455. * The texture used on the ground for the main color.
  101456. * Comes from the BabylonJS CDN by default.
  101457. *
  101458. * Remarks: Can be either a texture or a url.
  101459. */
  101460. groundTexture: string | BaseTexture;
  101461. /**
  101462. * The color mixed in the ground texture by default.
  101463. * BabylonJS clearColor by default.
  101464. */
  101465. groundColor: Color3;
  101466. /**
  101467. * Specifies the ground opacity.
  101468. * 1 by default.
  101469. */
  101470. groundOpacity: number;
  101471. /**
  101472. * Enables the ground to receive shadows.
  101473. * True by default.
  101474. */
  101475. enableGroundShadow: boolean;
  101476. /**
  101477. * Helps preventing the shadow to be fully black on the ground.
  101478. * 0.5 by default.
  101479. */
  101480. groundShadowLevel: number;
  101481. /**
  101482. * Creates a mirror texture attach to the ground.
  101483. * false by default.
  101484. */
  101485. enableGroundMirror: boolean;
  101486. /**
  101487. * Specifies the ground mirror size ratio.
  101488. * 0.3 by default as the default kernel is 64.
  101489. */
  101490. groundMirrorSizeRatio: number;
  101491. /**
  101492. * Specifies the ground mirror blur kernel size.
  101493. * 64 by default.
  101494. */
  101495. groundMirrorBlurKernel: number;
  101496. /**
  101497. * Specifies the ground mirror visibility amount.
  101498. * 1 by default
  101499. */
  101500. groundMirrorAmount: number;
  101501. /**
  101502. * Specifies the ground mirror reflectance weight.
  101503. * This uses the standard weight of the background material to setup the fresnel effect
  101504. * of the mirror.
  101505. * 1 by default.
  101506. */
  101507. groundMirrorFresnelWeight: number;
  101508. /**
  101509. * Specifies the ground mirror Falloff distance.
  101510. * This can helps reducing the size of the reflection.
  101511. * 0 by Default.
  101512. */
  101513. groundMirrorFallOffDistance: number;
  101514. /**
  101515. * Specifies the ground mirror texture type.
  101516. * Unsigned Int by Default.
  101517. */
  101518. groundMirrorTextureType: number;
  101519. /**
  101520. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  101521. * the shown objects.
  101522. */
  101523. groundYBias: number;
  101524. /**
  101525. * Specifies wether or not to create a skybox.
  101526. * True by default.
  101527. */
  101528. createSkybox: boolean;
  101529. /**
  101530. * Specifies the skybox size.
  101531. * 20 by default.
  101532. */
  101533. skyboxSize: number;
  101534. /**
  101535. * The texture used on the skybox for the main color.
  101536. * Comes from the BabylonJS CDN by default.
  101537. *
  101538. * Remarks: Can be either a texture or a url.
  101539. */
  101540. skyboxTexture: string | BaseTexture;
  101541. /**
  101542. * The color mixed in the skybox texture by default.
  101543. * BabylonJS clearColor by default.
  101544. */
  101545. skyboxColor: Color3;
  101546. /**
  101547. * The background rotation around the Y axis of the scene.
  101548. * This helps aligning the key lights of your scene with the background.
  101549. * 0 by default.
  101550. */
  101551. backgroundYRotation: number;
  101552. /**
  101553. * Compute automatically the size of the elements to best fit with the scene.
  101554. */
  101555. sizeAuto: boolean;
  101556. /**
  101557. * Default position of the rootMesh if autoSize is not true.
  101558. */
  101559. rootPosition: Vector3;
  101560. /**
  101561. * Sets up the image processing in the scene.
  101562. * true by default.
  101563. */
  101564. setupImageProcessing: boolean;
  101565. /**
  101566. * The texture used as your environment texture in the scene.
  101567. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  101568. *
  101569. * Remarks: Can be either a texture or a url.
  101570. */
  101571. environmentTexture: string | BaseTexture;
  101572. /**
  101573. * The value of the exposure to apply to the scene.
  101574. * 0.6 by default if setupImageProcessing is true.
  101575. */
  101576. cameraExposure: number;
  101577. /**
  101578. * The value of the contrast to apply to the scene.
  101579. * 1.6 by default if setupImageProcessing is true.
  101580. */
  101581. cameraContrast: number;
  101582. /**
  101583. * Specifies wether or not tonemapping should be enabled in the scene.
  101584. * true by default if setupImageProcessing is true.
  101585. */
  101586. toneMappingEnabled: boolean;
  101587. }
  101588. /**
  101589. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  101590. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  101591. * It also helps with the default setup of your imageProcessing configuration.
  101592. */
  101593. export class EnvironmentHelper {
  101594. /**
  101595. * Default ground texture URL.
  101596. */
  101597. private static _groundTextureCDNUrl;
  101598. /**
  101599. * Default skybox texture URL.
  101600. */
  101601. private static _skyboxTextureCDNUrl;
  101602. /**
  101603. * Default environment texture URL.
  101604. */
  101605. private static _environmentTextureCDNUrl;
  101606. /**
  101607. * Creates the default options for the helper.
  101608. */
  101609. private static _getDefaultOptions;
  101610. private _rootMesh;
  101611. /**
  101612. * Gets the root mesh created by the helper.
  101613. */
  101614. readonly rootMesh: Mesh;
  101615. private _skybox;
  101616. /**
  101617. * Gets the skybox created by the helper.
  101618. */
  101619. readonly skybox: Nullable<Mesh>;
  101620. private _skyboxTexture;
  101621. /**
  101622. * Gets the skybox texture created by the helper.
  101623. */
  101624. readonly skyboxTexture: Nullable<BaseTexture>;
  101625. private _skyboxMaterial;
  101626. /**
  101627. * Gets the skybox material created by the helper.
  101628. */
  101629. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  101630. private _ground;
  101631. /**
  101632. * Gets the ground mesh created by the helper.
  101633. */
  101634. readonly ground: Nullable<Mesh>;
  101635. private _groundTexture;
  101636. /**
  101637. * Gets the ground texture created by the helper.
  101638. */
  101639. readonly groundTexture: Nullable<BaseTexture>;
  101640. private _groundMirror;
  101641. /**
  101642. * Gets the ground mirror created by the helper.
  101643. */
  101644. readonly groundMirror: Nullable<MirrorTexture>;
  101645. /**
  101646. * Gets the ground mirror render list to helps pushing the meshes
  101647. * you wish in the ground reflection.
  101648. */
  101649. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  101650. private _groundMaterial;
  101651. /**
  101652. * Gets the ground material created by the helper.
  101653. */
  101654. readonly groundMaterial: Nullable<BackgroundMaterial>;
  101655. /**
  101656. * Stores the creation options.
  101657. */
  101658. private readonly _scene;
  101659. private _options;
  101660. /**
  101661. * This observable will be notified with any error during the creation of the environment,
  101662. * mainly texture creation errors.
  101663. */
  101664. onErrorObservable: Observable<{
  101665. message?: string;
  101666. exception?: any;
  101667. }>;
  101668. /**
  101669. * constructor
  101670. * @param options Defines the options we want to customize the helper
  101671. * @param scene The scene to add the material to
  101672. */
  101673. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  101674. /**
  101675. * Updates the background according to the new options
  101676. * @param options
  101677. */
  101678. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  101679. /**
  101680. * Sets the primary color of all the available elements.
  101681. * @param color the main color to affect to the ground and the background
  101682. */
  101683. setMainColor(color: Color3): void;
  101684. /**
  101685. * Setup the image processing according to the specified options.
  101686. */
  101687. private _setupImageProcessing;
  101688. /**
  101689. * Setup the environment texture according to the specified options.
  101690. */
  101691. private _setupEnvironmentTexture;
  101692. /**
  101693. * Setup the background according to the specified options.
  101694. */
  101695. private _setupBackground;
  101696. /**
  101697. * Get the scene sizes according to the setup.
  101698. */
  101699. private _getSceneSize;
  101700. /**
  101701. * Setup the ground according to the specified options.
  101702. */
  101703. private _setupGround;
  101704. /**
  101705. * Setup the ground material according to the specified options.
  101706. */
  101707. private _setupGroundMaterial;
  101708. /**
  101709. * Setup the ground diffuse texture according to the specified options.
  101710. */
  101711. private _setupGroundDiffuseTexture;
  101712. /**
  101713. * Setup the ground mirror texture according to the specified options.
  101714. */
  101715. private _setupGroundMirrorTexture;
  101716. /**
  101717. * Setup the ground to receive the mirror texture.
  101718. */
  101719. private _setupMirrorInGroundMaterial;
  101720. /**
  101721. * Setup the skybox according to the specified options.
  101722. */
  101723. private _setupSkybox;
  101724. /**
  101725. * Setup the skybox material according to the specified options.
  101726. */
  101727. private _setupSkyboxMaterial;
  101728. /**
  101729. * Setup the skybox reflection texture according to the specified options.
  101730. */
  101731. private _setupSkyboxReflectionTexture;
  101732. private _errorHandler;
  101733. /**
  101734. * Dispose all the elements created by the Helper.
  101735. */
  101736. dispose(): void;
  101737. }
  101738. }
  101739. declare module BABYLON {
  101740. /**
  101741. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  101742. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  101743. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  101744. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101745. */
  101746. export class PhotoDome extends TransformNode {
  101747. private _useDirectMapping;
  101748. /**
  101749. * The texture being displayed on the sphere
  101750. */
  101751. protected _photoTexture: Texture;
  101752. /**
  101753. * Gets or sets the texture being displayed on the sphere
  101754. */
  101755. photoTexture: Texture;
  101756. /**
  101757. * Observable raised when an error occured while loading the 360 image
  101758. */
  101759. onLoadErrorObservable: Observable<string>;
  101760. /**
  101761. * The skybox material
  101762. */
  101763. protected _material: BackgroundMaterial;
  101764. /**
  101765. * The surface used for the skybox
  101766. */
  101767. protected _mesh: Mesh;
  101768. /**
  101769. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101770. * Also see the options.resolution property.
  101771. */
  101772. fovMultiplier: number;
  101773. /**
  101774. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  101775. * @param name Element's name, child elements will append suffixes for their own names.
  101776. * @param urlsOfPhoto defines the url of the photo to display
  101777. * @param options defines an object containing optional or exposed sub element properties
  101778. * @param onError defines a callback called when an error occured while loading the texture
  101779. */
  101780. constructor(name: string, urlOfPhoto: string, options: {
  101781. resolution?: number;
  101782. size?: number;
  101783. useDirectMapping?: boolean;
  101784. faceForward?: boolean;
  101785. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  101786. /**
  101787. * Releases resources associated with this node.
  101788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101790. */
  101791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101792. }
  101793. }
  101794. declare module BABYLON {
  101795. /**
  101796. * Class used to host texture specific utilities
  101797. */
  101798. export class TextureTools {
  101799. /**
  101800. * Uses the GPU to create a copy texture rescaled at a given size
  101801. * @param texture Texture to copy from
  101802. * @param width defines the desired width
  101803. * @param height defines the desired height
  101804. * @param useBilinearMode defines if bilinear mode has to be used
  101805. * @return the generated texture
  101806. */
  101807. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  101808. /**
  101809. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101810. * @param scene defines the hosting scene
  101811. * @returns the environment BRDF texture
  101812. */
  101813. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101814. private static _environmentBRDFBase64Texture;
  101815. }
  101816. }
  101817. declare module BABYLON {
  101818. /**
  101819. * @hidden
  101820. */
  101821. export interface IMaterialClearCoatDefines {
  101822. CLEARCOAT: boolean;
  101823. CLEARCOAT_DEFAULTIOR: boolean;
  101824. CLEARCOAT_TEXTURE: boolean;
  101825. CLEARCOAT_TEXTUREDIRECTUV: number;
  101826. CLEARCOAT_BUMP: boolean;
  101827. CLEARCOAT_BUMPDIRECTUV: number;
  101828. CLEARCOAT_TINT: boolean;
  101829. CLEARCOAT_TINT_TEXTURE: boolean;
  101830. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101831. /** @hidden */
  101832. _areTexturesDirty: boolean;
  101833. }
  101834. /**
  101835. * Define the code related to the clear coat parameters of the pbr material.
  101836. */
  101837. export class PBRClearCoatConfiguration {
  101838. /**
  101839. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101840. * The default fits with a polyurethane material.
  101841. */
  101842. private static readonly _DefaultIndiceOfRefraction;
  101843. private _isEnabled;
  101844. /**
  101845. * Defines if the clear coat is enabled in the material.
  101846. */
  101847. isEnabled: boolean;
  101848. /**
  101849. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101850. */
  101851. intensity: number;
  101852. /**
  101853. * Defines the clear coat layer roughness.
  101854. */
  101855. roughness: number;
  101856. private _indiceOfRefraction;
  101857. /**
  101858. * Defines the indice of refraction of the clear coat.
  101859. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101860. * The default fits with a polyurethane material.
  101861. * Changing the default value is more performance intensive.
  101862. */
  101863. indiceOfRefraction: number;
  101864. private _texture;
  101865. /**
  101866. * Stores the clear coat values in a texture.
  101867. */
  101868. texture: Nullable<BaseTexture>;
  101869. private _bumpTexture;
  101870. /**
  101871. * Define the clear coat specific bump texture.
  101872. */
  101873. bumpTexture: Nullable<BaseTexture>;
  101874. private _isTintEnabled;
  101875. /**
  101876. * Defines if the clear coat tint is enabled in the material.
  101877. */
  101878. isTintEnabled: boolean;
  101879. /**
  101880. * Defines if the clear coat tint is enabled in the material.
  101881. * This is only use if tint is enabled
  101882. */
  101883. tintColor: Color3;
  101884. /**
  101885. * Defines if the distance at which the tint color should be found in the
  101886. * clear coat media.
  101887. * This is only use if tint is enabled
  101888. */
  101889. tintColorAtDistance: number;
  101890. /**
  101891. * Defines the clear coat layer thickness.
  101892. * This is only use if tint is enabled
  101893. */
  101894. tintThickness: number;
  101895. private _tintTexture;
  101896. /**
  101897. * Stores the clear tint values in a texture.
  101898. * rgb is tint
  101899. * a is a thickness factor
  101900. */
  101901. tintTexture: Nullable<BaseTexture>;
  101902. /** @hidden */
  101903. private _internalMarkAllSubMeshesAsTexturesDirty;
  101904. /** @hidden */
  101905. _markAllSubMeshesAsTexturesDirty(): void;
  101906. /**
  101907. * Instantiate a new istance of clear coat configuration.
  101908. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101909. */
  101910. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101911. /**
  101912. * Specifies that the submesh is ready to be used.
  101913. * @param defines the list of "defines" to update.
  101914. * @param scene defines the scene the material belongs to.
  101915. * @param engine defines the engine the material belongs to.
  101916. * @param disableBumpMap defines wether the material disables bump or not.
  101917. * @returns - boolean indicating that the submesh is ready or not.
  101918. */
  101919. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101920. /**
  101921. * Checks to see if a texture is used in the material.
  101922. * @param defines the list of "defines" to update.
  101923. * @param scene defines the scene to the material belongs to.
  101924. */
  101925. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101926. /**
  101927. * Binds the material data.
  101928. * @param uniformBuffer defines the Uniform buffer to fill in.
  101929. * @param scene defines the scene the material belongs to.
  101930. * @param engine defines the engine the material belongs to.
  101931. * @param disableBumpMap defines wether the material disables bump or not.
  101932. * @param isFrozen defines wether the material is frozen or not.
  101933. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101934. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101935. */
  101936. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  101937. /**
  101938. * Checks to see if a texture is used in the material.
  101939. * @param texture - Base texture to use.
  101940. * @returns - Boolean specifying if a texture is used in the material.
  101941. */
  101942. hasTexture(texture: BaseTexture): boolean;
  101943. /**
  101944. * Returns an array of the actively used textures.
  101945. * @param activeTextures Array of BaseTextures
  101946. */
  101947. getActiveTextures(activeTextures: BaseTexture[]): void;
  101948. /**
  101949. * Returns the animatable textures.
  101950. * @param animatables Array of animatable textures.
  101951. */
  101952. getAnimatables(animatables: IAnimatable[]): void;
  101953. /**
  101954. * Disposes the resources of the material.
  101955. * @param forceDisposeTextures - Forces the disposal of all textures.
  101956. */
  101957. dispose(forceDisposeTextures?: boolean): void;
  101958. /**
  101959. * Get the current class name of the texture useful for serialization or dynamic coding.
  101960. * @returns "PBRClearCoatConfiguration"
  101961. */
  101962. getClassName(): string;
  101963. /**
  101964. * Add fallbacks to the effect fallbacks list.
  101965. * @param defines defines the Base texture to use.
  101966. * @param fallbacks defines the current fallback list.
  101967. * @param currentRank defines the current fallback rank.
  101968. * @returns the new fallback rank.
  101969. */
  101970. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101971. /**
  101972. * Add the required uniforms to the current list.
  101973. * @param uniforms defines the current uniform list.
  101974. */
  101975. static AddUniforms(uniforms: string[]): void;
  101976. /**
  101977. * Add the required samplers to the current list.
  101978. * @param samplers defines the current sampler list.
  101979. */
  101980. static AddSamplers(samplers: string[]): void;
  101981. /**
  101982. * Add the required uniforms to the current buffer.
  101983. * @param uniformBuffer defines the current uniform buffer.
  101984. */
  101985. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101986. /**
  101987. * Makes a duplicate of the current configuration into another one.
  101988. * @param clearCoatConfiguration define the config where to copy the info
  101989. */
  101990. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101991. /**
  101992. * Serializes this clear coat configuration.
  101993. * @returns - An object with the serialized config.
  101994. */
  101995. serialize(): any;
  101996. /**
  101997. * Parses a Clear Coat Configuration from a serialized object.
  101998. * @param source - Serialized object.
  101999. */
  102000. parse(source: any): void;
  102001. }
  102002. }
  102003. declare module BABYLON {
  102004. /**
  102005. * @hidden
  102006. */
  102007. export interface IMaterialAnisotropicDefines {
  102008. ANISOTROPIC: boolean;
  102009. ANISOTROPIC_TEXTURE: boolean;
  102010. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102011. MAINUV1: boolean;
  102012. _areTexturesDirty: boolean;
  102013. _needUVs: boolean;
  102014. }
  102015. /**
  102016. * Define the code related to the anisotropic parameters of the pbr material.
  102017. */
  102018. export class PBRAnisotropicConfiguration {
  102019. private _isEnabled;
  102020. /**
  102021. * Defines if the anisotropy is enabled in the material.
  102022. */
  102023. isEnabled: boolean;
  102024. /**
  102025. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  102026. */
  102027. intensity: number;
  102028. /**
  102029. * Defines if the effect is along the tangents, bitangents or in between.
  102030. * By default, the effect is "strectching" the highlights along the tangents.
  102031. */
  102032. direction: Vector2;
  102033. private _texture;
  102034. /**
  102035. * Stores the anisotropy values in a texture.
  102036. * rg is direction (like normal from -1 to 1)
  102037. * b is a intensity
  102038. */
  102039. texture: Nullable<BaseTexture>;
  102040. /** @hidden */
  102041. private _internalMarkAllSubMeshesAsTexturesDirty;
  102042. /** @hidden */
  102043. _markAllSubMeshesAsTexturesDirty(): void;
  102044. /**
  102045. * Instantiate a new istance of anisotropy configuration.
  102046. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102047. */
  102048. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102049. /**
  102050. * Specifies that the submesh is ready to be used.
  102051. * @param defines the list of "defines" to update.
  102052. * @param scene defines the scene the material belongs to.
  102053. * @returns - boolean indicating that the submesh is ready or not.
  102054. */
  102055. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  102056. /**
  102057. * Checks to see if a texture is used in the material.
  102058. * @param defines the list of "defines" to update.
  102059. * @param mesh the mesh we are preparing the defines for.
  102060. * @param scene defines the scene the material belongs to.
  102061. */
  102062. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  102063. /**
  102064. * Binds the material data.
  102065. * @param uniformBuffer defines the Uniform buffer to fill in.
  102066. * @param scene defines the scene the material belongs to.
  102067. * @param isFrozen defines wether the material is frozen or not.
  102068. */
  102069. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102070. /**
  102071. * Checks to see if a texture is used in the material.
  102072. * @param texture - Base texture to use.
  102073. * @returns - Boolean specifying if a texture is used in the material.
  102074. */
  102075. hasTexture(texture: BaseTexture): boolean;
  102076. /**
  102077. * Returns an array of the actively used textures.
  102078. * @param activeTextures Array of BaseTextures
  102079. */
  102080. getActiveTextures(activeTextures: BaseTexture[]): void;
  102081. /**
  102082. * Returns the animatable textures.
  102083. * @param animatables Array of animatable textures.
  102084. */
  102085. getAnimatables(animatables: IAnimatable[]): void;
  102086. /**
  102087. * Disposes the resources of the material.
  102088. * @param forceDisposeTextures - Forces the disposal of all textures.
  102089. */
  102090. dispose(forceDisposeTextures?: boolean): void;
  102091. /**
  102092. * Get the current class name of the texture useful for serialization or dynamic coding.
  102093. * @returns "PBRAnisotropicConfiguration"
  102094. */
  102095. getClassName(): string;
  102096. /**
  102097. * Add fallbacks to the effect fallbacks list.
  102098. * @param defines defines the Base texture to use.
  102099. * @param fallbacks defines the current fallback list.
  102100. * @param currentRank defines the current fallback rank.
  102101. * @returns the new fallback rank.
  102102. */
  102103. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102104. /**
  102105. * Add the required uniforms to the current list.
  102106. * @param uniforms defines the current uniform list.
  102107. */
  102108. static AddUniforms(uniforms: string[]): void;
  102109. /**
  102110. * Add the required uniforms to the current buffer.
  102111. * @param uniformBuffer defines the current uniform buffer.
  102112. */
  102113. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102114. /**
  102115. * Add the required samplers to the current list.
  102116. * @param samplers defines the current sampler list.
  102117. */
  102118. static AddSamplers(samplers: string[]): void;
  102119. /**
  102120. * Makes a duplicate of the current configuration into another one.
  102121. * @param anisotropicConfiguration define the config where to copy the info
  102122. */
  102123. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  102124. /**
  102125. * Serializes this anisotropy configuration.
  102126. * @returns - An object with the serialized config.
  102127. */
  102128. serialize(): any;
  102129. /**
  102130. * Parses a anisotropy Configuration from a serialized object.
  102131. * @param source - Serialized object.
  102132. */
  102133. parse(source: any): void;
  102134. }
  102135. }
  102136. declare module BABYLON {
  102137. /**
  102138. * @hidden
  102139. */
  102140. export interface IMaterialBRDFDefines {
  102141. BRDF_V_HEIGHT_CORRELATED: boolean;
  102142. MS_BRDF_ENERGY_CONSERVATION: boolean;
  102143. /** @hidden */
  102144. _areMiscDirty: boolean;
  102145. }
  102146. /**
  102147. * Define the code related to the BRDF parameters of the pbr material.
  102148. */
  102149. export class PBRBRDFConfiguration {
  102150. /**
  102151. * Default value used for the energy conservation.
  102152. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  102153. */
  102154. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  102155. /**
  102156. * Default value used for the Smith Visibility Height Correlated mode.
  102157. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  102158. */
  102159. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  102160. private _useEnergyConservation;
  102161. /**
  102162. * Defines if the material uses energy conservation.
  102163. */
  102164. useEnergyConservation: boolean;
  102165. private _useSmithVisibilityHeightCorrelated;
  102166. /**
  102167. * LEGACY Mode set to false
  102168. * Defines if the material uses height smith correlated visibility term.
  102169. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  102170. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  102171. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  102172. * Not relying on height correlated will also disable energy conservation.
  102173. */
  102174. useSmithVisibilityHeightCorrelated: boolean;
  102175. /** @hidden */
  102176. private _internalMarkAllSubMeshesAsMiscDirty;
  102177. /** @hidden */
  102178. _markAllSubMeshesAsMiscDirty(): void;
  102179. /**
  102180. * Instantiate a new istance of clear coat configuration.
  102181. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  102182. */
  102183. constructor(markAllSubMeshesAsMiscDirty: () => void);
  102184. /**
  102185. * Checks to see if a texture is used in the material.
  102186. * @param defines the list of "defines" to update.
  102187. */
  102188. prepareDefines(defines: IMaterialBRDFDefines): void;
  102189. /**
  102190. * Get the current class name of the texture useful for serialization or dynamic coding.
  102191. * @returns "PBRClearCoatConfiguration"
  102192. */
  102193. getClassName(): string;
  102194. /**
  102195. * Makes a duplicate of the current configuration into another one.
  102196. * @param brdfConfiguration define the config where to copy the info
  102197. */
  102198. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  102199. /**
  102200. * Serializes this BRDF configuration.
  102201. * @returns - An object with the serialized config.
  102202. */
  102203. serialize(): any;
  102204. /**
  102205. * Parses a BRDF Configuration from a serialized object.
  102206. * @param source - Serialized object.
  102207. */
  102208. parse(source: any): void;
  102209. }
  102210. }
  102211. declare module BABYLON {
  102212. /**
  102213. * @hidden
  102214. */
  102215. export interface IMaterialSheenDefines {
  102216. SHEEN: boolean;
  102217. SHEEN_TEXTURE: boolean;
  102218. SHEEN_TEXTUREDIRECTUV: number;
  102219. SHEEN_LINKWITHALBEDO: boolean;
  102220. /** @hidden */
  102221. _areTexturesDirty: boolean;
  102222. }
  102223. /**
  102224. * Define the code related to the Sheen parameters of the pbr material.
  102225. */
  102226. export class PBRSheenConfiguration {
  102227. private _isEnabled;
  102228. /**
  102229. * Defines if the material uses sheen.
  102230. */
  102231. isEnabled: boolean;
  102232. private _linkSheenWithAlbedo;
  102233. /**
  102234. * Defines if the sheen is linked to the sheen color.
  102235. */
  102236. linkSheenWithAlbedo: boolean;
  102237. /**
  102238. * Defines the sheen intensity.
  102239. */
  102240. intensity: number;
  102241. /**
  102242. * Defines the sheen color.
  102243. */
  102244. color: Color3;
  102245. private _texture;
  102246. /**
  102247. * Stores the sheen tint values in a texture.
  102248. * rgb is tint
  102249. * a is a intensity
  102250. */
  102251. texture: Nullable<BaseTexture>;
  102252. /** @hidden */
  102253. private _internalMarkAllSubMeshesAsTexturesDirty;
  102254. /** @hidden */
  102255. _markAllSubMeshesAsTexturesDirty(): void;
  102256. /**
  102257. * Instantiate a new istance of clear coat configuration.
  102258. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102259. */
  102260. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102261. /**
  102262. * Specifies that the submesh is ready to be used.
  102263. * @param defines the list of "defines" to update.
  102264. * @param scene defines the scene the material belongs to.
  102265. * @returns - boolean indicating that the submesh is ready or not.
  102266. */
  102267. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  102268. /**
  102269. * Checks to see if a texture is used in the material.
  102270. * @param defines the list of "defines" to update.
  102271. * @param scene defines the scene the material belongs to.
  102272. */
  102273. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  102274. /**
  102275. * Binds the material data.
  102276. * @param uniformBuffer defines the Uniform buffer to fill in.
  102277. * @param scene defines the scene the material belongs to.
  102278. * @param isFrozen defines wether the material is frozen or not.
  102279. */
  102280. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102281. /**
  102282. * Checks to see if a texture is used in the material.
  102283. * @param texture - Base texture to use.
  102284. * @returns - Boolean specifying if a texture is used in the material.
  102285. */
  102286. hasTexture(texture: BaseTexture): boolean;
  102287. /**
  102288. * Returns an array of the actively used textures.
  102289. * @param activeTextures Array of BaseTextures
  102290. */
  102291. getActiveTextures(activeTextures: BaseTexture[]): void;
  102292. /**
  102293. * Returns the animatable textures.
  102294. * @param animatables Array of animatable textures.
  102295. */
  102296. getAnimatables(animatables: IAnimatable[]): void;
  102297. /**
  102298. * Disposes the resources of the material.
  102299. * @param forceDisposeTextures - Forces the disposal of all textures.
  102300. */
  102301. dispose(forceDisposeTextures?: boolean): void;
  102302. /**
  102303. * Get the current class name of the texture useful for serialization or dynamic coding.
  102304. * @returns "PBRSheenConfiguration"
  102305. */
  102306. getClassName(): string;
  102307. /**
  102308. * Add fallbacks to the effect fallbacks list.
  102309. * @param defines defines the Base texture to use.
  102310. * @param fallbacks defines the current fallback list.
  102311. * @param currentRank defines the current fallback rank.
  102312. * @returns the new fallback rank.
  102313. */
  102314. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102315. /**
  102316. * Add the required uniforms to the current list.
  102317. * @param uniforms defines the current uniform list.
  102318. */
  102319. static AddUniforms(uniforms: string[]): void;
  102320. /**
  102321. * Add the required uniforms to the current buffer.
  102322. * @param uniformBuffer defines the current uniform buffer.
  102323. */
  102324. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102325. /**
  102326. * Add the required samplers to the current list.
  102327. * @param samplers defines the current sampler list.
  102328. */
  102329. static AddSamplers(samplers: string[]): void;
  102330. /**
  102331. * Makes a duplicate of the current configuration into another one.
  102332. * @param sheenConfiguration define the config where to copy the info
  102333. */
  102334. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  102335. /**
  102336. * Serializes this BRDF configuration.
  102337. * @returns - An object with the serialized config.
  102338. */
  102339. serialize(): any;
  102340. /**
  102341. * Parses a Sheen Configuration from a serialized object.
  102342. * @param source - Serialized object.
  102343. */
  102344. parse(source: any): void;
  102345. }
  102346. }
  102347. declare module BABYLON {
  102348. /** @hidden */
  102349. export var pbrFragmentDeclaration: {
  102350. name: string;
  102351. shader: string;
  102352. };
  102353. }
  102354. declare module BABYLON {
  102355. /** @hidden */
  102356. export var pbrUboDeclaration: {
  102357. name: string;
  102358. shader: string;
  102359. };
  102360. }
  102361. declare module BABYLON {
  102362. /** @hidden */
  102363. export var pbrFragmentExtraDeclaration: {
  102364. name: string;
  102365. shader: string;
  102366. };
  102367. }
  102368. declare module BABYLON {
  102369. /** @hidden */
  102370. export var pbrFragmentSamplersDeclaration: {
  102371. name: string;
  102372. shader: string;
  102373. };
  102374. }
  102375. declare module BABYLON {
  102376. /** @hidden */
  102377. export var pbrHelperFunctions: {
  102378. name: string;
  102379. shader: string;
  102380. };
  102381. }
  102382. declare module BABYLON {
  102383. /** @hidden */
  102384. export var harmonicsFunctions: {
  102385. name: string;
  102386. shader: string;
  102387. };
  102388. }
  102389. declare module BABYLON {
  102390. /** @hidden */
  102391. export var pbrDirectLightingSetupFunctions: {
  102392. name: string;
  102393. shader: string;
  102394. };
  102395. }
  102396. declare module BABYLON {
  102397. /** @hidden */
  102398. export var pbrDirectLightingFalloffFunctions: {
  102399. name: string;
  102400. shader: string;
  102401. };
  102402. }
  102403. declare module BABYLON {
  102404. /** @hidden */
  102405. export var pbrBRDFFunctions: {
  102406. name: string;
  102407. shader: string;
  102408. };
  102409. }
  102410. declare module BABYLON {
  102411. /** @hidden */
  102412. export var pbrDirectLightingFunctions: {
  102413. name: string;
  102414. shader: string;
  102415. };
  102416. }
  102417. declare module BABYLON {
  102418. /** @hidden */
  102419. export var pbrIBLFunctions: {
  102420. name: string;
  102421. shader: string;
  102422. };
  102423. }
  102424. declare module BABYLON {
  102425. /** @hidden */
  102426. export var pbrDebug: {
  102427. name: string;
  102428. shader: string;
  102429. };
  102430. }
  102431. declare module BABYLON {
  102432. /** @hidden */
  102433. export var pbrPixelShader: {
  102434. name: string;
  102435. shader: string;
  102436. };
  102437. }
  102438. declare module BABYLON {
  102439. /** @hidden */
  102440. export var pbrVertexDeclaration: {
  102441. name: string;
  102442. shader: string;
  102443. };
  102444. }
  102445. declare module BABYLON {
  102446. /** @hidden */
  102447. export var pbrVertexShader: {
  102448. name: string;
  102449. shader: string;
  102450. };
  102451. }
  102452. declare module BABYLON {
  102453. /**
  102454. * The Physically based material base class of BJS.
  102455. *
  102456. * This offers the main features of a standard PBR material.
  102457. * For more information, please refer to the documentation :
  102458. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102459. */
  102460. export abstract class PBRBaseMaterial extends PushMaterial {
  102461. /**
  102462. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102463. */
  102464. static readonly PBRMATERIAL_OPAQUE: number;
  102465. /**
  102466. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102467. */
  102468. static readonly PBRMATERIAL_ALPHATEST: number;
  102469. /**
  102470. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102471. */
  102472. static readonly PBRMATERIAL_ALPHABLEND: number;
  102473. /**
  102474. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102475. * They are also discarded below the alpha cutoff threshold to improve performances.
  102476. */
  102477. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102478. /**
  102479. * Defines the default value of how much AO map is occluding the analytical lights
  102480. * (point spot...).
  102481. */
  102482. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102483. /**
  102484. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102485. */
  102486. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102487. /**
  102488. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102489. * to enhance interoperability with other engines.
  102490. */
  102491. static readonly LIGHTFALLOFF_GLTF: number;
  102492. /**
  102493. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102494. * to enhance interoperability with other materials.
  102495. */
  102496. static readonly LIGHTFALLOFF_STANDARD: number;
  102497. /**
  102498. * Intensity of the direct lights e.g. the four lights available in your scene.
  102499. * This impacts both the direct diffuse and specular highlights.
  102500. */
  102501. protected _directIntensity: number;
  102502. /**
  102503. * Intensity of the emissive part of the material.
  102504. * This helps controlling the emissive effect without modifying the emissive color.
  102505. */
  102506. protected _emissiveIntensity: number;
  102507. /**
  102508. * Intensity of the environment e.g. how much the environment will light the object
  102509. * either through harmonics for rough material or through the refelction for shiny ones.
  102510. */
  102511. protected _environmentIntensity: number;
  102512. /**
  102513. * This is a special control allowing the reduction of the specular highlights coming from the
  102514. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102515. */
  102516. protected _specularIntensity: number;
  102517. /**
  102518. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102519. */
  102520. private _lightingInfos;
  102521. /**
  102522. * Debug Control allowing disabling the bump map on this material.
  102523. */
  102524. protected _disableBumpMap: boolean;
  102525. /**
  102526. * AKA Diffuse Texture in standard nomenclature.
  102527. */
  102528. protected _albedoTexture: BaseTexture;
  102529. /**
  102530. * AKA Occlusion Texture in other nomenclature.
  102531. */
  102532. protected _ambientTexture: BaseTexture;
  102533. /**
  102534. * AKA Occlusion Texture Intensity in other nomenclature.
  102535. */
  102536. protected _ambientTextureStrength: number;
  102537. /**
  102538. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102539. * 1 means it completely occludes it
  102540. * 0 mean it has no impact
  102541. */
  102542. protected _ambientTextureImpactOnAnalyticalLights: number;
  102543. /**
  102544. * Stores the alpha values in a texture.
  102545. */
  102546. protected _opacityTexture: BaseTexture;
  102547. /**
  102548. * Stores the reflection values in a texture.
  102549. */
  102550. protected _reflectionTexture: BaseTexture;
  102551. /**
  102552. * Stores the refraction values in a texture.
  102553. */
  102554. protected _refractionTexture: BaseTexture;
  102555. /**
  102556. * Stores the emissive values in a texture.
  102557. */
  102558. protected _emissiveTexture: BaseTexture;
  102559. /**
  102560. * AKA Specular texture in other nomenclature.
  102561. */
  102562. protected _reflectivityTexture: BaseTexture;
  102563. /**
  102564. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102565. */
  102566. protected _metallicTexture: BaseTexture;
  102567. /**
  102568. * Specifies the metallic scalar of the metallic/roughness workflow.
  102569. * Can also be used to scale the metalness values of the metallic texture.
  102570. */
  102571. protected _metallic: Nullable<number>;
  102572. /**
  102573. * Specifies the roughness scalar of the metallic/roughness workflow.
  102574. * Can also be used to scale the roughness values of the metallic texture.
  102575. */
  102576. protected _roughness: Nullable<number>;
  102577. /**
  102578. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102579. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102580. */
  102581. protected _microSurfaceTexture: BaseTexture;
  102582. /**
  102583. * Stores surface normal data used to displace a mesh in a texture.
  102584. */
  102585. protected _bumpTexture: BaseTexture;
  102586. /**
  102587. * Stores the pre-calculated light information of a mesh in a texture.
  102588. */
  102589. protected _lightmapTexture: BaseTexture;
  102590. /**
  102591. * The color of a material in ambient lighting.
  102592. */
  102593. protected _ambientColor: Color3;
  102594. /**
  102595. * AKA Diffuse Color in other nomenclature.
  102596. */
  102597. protected _albedoColor: Color3;
  102598. /**
  102599. * AKA Specular Color in other nomenclature.
  102600. */
  102601. protected _reflectivityColor: Color3;
  102602. /**
  102603. * The color applied when light is reflected from a material.
  102604. */
  102605. protected _reflectionColor: Color3;
  102606. /**
  102607. * The color applied when light is emitted from a material.
  102608. */
  102609. protected _emissiveColor: Color3;
  102610. /**
  102611. * AKA Glossiness in other nomenclature.
  102612. */
  102613. protected _microSurface: number;
  102614. /**
  102615. * source material index of refraction (IOR)' / 'destination material IOR.
  102616. */
  102617. protected _indexOfRefraction: number;
  102618. /**
  102619. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102620. */
  102621. protected _invertRefractionY: boolean;
  102622. /**
  102623. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102624. * Materials half opaque for instance using refraction could benefit from this control.
  102625. */
  102626. protected _linkRefractionWithTransparency: boolean;
  102627. /**
  102628. * Specifies that the material will use the light map as a show map.
  102629. */
  102630. protected _useLightmapAsShadowmap: boolean;
  102631. /**
  102632. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102633. * makes the reflect vector face the model (under horizon).
  102634. */
  102635. protected _useHorizonOcclusion: boolean;
  102636. /**
  102637. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102638. * too much the area relying on ambient texture to define their ambient occlusion.
  102639. */
  102640. protected _useRadianceOcclusion: boolean;
  102641. /**
  102642. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102643. */
  102644. protected _useAlphaFromAlbedoTexture: boolean;
  102645. /**
  102646. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102647. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102648. */
  102649. protected _useSpecularOverAlpha: boolean;
  102650. /**
  102651. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102652. */
  102653. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102654. /**
  102655. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102656. */
  102657. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102658. /**
  102659. * Specifies if the metallic texture contains the roughness information in its green channel.
  102660. */
  102661. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102662. /**
  102663. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102664. */
  102665. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102666. /**
  102667. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102668. */
  102669. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102670. /**
  102671. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102672. */
  102673. protected _useAmbientInGrayScale: boolean;
  102674. /**
  102675. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102676. * The material will try to infer what glossiness each pixel should be.
  102677. */
  102678. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102679. /**
  102680. * Defines the falloff type used in this material.
  102681. * It by default is Physical.
  102682. */
  102683. protected _lightFalloff: number;
  102684. /**
  102685. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102686. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102687. */
  102688. protected _useRadianceOverAlpha: boolean;
  102689. /**
  102690. * Allows using an object space normal map (instead of tangent space).
  102691. */
  102692. protected _useObjectSpaceNormalMap: boolean;
  102693. /**
  102694. * Allows using the bump map in parallax mode.
  102695. */
  102696. protected _useParallax: boolean;
  102697. /**
  102698. * Allows using the bump map in parallax occlusion mode.
  102699. */
  102700. protected _useParallaxOcclusion: boolean;
  102701. /**
  102702. * Controls the scale bias of the parallax mode.
  102703. */
  102704. protected _parallaxScaleBias: number;
  102705. /**
  102706. * If sets to true, disables all the lights affecting the material.
  102707. */
  102708. protected _disableLighting: boolean;
  102709. /**
  102710. * Number of Simultaneous lights allowed on the material.
  102711. */
  102712. protected _maxSimultaneousLights: number;
  102713. /**
  102714. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102715. */
  102716. protected _invertNormalMapX: boolean;
  102717. /**
  102718. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102719. */
  102720. protected _invertNormalMapY: boolean;
  102721. /**
  102722. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102723. */
  102724. protected _twoSidedLighting: boolean;
  102725. /**
  102726. * Defines the alpha limits in alpha test mode.
  102727. */
  102728. protected _alphaCutOff: number;
  102729. /**
  102730. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102731. */
  102732. protected _forceAlphaTest: boolean;
  102733. /**
  102734. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102735. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102736. */
  102737. protected _useAlphaFresnel: boolean;
  102738. /**
  102739. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102740. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102741. */
  102742. protected _useLinearAlphaFresnel: boolean;
  102743. /**
  102744. * The transparency mode of the material.
  102745. */
  102746. protected _transparencyMode: Nullable<number>;
  102747. /**
  102748. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102749. * from cos thetav and roughness:
  102750. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102751. */
  102752. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102753. /**
  102754. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102755. */
  102756. protected _forceIrradianceInFragment: boolean;
  102757. /**
  102758. * Force normal to face away from face.
  102759. */
  102760. protected _forceNormalForward: boolean;
  102761. /**
  102762. * Enables specular anti aliasing in the PBR shader.
  102763. * It will both interacts on the Geometry for analytical and IBL lighting.
  102764. * It also prefilter the roughness map based on the bump values.
  102765. */
  102766. protected _enableSpecularAntiAliasing: boolean;
  102767. /**
  102768. * Default configuration related to image processing available in the PBR Material.
  102769. */
  102770. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102771. /**
  102772. * Keep track of the image processing observer to allow dispose and replace.
  102773. */
  102774. private _imageProcessingObserver;
  102775. /**
  102776. * Attaches a new image processing configuration to the PBR Material.
  102777. * @param configuration
  102778. */
  102779. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102780. /**
  102781. * Stores the available render targets.
  102782. */
  102783. private _renderTargets;
  102784. /**
  102785. * Sets the global ambient color for the material used in lighting calculations.
  102786. */
  102787. private _globalAmbientColor;
  102788. /**
  102789. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102790. */
  102791. private _useLogarithmicDepth;
  102792. /**
  102793. * If set to true, no lighting calculations will be applied.
  102794. */
  102795. private _unlit;
  102796. private _debugMode;
  102797. /**
  102798. * @hidden
  102799. * This is reserved for the inspector.
  102800. * Defines the material debug mode.
  102801. * It helps seeing only some components of the material while troubleshooting.
  102802. */
  102803. debugMode: number;
  102804. /**
  102805. * @hidden
  102806. * This is reserved for the inspector.
  102807. * Specify from where on screen the debug mode should start.
  102808. * The value goes from -1 (full screen) to 1 (not visible)
  102809. * It helps with side by side comparison against the final render
  102810. * This defaults to -1
  102811. */
  102812. private debugLimit;
  102813. /**
  102814. * @hidden
  102815. * This is reserved for the inspector.
  102816. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102817. * You can use the factor to better multiply the final value.
  102818. */
  102819. private debugFactor;
  102820. /**
  102821. * Defines the clear coat layer parameters for the material.
  102822. */
  102823. readonly clearCoat: PBRClearCoatConfiguration;
  102824. /**
  102825. * Defines the anisotropic parameters for the material.
  102826. */
  102827. readonly anisotropy: PBRAnisotropicConfiguration;
  102828. /**
  102829. * Defines the BRDF parameters for the material.
  102830. */
  102831. readonly brdf: PBRBRDFConfiguration;
  102832. /**
  102833. * Defines the Sheen parameters for the material.
  102834. */
  102835. readonly sheen: PBRSheenConfiguration;
  102836. /**
  102837. * Instantiates a new PBRMaterial instance.
  102838. *
  102839. * @param name The material name
  102840. * @param scene The scene the material will be use in.
  102841. */
  102842. constructor(name: string, scene: Scene);
  102843. /**
  102844. * Gets a boolean indicating that current material needs to register RTT
  102845. */
  102846. readonly hasRenderTargetTextures: boolean;
  102847. /**
  102848. * Gets the name of the material class.
  102849. */
  102850. getClassName(): string;
  102851. /**
  102852. * Gets the name of the material shader.
  102853. * @returns - string that specifies the shader program of the material.
  102854. */
  102855. getShaderName(): string;
  102856. /**
  102857. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102858. */
  102859. /**
  102860. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102861. */
  102862. useLogarithmicDepth: boolean;
  102863. /**
  102864. * Gets the current transparency mode.
  102865. */
  102866. /**
  102867. * Sets the transparency mode of the material.
  102868. *
  102869. * | Value | Type | Description |
  102870. * | ----- | ----------------------------------- | ----------- |
  102871. * | 0 | OPAQUE | |
  102872. * | 1 | ALPHATEST | |
  102873. * | 2 | ALPHABLEND | |
  102874. * | 3 | ALPHATESTANDBLEND | |
  102875. *
  102876. */
  102877. transparencyMode: Nullable<number>;
  102878. /**
  102879. * Returns true if alpha blending should be disabled.
  102880. */
  102881. private readonly _disableAlphaBlending;
  102882. /**
  102883. * Specifies whether or not this material should be rendered in alpha blend mode.
  102884. */
  102885. needAlphaBlending(): boolean;
  102886. /**
  102887. * Specifies if the mesh will require alpha blending.
  102888. * @param mesh - BJS mesh.
  102889. */
  102890. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102891. /**
  102892. * Specifies whether or not this material should be rendered in alpha test mode.
  102893. */
  102894. needAlphaTesting(): boolean;
  102895. /**
  102896. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102897. */
  102898. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102899. /**
  102900. * Gets the texture used for the alpha test.
  102901. */
  102902. getAlphaTestTexture(): BaseTexture;
  102903. /**
  102904. * Specifies that the submesh is ready to be used.
  102905. * @param mesh - BJS mesh.
  102906. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102907. * @param useInstances - Specifies that instances should be used.
  102908. * @returns - boolean indicating that the submesh is ready or not.
  102909. */
  102910. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102911. /**
  102912. * Specifies if the material uses metallic roughness workflow.
  102913. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102914. */
  102915. isMetallicWorkflow(): boolean;
  102916. private _prepareEffect;
  102917. private _prepareDefines;
  102918. /**
  102919. * Force shader compilation
  102920. */
  102921. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  102922. clipPlane: boolean;
  102923. }>): void;
  102924. /**
  102925. * Initializes the uniform buffer layout for the shader.
  102926. */
  102927. buildUniformLayout(): void;
  102928. /**
  102929. * Unbinds the textures.
  102930. */
  102931. unbind(): void;
  102932. /**
  102933. * Binds the submesh data.
  102934. * @param world - The world matrix.
  102935. * @param mesh - The BJS mesh.
  102936. * @param subMesh - A submesh of the BJS mesh.
  102937. */
  102938. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102939. /**
  102940. * Returns the animatable textures.
  102941. * @returns - Array of animatable textures.
  102942. */
  102943. getAnimatables(): IAnimatable[];
  102944. /**
  102945. * Returns the texture used for reflections.
  102946. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102947. */
  102948. private _getReflectionTexture;
  102949. /**
  102950. * Returns the texture used for refraction or null if none is used.
  102951. * @returns - Refection texture if present. If no refraction texture and refraction
  102952. * is linked with transparency, returns environment texture. Otherwise, returns null.
  102953. */
  102954. private _getRefractionTexture;
  102955. /**
  102956. * Returns an array of the actively used textures.
  102957. * @returns - Array of BaseTextures
  102958. */
  102959. getActiveTextures(): BaseTexture[];
  102960. /**
  102961. * Checks to see if a texture is used in the material.
  102962. * @param texture - Base texture to use.
  102963. * @returns - Boolean specifying if a texture is used in the material.
  102964. */
  102965. hasTexture(texture: BaseTexture): boolean;
  102966. /**
  102967. * Disposes the resources of the material.
  102968. * @param forceDisposeEffect - Forces the disposal of effects.
  102969. * @param forceDisposeTextures - Forces the disposal of all textures.
  102970. */
  102971. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102972. }
  102973. }
  102974. declare module BABYLON {
  102975. /**
  102976. * The Physically based material of BJS.
  102977. *
  102978. * This offers the main features of a standard PBR material.
  102979. * For more information, please refer to the documentation :
  102980. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102981. */
  102982. export class PBRMaterial extends PBRBaseMaterial {
  102983. /**
  102984. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102985. */
  102986. static readonly PBRMATERIAL_OPAQUE: number;
  102987. /**
  102988. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102989. */
  102990. static readonly PBRMATERIAL_ALPHATEST: number;
  102991. /**
  102992. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102993. */
  102994. static readonly PBRMATERIAL_ALPHABLEND: number;
  102995. /**
  102996. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102997. * They are also discarded below the alpha cutoff threshold to improve performances.
  102998. */
  102999. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103000. /**
  103001. * Defines the default value of how much AO map is occluding the analytical lights
  103002. * (point spot...).
  103003. */
  103004. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103005. /**
  103006. * Intensity of the direct lights e.g. the four lights available in your scene.
  103007. * This impacts both the direct diffuse and specular highlights.
  103008. */
  103009. directIntensity: number;
  103010. /**
  103011. * Intensity of the emissive part of the material.
  103012. * This helps controlling the emissive effect without modifying the emissive color.
  103013. */
  103014. emissiveIntensity: number;
  103015. /**
  103016. * Intensity of the environment e.g. how much the environment will light the object
  103017. * either through harmonics for rough material or through the refelction for shiny ones.
  103018. */
  103019. environmentIntensity: number;
  103020. /**
  103021. * This is a special control allowing the reduction of the specular highlights coming from the
  103022. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103023. */
  103024. specularIntensity: number;
  103025. /**
  103026. * Debug Control allowing disabling the bump map on this material.
  103027. */
  103028. disableBumpMap: boolean;
  103029. /**
  103030. * AKA Diffuse Texture in standard nomenclature.
  103031. */
  103032. albedoTexture: BaseTexture;
  103033. /**
  103034. * AKA Occlusion Texture in other nomenclature.
  103035. */
  103036. ambientTexture: BaseTexture;
  103037. /**
  103038. * AKA Occlusion Texture Intensity in other nomenclature.
  103039. */
  103040. ambientTextureStrength: number;
  103041. /**
  103042. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103043. * 1 means it completely occludes it
  103044. * 0 mean it has no impact
  103045. */
  103046. ambientTextureImpactOnAnalyticalLights: number;
  103047. /**
  103048. * Stores the alpha values in a texture.
  103049. */
  103050. opacityTexture: BaseTexture;
  103051. /**
  103052. * Stores the reflection values in a texture.
  103053. */
  103054. reflectionTexture: Nullable<BaseTexture>;
  103055. /**
  103056. * Stores the emissive values in a texture.
  103057. */
  103058. emissiveTexture: BaseTexture;
  103059. /**
  103060. * AKA Specular texture in other nomenclature.
  103061. */
  103062. reflectivityTexture: BaseTexture;
  103063. /**
  103064. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103065. */
  103066. metallicTexture: BaseTexture;
  103067. /**
  103068. * Specifies the metallic scalar of the metallic/roughness workflow.
  103069. * Can also be used to scale the metalness values of the metallic texture.
  103070. */
  103071. metallic: Nullable<number>;
  103072. /**
  103073. * Specifies the roughness scalar of the metallic/roughness workflow.
  103074. * Can also be used to scale the roughness values of the metallic texture.
  103075. */
  103076. roughness: Nullable<number>;
  103077. /**
  103078. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103079. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103080. */
  103081. microSurfaceTexture: BaseTexture;
  103082. /**
  103083. * Stores surface normal data used to displace a mesh in a texture.
  103084. */
  103085. bumpTexture: BaseTexture;
  103086. /**
  103087. * Stores the pre-calculated light information of a mesh in a texture.
  103088. */
  103089. lightmapTexture: BaseTexture;
  103090. /**
  103091. * Stores the refracted light information in a texture.
  103092. */
  103093. refractionTexture: BaseTexture;
  103094. /**
  103095. * The color of a material in ambient lighting.
  103096. */
  103097. ambientColor: Color3;
  103098. /**
  103099. * AKA Diffuse Color in other nomenclature.
  103100. */
  103101. albedoColor: Color3;
  103102. /**
  103103. * AKA Specular Color in other nomenclature.
  103104. */
  103105. reflectivityColor: Color3;
  103106. /**
  103107. * The color reflected from the material.
  103108. */
  103109. reflectionColor: Color3;
  103110. /**
  103111. * The color emitted from the material.
  103112. */
  103113. emissiveColor: Color3;
  103114. /**
  103115. * AKA Glossiness in other nomenclature.
  103116. */
  103117. microSurface: number;
  103118. /**
  103119. * source material index of refraction (IOR)' / 'destination material IOR.
  103120. */
  103121. indexOfRefraction: number;
  103122. /**
  103123. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103124. */
  103125. invertRefractionY: boolean;
  103126. /**
  103127. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103128. * Materials half opaque for instance using refraction could benefit from this control.
  103129. */
  103130. linkRefractionWithTransparency: boolean;
  103131. /**
  103132. * If true, the light map contains occlusion information instead of lighting info.
  103133. */
  103134. useLightmapAsShadowmap: boolean;
  103135. /**
  103136. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103137. */
  103138. useAlphaFromAlbedoTexture: boolean;
  103139. /**
  103140. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103141. */
  103142. forceAlphaTest: boolean;
  103143. /**
  103144. * Defines the alpha limits in alpha test mode.
  103145. */
  103146. alphaCutOff: number;
  103147. /**
  103148. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103149. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103150. */
  103151. useSpecularOverAlpha: boolean;
  103152. /**
  103153. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103154. */
  103155. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103156. /**
  103157. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103158. */
  103159. useRoughnessFromMetallicTextureAlpha: boolean;
  103160. /**
  103161. * Specifies if the metallic texture contains the roughness information in its green channel.
  103162. */
  103163. useRoughnessFromMetallicTextureGreen: boolean;
  103164. /**
  103165. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103166. */
  103167. useMetallnessFromMetallicTextureBlue: boolean;
  103168. /**
  103169. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103170. */
  103171. useAmbientOcclusionFromMetallicTextureRed: boolean;
  103172. /**
  103173. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103174. */
  103175. useAmbientInGrayScale: boolean;
  103176. /**
  103177. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103178. * The material will try to infer what glossiness each pixel should be.
  103179. */
  103180. useAutoMicroSurfaceFromReflectivityMap: boolean;
  103181. /**
  103182. * BJS is using an harcoded light falloff based on a manually sets up range.
  103183. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103184. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103185. */
  103186. /**
  103187. * BJS is using an harcoded light falloff based on a manually sets up range.
  103188. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103189. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103190. */
  103191. usePhysicalLightFalloff: boolean;
  103192. /**
  103193. * In order to support the falloff compatibility with gltf, a special mode has been added
  103194. * to reproduce the gltf light falloff.
  103195. */
  103196. /**
  103197. * In order to support the falloff compatibility with gltf, a special mode has been added
  103198. * to reproduce the gltf light falloff.
  103199. */
  103200. useGLTFLightFalloff: boolean;
  103201. /**
  103202. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103203. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103204. */
  103205. useRadianceOverAlpha: boolean;
  103206. /**
  103207. * Allows using an object space normal map (instead of tangent space).
  103208. */
  103209. useObjectSpaceNormalMap: boolean;
  103210. /**
  103211. * Allows using the bump map in parallax mode.
  103212. */
  103213. useParallax: boolean;
  103214. /**
  103215. * Allows using the bump map in parallax occlusion mode.
  103216. */
  103217. useParallaxOcclusion: boolean;
  103218. /**
  103219. * Controls the scale bias of the parallax mode.
  103220. */
  103221. parallaxScaleBias: number;
  103222. /**
  103223. * If sets to true, disables all the lights affecting the material.
  103224. */
  103225. disableLighting: boolean;
  103226. /**
  103227. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103228. */
  103229. forceIrradianceInFragment: boolean;
  103230. /**
  103231. * Number of Simultaneous lights allowed on the material.
  103232. */
  103233. maxSimultaneousLights: number;
  103234. /**
  103235. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103236. */
  103237. invertNormalMapX: boolean;
  103238. /**
  103239. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103240. */
  103241. invertNormalMapY: boolean;
  103242. /**
  103243. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103244. */
  103245. twoSidedLighting: boolean;
  103246. /**
  103247. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103248. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103249. */
  103250. useAlphaFresnel: boolean;
  103251. /**
  103252. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103253. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103254. */
  103255. useLinearAlphaFresnel: boolean;
  103256. /**
  103257. * Let user defines the brdf lookup texture used for IBL.
  103258. * A default 8bit version is embedded but you could point at :
  103259. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  103260. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103261. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103262. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103263. */
  103264. environmentBRDFTexture: Nullable<BaseTexture>;
  103265. /**
  103266. * Force normal to face away from face.
  103267. */
  103268. forceNormalForward: boolean;
  103269. /**
  103270. * Enables specular anti aliasing in the PBR shader.
  103271. * It will both interacts on the Geometry for analytical and IBL lighting.
  103272. * It also prefilter the roughness map based on the bump values.
  103273. */
  103274. enableSpecularAntiAliasing: boolean;
  103275. /**
  103276. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103277. * makes the reflect vector face the model (under horizon).
  103278. */
  103279. useHorizonOcclusion: boolean;
  103280. /**
  103281. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103282. * too much the area relying on ambient texture to define their ambient occlusion.
  103283. */
  103284. useRadianceOcclusion: boolean;
  103285. /**
  103286. * If set to true, no lighting calculations will be applied.
  103287. */
  103288. unlit: boolean;
  103289. /**
  103290. * Gets the image processing configuration used either in this material.
  103291. */
  103292. /**
  103293. * Sets the Default image processing configuration used either in the this material.
  103294. *
  103295. * If sets to null, the scene one is in use.
  103296. */
  103297. imageProcessingConfiguration: ImageProcessingConfiguration;
  103298. /**
  103299. * Gets wether the color curves effect is enabled.
  103300. */
  103301. /**
  103302. * Sets wether the color curves effect is enabled.
  103303. */
  103304. cameraColorCurvesEnabled: boolean;
  103305. /**
  103306. * Gets wether the color grading effect is enabled.
  103307. */
  103308. /**
  103309. * Gets wether the color grading effect is enabled.
  103310. */
  103311. cameraColorGradingEnabled: boolean;
  103312. /**
  103313. * Gets wether tonemapping is enabled or not.
  103314. */
  103315. /**
  103316. * Sets wether tonemapping is enabled or not
  103317. */
  103318. cameraToneMappingEnabled: boolean;
  103319. /**
  103320. * The camera exposure used on this material.
  103321. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103322. * This corresponds to a photographic exposure.
  103323. */
  103324. /**
  103325. * The camera exposure used on this material.
  103326. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103327. * This corresponds to a photographic exposure.
  103328. */
  103329. cameraExposure: number;
  103330. /**
  103331. * Gets The camera contrast used on this material.
  103332. */
  103333. /**
  103334. * Sets The camera contrast used on this material.
  103335. */
  103336. cameraContrast: number;
  103337. /**
  103338. * Gets the Color Grading 2D Lookup Texture.
  103339. */
  103340. /**
  103341. * Sets the Color Grading 2D Lookup Texture.
  103342. */
  103343. cameraColorGradingTexture: Nullable<BaseTexture>;
  103344. /**
  103345. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103346. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103347. * 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;
  103348. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103349. */
  103350. /**
  103351. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103352. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103353. * 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;
  103354. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103355. */
  103356. cameraColorCurves: Nullable<ColorCurves>;
  103357. /**
  103358. * Instantiates a new PBRMaterial instance.
  103359. *
  103360. * @param name The material name
  103361. * @param scene The scene the material will be use in.
  103362. */
  103363. constructor(name: string, scene: Scene);
  103364. /**
  103365. * Returns the name of this material class.
  103366. */
  103367. getClassName(): string;
  103368. /**
  103369. * Makes a duplicate of the current material.
  103370. * @param name - name to use for the new material.
  103371. */
  103372. clone(name: string): PBRMaterial;
  103373. /**
  103374. * Serializes this PBR Material.
  103375. * @returns - An object with the serialized material.
  103376. */
  103377. serialize(): any;
  103378. /**
  103379. * Parses a PBR Material from a serialized object.
  103380. * @param source - Serialized object.
  103381. * @param scene - BJS scene instance.
  103382. * @param rootUrl - url for the scene object
  103383. * @returns - PBRMaterial
  103384. */
  103385. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103386. }
  103387. }
  103388. declare module BABYLON {
  103389. /**
  103390. * Direct draw surface info
  103391. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103392. */
  103393. export interface DDSInfo {
  103394. /**
  103395. * Width of the texture
  103396. */
  103397. width: number;
  103398. /**
  103399. * Width of the texture
  103400. */
  103401. height: number;
  103402. /**
  103403. * Number of Mipmaps for the texture
  103404. * @see https://en.wikipedia.org/wiki/Mipmap
  103405. */
  103406. mipmapCount: number;
  103407. /**
  103408. * If the textures format is a known fourCC format
  103409. * @see https://www.fourcc.org/
  103410. */
  103411. isFourCC: boolean;
  103412. /**
  103413. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103414. */
  103415. isRGB: boolean;
  103416. /**
  103417. * If the texture is a lumincance format
  103418. */
  103419. isLuminance: boolean;
  103420. /**
  103421. * If this is a cube texture
  103422. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103423. */
  103424. isCube: boolean;
  103425. /**
  103426. * If the texture is a compressed format eg. FOURCC_DXT1
  103427. */
  103428. isCompressed: boolean;
  103429. /**
  103430. * The dxgiFormat of the texture
  103431. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103432. */
  103433. dxgiFormat: number;
  103434. /**
  103435. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103436. */
  103437. textureType: number;
  103438. /**
  103439. * Sphericle polynomial created for the dds texture
  103440. */
  103441. sphericalPolynomial?: SphericalPolynomial;
  103442. }
  103443. /**
  103444. * Class used to provide DDS decompression tools
  103445. */
  103446. export class DDSTools {
  103447. /**
  103448. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103449. */
  103450. static StoreLODInAlphaChannel: boolean;
  103451. /**
  103452. * Gets DDS information from an array buffer
  103453. * @param arrayBuffer defines the array buffer to read data from
  103454. * @returns the DDS information
  103455. */
  103456. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103457. private static _FloatView;
  103458. private static _Int32View;
  103459. private static _ToHalfFloat;
  103460. private static _FromHalfFloat;
  103461. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103462. private static _GetHalfFloatRGBAArrayBuffer;
  103463. private static _GetFloatRGBAArrayBuffer;
  103464. private static _GetFloatAsUIntRGBAArrayBuffer;
  103465. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103466. private static _GetRGBAArrayBuffer;
  103467. private static _ExtractLongWordOrder;
  103468. private static _GetRGBArrayBuffer;
  103469. private static _GetLuminanceArrayBuffer;
  103470. /**
  103471. * Uploads DDS Levels to a Babylon Texture
  103472. * @hidden
  103473. */
  103474. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103475. }
  103476. interface Engine {
  103477. /**
  103478. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103479. * @param rootUrl defines the url where the file to load is located
  103480. * @param scene defines the current scene
  103481. * @param lodScale defines scale to apply to the mip map selection
  103482. * @param lodOffset defines offset to apply to the mip map selection
  103483. * @param onLoad defines an optional callback raised when the texture is loaded
  103484. * @param onError defines an optional callback raised if there is an issue to load the texture
  103485. * @param format defines the format of the data
  103486. * @param forcedExtension defines the extension to use to pick the right loader
  103487. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103488. * @returns the cube texture as an InternalTexture
  103489. */
  103490. 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;
  103491. }
  103492. }
  103493. declare module BABYLON {
  103494. /**
  103495. * Implementation of the DDS Texture Loader.
  103496. * @hidden
  103497. */
  103498. export class _DDSTextureLoader implements IInternalTextureLoader {
  103499. /**
  103500. * Defines wether the loader supports cascade loading the different faces.
  103501. */
  103502. readonly supportCascades: boolean;
  103503. /**
  103504. * This returns if the loader support the current file information.
  103505. * @param extension defines the file extension of the file being loaded
  103506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103507. * @param fallback defines the fallback internal texture if any
  103508. * @param isBase64 defines whether the texture is encoded as a base64
  103509. * @param isBuffer defines whether the texture data are stored as a buffer
  103510. * @returns true if the loader can load the specified file
  103511. */
  103512. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103513. /**
  103514. * Transform the url before loading if required.
  103515. * @param rootUrl the url of the texture
  103516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103517. * @returns the transformed texture
  103518. */
  103519. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103520. /**
  103521. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103522. * @param rootUrl the url of the texture
  103523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103524. * @returns the fallback texture
  103525. */
  103526. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103527. /**
  103528. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103529. * @param data contains the texture data
  103530. * @param texture defines the BabylonJS internal texture
  103531. * @param createPolynomials will be true if polynomials have been requested
  103532. * @param onLoad defines the callback to trigger once the texture is ready
  103533. * @param onError defines the callback to trigger in case of error
  103534. */
  103535. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103536. /**
  103537. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103538. * @param data contains the texture data
  103539. * @param texture defines the BabylonJS internal texture
  103540. * @param callback defines the method to call once ready to upload
  103541. */
  103542. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103543. }
  103544. }
  103545. declare module BABYLON {
  103546. /** @hidden */
  103547. export var rgbdEncodePixelShader: {
  103548. name: string;
  103549. shader: string;
  103550. };
  103551. }
  103552. declare module BABYLON {
  103553. /** @hidden */
  103554. export var rgbdDecodePixelShader: {
  103555. name: string;
  103556. shader: string;
  103557. };
  103558. }
  103559. declare module BABYLON {
  103560. /**
  103561. * Raw texture data and descriptor sufficient for WebGL texture upload
  103562. */
  103563. export interface EnvironmentTextureInfo {
  103564. /**
  103565. * Version of the environment map
  103566. */
  103567. version: number;
  103568. /**
  103569. * Width of image
  103570. */
  103571. width: number;
  103572. /**
  103573. * Irradiance information stored in the file.
  103574. */
  103575. irradiance: any;
  103576. /**
  103577. * Specular information stored in the file.
  103578. */
  103579. specular: any;
  103580. }
  103581. /**
  103582. * Sets of helpers addressing the serialization and deserialization of environment texture
  103583. * stored in a BabylonJS env file.
  103584. * Those files are usually stored as .env files.
  103585. */
  103586. export class EnvironmentTextureTools {
  103587. /**
  103588. * Magic number identifying the env file.
  103589. */
  103590. private static _MagicBytes;
  103591. /**
  103592. * Gets the environment info from an env file.
  103593. * @param data The array buffer containing the .env bytes.
  103594. * @returns the environment file info (the json header) if successfully parsed.
  103595. */
  103596. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103597. /**
  103598. * Creates an environment texture from a loaded cube texture.
  103599. * @param texture defines the cube texture to convert in env file
  103600. * @return a promise containing the environment data if succesfull.
  103601. */
  103602. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103603. /**
  103604. * Creates a JSON representation of the spherical data.
  103605. * @param texture defines the texture containing the polynomials
  103606. * @return the JSON representation of the spherical info
  103607. */
  103608. private static _CreateEnvTextureIrradiance;
  103609. /**
  103610. * Uploads the texture info contained in the env file to the GPU.
  103611. * @param texture defines the internal texture to upload to
  103612. * @param arrayBuffer defines the buffer cotaining the data to load
  103613. * @param info defines the texture info retrieved through the GetEnvInfo method
  103614. * @returns a promise
  103615. */
  103616. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103617. /**
  103618. * Uploads the levels of image data to the GPU.
  103619. * @param texture defines the internal texture to upload to
  103620. * @param imageData defines the array buffer views of image data [mipmap][face]
  103621. * @returns a promise
  103622. */
  103623. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103624. /**
  103625. * Uploads spherical polynomials information to the texture.
  103626. * @param texture defines the texture we are trying to upload the information to
  103627. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103628. */
  103629. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103630. /** @hidden */
  103631. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103632. }
  103633. }
  103634. declare module BABYLON {
  103635. /**
  103636. * Implementation of the ENV Texture Loader.
  103637. * @hidden
  103638. */
  103639. export class _ENVTextureLoader implements IInternalTextureLoader {
  103640. /**
  103641. * Defines wether the loader supports cascade loading the different faces.
  103642. */
  103643. readonly supportCascades: boolean;
  103644. /**
  103645. * This returns if the loader support the current file information.
  103646. * @param extension defines the file extension of the file being loaded
  103647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103648. * @param fallback defines the fallback internal texture if any
  103649. * @param isBase64 defines whether the texture is encoded as a base64
  103650. * @param isBuffer defines whether the texture data are stored as a buffer
  103651. * @returns true if the loader can load the specified file
  103652. */
  103653. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103654. /**
  103655. * Transform the url before loading if required.
  103656. * @param rootUrl the url of the texture
  103657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103658. * @returns the transformed texture
  103659. */
  103660. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103661. /**
  103662. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103663. * @param rootUrl the url of the texture
  103664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103665. * @returns the fallback texture
  103666. */
  103667. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103668. /**
  103669. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103670. * @param data contains the texture data
  103671. * @param texture defines the BabylonJS internal texture
  103672. * @param createPolynomials will be true if polynomials have been requested
  103673. * @param onLoad defines the callback to trigger once the texture is ready
  103674. * @param onError defines the callback to trigger in case of error
  103675. */
  103676. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103677. /**
  103678. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103679. * @param data contains the texture data
  103680. * @param texture defines the BabylonJS internal texture
  103681. * @param callback defines the method to call once ready to upload
  103682. */
  103683. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103684. }
  103685. }
  103686. declare module BABYLON {
  103687. /**
  103688. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103689. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103690. */
  103691. export class KhronosTextureContainer {
  103692. /** contents of the KTX container file */
  103693. arrayBuffer: any;
  103694. private static HEADER_LEN;
  103695. private static COMPRESSED_2D;
  103696. private static COMPRESSED_3D;
  103697. private static TEX_2D;
  103698. private static TEX_3D;
  103699. /**
  103700. * Gets the openGL type
  103701. */
  103702. glType: number;
  103703. /**
  103704. * Gets the openGL type size
  103705. */
  103706. glTypeSize: number;
  103707. /**
  103708. * Gets the openGL format
  103709. */
  103710. glFormat: number;
  103711. /**
  103712. * Gets the openGL internal format
  103713. */
  103714. glInternalFormat: number;
  103715. /**
  103716. * Gets the base internal format
  103717. */
  103718. glBaseInternalFormat: number;
  103719. /**
  103720. * Gets image width in pixel
  103721. */
  103722. pixelWidth: number;
  103723. /**
  103724. * Gets image height in pixel
  103725. */
  103726. pixelHeight: number;
  103727. /**
  103728. * Gets image depth in pixels
  103729. */
  103730. pixelDepth: number;
  103731. /**
  103732. * Gets the number of array elements
  103733. */
  103734. numberOfArrayElements: number;
  103735. /**
  103736. * Gets the number of faces
  103737. */
  103738. numberOfFaces: number;
  103739. /**
  103740. * Gets the number of mipmap levels
  103741. */
  103742. numberOfMipmapLevels: number;
  103743. /**
  103744. * Gets the bytes of key value data
  103745. */
  103746. bytesOfKeyValueData: number;
  103747. /**
  103748. * Gets the load type
  103749. */
  103750. loadType: number;
  103751. /**
  103752. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103753. */
  103754. isInvalid: boolean;
  103755. /**
  103756. * Creates a new KhronosTextureContainer
  103757. * @param arrayBuffer contents of the KTX container file
  103758. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103759. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103760. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103761. */
  103762. constructor(
  103763. /** contents of the KTX container file */
  103764. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103765. /**
  103766. * Uploads KTX content to a Babylon Texture.
  103767. * It is assumed that the texture has already been created & is currently bound
  103768. * @hidden
  103769. */
  103770. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103771. private _upload2DCompressedLevels;
  103772. }
  103773. }
  103774. declare module BABYLON {
  103775. /**
  103776. * Implementation of the KTX Texture Loader.
  103777. * @hidden
  103778. */
  103779. export class _KTXTextureLoader implements IInternalTextureLoader {
  103780. /**
  103781. * Defines wether the loader supports cascade loading the different faces.
  103782. */
  103783. readonly supportCascades: boolean;
  103784. /**
  103785. * This returns if the loader support the current file information.
  103786. * @param extension defines the file extension of the file being loaded
  103787. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103788. * @param fallback defines the fallback internal texture if any
  103789. * @param isBase64 defines whether the texture is encoded as a base64
  103790. * @param isBuffer defines whether the texture data are stored as a buffer
  103791. * @returns true if the loader can load the specified file
  103792. */
  103793. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103794. /**
  103795. * Transform the url before loading if required.
  103796. * @param rootUrl the url of the texture
  103797. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103798. * @returns the transformed texture
  103799. */
  103800. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103801. /**
  103802. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103803. * @param rootUrl the url of the texture
  103804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103805. * @returns the fallback texture
  103806. */
  103807. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103808. /**
  103809. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103810. * @param data contains the texture data
  103811. * @param texture defines the BabylonJS internal texture
  103812. * @param createPolynomials will be true if polynomials have been requested
  103813. * @param onLoad defines the callback to trigger once the texture is ready
  103814. * @param onError defines the callback to trigger in case of error
  103815. */
  103816. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103817. /**
  103818. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103819. * @param data contains the texture data
  103820. * @param texture defines the BabylonJS internal texture
  103821. * @param callback defines the method to call once ready to upload
  103822. */
  103823. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103824. }
  103825. }
  103826. declare module BABYLON {
  103827. /** @hidden */
  103828. export var _forceSceneHelpersToBundle: boolean;
  103829. interface Scene {
  103830. /**
  103831. * Creates a default light for the scene.
  103832. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  103833. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  103834. */
  103835. createDefaultLight(replace?: boolean): void;
  103836. /**
  103837. * Creates a default camera for the scene.
  103838. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  103839. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103840. * @param replace has default false, when true replaces the active camera in the scene
  103841. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  103842. */
  103843. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103844. /**
  103845. * Creates a default camera and a default light.
  103846. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  103847. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103848. * @param replace has the default false, when true replaces the active camera/light in the scene
  103849. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  103850. */
  103851. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103852. /**
  103853. * Creates a new sky box
  103854. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  103855. * @param environmentTexture defines the texture to use as environment texture
  103856. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  103857. * @param scale defines the overall scale of the skybox
  103858. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  103859. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  103860. * @returns a new mesh holding the sky box
  103861. */
  103862. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  103863. /**
  103864. * Creates a new environment
  103865. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  103866. * @param options defines the options you can use to configure the environment
  103867. * @returns the new EnvironmentHelper
  103868. */
  103869. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  103870. /**
  103871. * Creates a new VREXperienceHelper
  103872. * @see http://doc.babylonjs.com/how_to/webvr_helper
  103873. * @param webVROptions defines the options used to create the new VREXperienceHelper
  103874. * @returns a new VREXperienceHelper
  103875. */
  103876. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  103877. /**
  103878. * Creates a new XREXperienceHelper
  103879. * @see http://doc.babylonjs.com/how_to/webxr
  103880. * @returns a promise for a new XREXperienceHelper
  103881. */
  103882. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  103883. }
  103884. }
  103885. declare module BABYLON {
  103886. /**
  103887. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  103888. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  103889. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  103890. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103891. */
  103892. export class VideoDome extends TransformNode {
  103893. /**
  103894. * Define the video source as a Monoscopic panoramic 360 video.
  103895. */
  103896. static readonly MODE_MONOSCOPIC: number;
  103897. /**
  103898. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103899. */
  103900. static readonly MODE_TOPBOTTOM: number;
  103901. /**
  103902. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103903. */
  103904. static readonly MODE_SIDEBYSIDE: number;
  103905. private _useDirectMapping;
  103906. /**
  103907. * The video texture being displayed on the sphere
  103908. */
  103909. protected _videoTexture: VideoTexture;
  103910. /**
  103911. * Gets the video texture being displayed on the sphere
  103912. */
  103913. readonly videoTexture: VideoTexture;
  103914. /**
  103915. * The skybox material
  103916. */
  103917. protected _material: BackgroundMaterial;
  103918. /**
  103919. * The surface used for the skybox
  103920. */
  103921. protected _mesh: Mesh;
  103922. /**
  103923. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103924. * Also see the options.resolution property.
  103925. */
  103926. fovMultiplier: number;
  103927. private _videoMode;
  103928. /**
  103929. * Gets or set the current video mode for the video. It can be:
  103930. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  103931. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103932. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103933. */
  103934. videoMode: number;
  103935. /**
  103936. * Oberserver used in Stereoscopic VR Mode.
  103937. */
  103938. private _onBeforeCameraRenderObserver;
  103939. /**
  103940. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  103941. * @param name Element's name, child elements will append suffixes for their own names.
  103942. * @param urlsOrVideo defines the url(s) or the video element to use
  103943. * @param options An object containing optional or exposed sub element properties
  103944. */
  103945. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  103946. resolution?: number;
  103947. clickToPlay?: boolean;
  103948. autoPlay?: boolean;
  103949. loop?: boolean;
  103950. size?: number;
  103951. poster?: string;
  103952. faceForward?: boolean;
  103953. useDirectMapping?: boolean;
  103954. }, scene: Scene);
  103955. private _changeVideoMode;
  103956. /**
  103957. * Releases resources associated with this node.
  103958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103960. */
  103961. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103962. }
  103963. }
  103964. declare module BABYLON {
  103965. /**
  103966. * This class can be used to get instrumentation data from a Babylon engine
  103967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103968. */
  103969. export class EngineInstrumentation implements IDisposable {
  103970. /**
  103971. * Define the instrumented engine.
  103972. */
  103973. engine: Engine;
  103974. private _captureGPUFrameTime;
  103975. private _gpuFrameTimeToken;
  103976. private _gpuFrameTime;
  103977. private _captureShaderCompilationTime;
  103978. private _shaderCompilationTime;
  103979. private _onBeginFrameObserver;
  103980. private _onEndFrameObserver;
  103981. private _onBeforeShaderCompilationObserver;
  103982. private _onAfterShaderCompilationObserver;
  103983. /**
  103984. * Gets the perf counter used for GPU frame time
  103985. */
  103986. readonly gpuFrameTimeCounter: PerfCounter;
  103987. /**
  103988. * Gets the GPU frame time capture status
  103989. */
  103990. /**
  103991. * Enable or disable the GPU frame time capture
  103992. */
  103993. captureGPUFrameTime: boolean;
  103994. /**
  103995. * Gets the perf counter used for shader compilation time
  103996. */
  103997. readonly shaderCompilationTimeCounter: PerfCounter;
  103998. /**
  103999. * Gets the shader compilation time capture status
  104000. */
  104001. /**
  104002. * Enable or disable the shader compilation time capture
  104003. */
  104004. captureShaderCompilationTime: boolean;
  104005. /**
  104006. * Instantiates a new engine instrumentation.
  104007. * This class can be used to get instrumentation data from a Babylon engine
  104008. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  104009. * @param engine Defines the engine to instrument
  104010. */
  104011. constructor(
  104012. /**
  104013. * Define the instrumented engine.
  104014. */
  104015. engine: Engine);
  104016. /**
  104017. * Dispose and release associated resources.
  104018. */
  104019. dispose(): void;
  104020. }
  104021. }
  104022. declare module BABYLON {
  104023. /**
  104024. * This class can be used to get instrumentation data from a Babylon engine
  104025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  104026. */
  104027. export class SceneInstrumentation implements IDisposable {
  104028. /**
  104029. * Defines the scene to instrument
  104030. */
  104031. scene: Scene;
  104032. private _captureActiveMeshesEvaluationTime;
  104033. private _activeMeshesEvaluationTime;
  104034. private _captureRenderTargetsRenderTime;
  104035. private _renderTargetsRenderTime;
  104036. private _captureFrameTime;
  104037. private _frameTime;
  104038. private _captureRenderTime;
  104039. private _renderTime;
  104040. private _captureInterFrameTime;
  104041. private _interFrameTime;
  104042. private _captureParticlesRenderTime;
  104043. private _particlesRenderTime;
  104044. private _captureSpritesRenderTime;
  104045. private _spritesRenderTime;
  104046. private _capturePhysicsTime;
  104047. private _physicsTime;
  104048. private _captureAnimationsTime;
  104049. private _animationsTime;
  104050. private _captureCameraRenderTime;
  104051. private _cameraRenderTime;
  104052. private _onBeforeActiveMeshesEvaluationObserver;
  104053. private _onAfterActiveMeshesEvaluationObserver;
  104054. private _onBeforeRenderTargetsRenderObserver;
  104055. private _onAfterRenderTargetsRenderObserver;
  104056. private _onAfterRenderObserver;
  104057. private _onBeforeDrawPhaseObserver;
  104058. private _onAfterDrawPhaseObserver;
  104059. private _onBeforeAnimationsObserver;
  104060. private _onBeforeParticlesRenderingObserver;
  104061. private _onAfterParticlesRenderingObserver;
  104062. private _onBeforeSpritesRenderingObserver;
  104063. private _onAfterSpritesRenderingObserver;
  104064. private _onBeforePhysicsObserver;
  104065. private _onAfterPhysicsObserver;
  104066. private _onAfterAnimationsObserver;
  104067. private _onBeforeCameraRenderObserver;
  104068. private _onAfterCameraRenderObserver;
  104069. /**
  104070. * Gets the perf counter used for active meshes evaluation time
  104071. */
  104072. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  104073. /**
  104074. * Gets the active meshes evaluation time capture status
  104075. */
  104076. /**
  104077. * Enable or disable the active meshes evaluation time capture
  104078. */
  104079. captureActiveMeshesEvaluationTime: boolean;
  104080. /**
  104081. * Gets the perf counter used for render targets render time
  104082. */
  104083. readonly renderTargetsRenderTimeCounter: PerfCounter;
  104084. /**
  104085. * Gets the render targets render time capture status
  104086. */
  104087. /**
  104088. * Enable or disable the render targets render time capture
  104089. */
  104090. captureRenderTargetsRenderTime: boolean;
  104091. /**
  104092. * Gets the perf counter used for particles render time
  104093. */
  104094. readonly particlesRenderTimeCounter: PerfCounter;
  104095. /**
  104096. * Gets the particles render time capture status
  104097. */
  104098. /**
  104099. * Enable or disable the particles render time capture
  104100. */
  104101. captureParticlesRenderTime: boolean;
  104102. /**
  104103. * Gets the perf counter used for sprites render time
  104104. */
  104105. readonly spritesRenderTimeCounter: PerfCounter;
  104106. /**
  104107. * Gets the sprites render time capture status
  104108. */
  104109. /**
  104110. * Enable or disable the sprites render time capture
  104111. */
  104112. captureSpritesRenderTime: boolean;
  104113. /**
  104114. * Gets the perf counter used for physics time
  104115. */
  104116. readonly physicsTimeCounter: PerfCounter;
  104117. /**
  104118. * Gets the physics time capture status
  104119. */
  104120. /**
  104121. * Enable or disable the physics time capture
  104122. */
  104123. capturePhysicsTime: boolean;
  104124. /**
  104125. * Gets the perf counter used for animations time
  104126. */
  104127. readonly animationsTimeCounter: PerfCounter;
  104128. /**
  104129. * Gets the animations time capture status
  104130. */
  104131. /**
  104132. * Enable or disable the animations time capture
  104133. */
  104134. captureAnimationsTime: boolean;
  104135. /**
  104136. * Gets the perf counter used for frame time capture
  104137. */
  104138. readonly frameTimeCounter: PerfCounter;
  104139. /**
  104140. * Gets the frame time capture status
  104141. */
  104142. /**
  104143. * Enable or disable the frame time capture
  104144. */
  104145. captureFrameTime: boolean;
  104146. /**
  104147. * Gets the perf counter used for inter-frames time capture
  104148. */
  104149. readonly interFrameTimeCounter: PerfCounter;
  104150. /**
  104151. * Gets the inter-frames time capture status
  104152. */
  104153. /**
  104154. * Enable or disable the inter-frames time capture
  104155. */
  104156. captureInterFrameTime: boolean;
  104157. /**
  104158. * Gets the perf counter used for render time capture
  104159. */
  104160. readonly renderTimeCounter: PerfCounter;
  104161. /**
  104162. * Gets the render time capture status
  104163. */
  104164. /**
  104165. * Enable or disable the render time capture
  104166. */
  104167. captureRenderTime: boolean;
  104168. /**
  104169. * Gets the perf counter used for camera render time capture
  104170. */
  104171. readonly cameraRenderTimeCounter: PerfCounter;
  104172. /**
  104173. * Gets the camera render time capture status
  104174. */
  104175. /**
  104176. * Enable or disable the camera render time capture
  104177. */
  104178. captureCameraRenderTime: boolean;
  104179. /**
  104180. * Gets the perf counter used for draw calls
  104181. */
  104182. readonly drawCallsCounter: PerfCounter;
  104183. /**
  104184. * Gets the perf counter used for texture collisions
  104185. */
  104186. readonly textureCollisionsCounter: PerfCounter;
  104187. /**
  104188. * Instantiates a new scene instrumentation.
  104189. * This class can be used to get instrumentation data from a Babylon engine
  104190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  104191. * @param scene Defines the scene to instrument
  104192. */
  104193. constructor(
  104194. /**
  104195. * Defines the scene to instrument
  104196. */
  104197. scene: Scene);
  104198. /**
  104199. * Dispose and release associated resources.
  104200. */
  104201. dispose(): void;
  104202. }
  104203. }
  104204. declare module BABYLON {
  104205. /** @hidden */
  104206. export var glowMapGenerationPixelShader: {
  104207. name: string;
  104208. shader: string;
  104209. };
  104210. }
  104211. declare module BABYLON {
  104212. /** @hidden */
  104213. export var glowMapGenerationVertexShader: {
  104214. name: string;
  104215. shader: string;
  104216. };
  104217. }
  104218. declare module BABYLON {
  104219. /**
  104220. * Effect layer options. This helps customizing the behaviour
  104221. * of the effect layer.
  104222. */
  104223. export interface IEffectLayerOptions {
  104224. /**
  104225. * Multiplication factor apply to the canvas size to compute the render target size
  104226. * used to generated the objects (the smaller the faster).
  104227. */
  104228. mainTextureRatio: number;
  104229. /**
  104230. * Enforces a fixed size texture to ensure effect stability across devices.
  104231. */
  104232. mainTextureFixedSize?: number;
  104233. /**
  104234. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  104235. */
  104236. alphaBlendingMode: number;
  104237. /**
  104238. * The camera attached to the layer.
  104239. */
  104240. camera: Nullable<Camera>;
  104241. /**
  104242. * The rendering group to draw the layer in.
  104243. */
  104244. renderingGroupId: number;
  104245. }
  104246. /**
  104247. * The effect layer Helps adding post process effect blended with the main pass.
  104248. *
  104249. * This can be for instance use to generate glow or higlight effects on the scene.
  104250. *
  104251. * The effect layer class can not be used directly and is intented to inherited from to be
  104252. * customized per effects.
  104253. */
  104254. export abstract class EffectLayer {
  104255. private _vertexBuffers;
  104256. private _indexBuffer;
  104257. private _cachedDefines;
  104258. private _effectLayerMapGenerationEffect;
  104259. private _effectLayerOptions;
  104260. private _mergeEffect;
  104261. protected _scene: Scene;
  104262. protected _engine: Engine;
  104263. protected _maxSize: number;
  104264. protected _mainTextureDesiredSize: ISize;
  104265. protected _mainTexture: RenderTargetTexture;
  104266. protected _shouldRender: boolean;
  104267. protected _postProcesses: PostProcess[];
  104268. protected _textures: BaseTexture[];
  104269. protected _emissiveTextureAndColor: {
  104270. texture: Nullable<BaseTexture>;
  104271. color: Color4;
  104272. };
  104273. /**
  104274. * The name of the layer
  104275. */
  104276. name: string;
  104277. /**
  104278. * The clear color of the texture used to generate the glow map.
  104279. */
  104280. neutralColor: Color4;
  104281. /**
  104282. * Specifies wether the highlight layer is enabled or not.
  104283. */
  104284. isEnabled: boolean;
  104285. /**
  104286. * Gets the camera attached to the layer.
  104287. */
  104288. readonly camera: Nullable<Camera>;
  104289. /**
  104290. * Gets the rendering group id the layer should render in.
  104291. */
  104292. readonly renderingGroupId: number;
  104293. /**
  104294. * An event triggered when the effect layer has been disposed.
  104295. */
  104296. onDisposeObservable: Observable<EffectLayer>;
  104297. /**
  104298. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  104299. */
  104300. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  104301. /**
  104302. * An event triggered when the generated texture is being merged in the scene.
  104303. */
  104304. onBeforeComposeObservable: Observable<EffectLayer>;
  104305. /**
  104306. * An event triggered when the generated texture has been merged in the scene.
  104307. */
  104308. onAfterComposeObservable: Observable<EffectLayer>;
  104309. /**
  104310. * An event triggered when the efffect layer changes its size.
  104311. */
  104312. onSizeChangedObservable: Observable<EffectLayer>;
  104313. /** @hidden */
  104314. static _SceneComponentInitialization: (scene: Scene) => void;
  104315. /**
  104316. * Instantiates a new effect Layer and references it in the scene.
  104317. * @param name The name of the layer
  104318. * @param scene The scene to use the layer in
  104319. */
  104320. constructor(
  104321. /** The Friendly of the effect in the scene */
  104322. name: string, scene: Scene);
  104323. /**
  104324. * Get the effect name of the layer.
  104325. * @return The effect name
  104326. */
  104327. abstract getEffectName(): string;
  104328. /**
  104329. * Checks for the readiness of the element composing the layer.
  104330. * @param subMesh the mesh to check for
  104331. * @param useInstances specify wether or not to use instances to render the mesh
  104332. * @return true if ready otherwise, false
  104333. */
  104334. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104335. /**
  104336. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104337. * @returns true if the effect requires stencil during the main canvas render pass.
  104338. */
  104339. abstract needStencil(): boolean;
  104340. /**
  104341. * Create the merge effect. This is the shader use to blit the information back
  104342. * to the main canvas at the end of the scene rendering.
  104343. * @returns The effect containing the shader used to merge the effect on the main canvas
  104344. */
  104345. protected abstract _createMergeEffect(): Effect;
  104346. /**
  104347. * Creates the render target textures and post processes used in the effect layer.
  104348. */
  104349. protected abstract _createTextureAndPostProcesses(): void;
  104350. /**
  104351. * Implementation specific of rendering the generating effect on the main canvas.
  104352. * @param effect The effect used to render through
  104353. */
  104354. protected abstract _internalRender(effect: Effect): void;
  104355. /**
  104356. * Sets the required values for both the emissive texture and and the main color.
  104357. */
  104358. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104359. /**
  104360. * Free any resources and references associated to a mesh.
  104361. * Internal use
  104362. * @param mesh The mesh to free.
  104363. */
  104364. abstract _disposeMesh(mesh: Mesh): void;
  104365. /**
  104366. * Serializes this layer (Glow or Highlight for example)
  104367. * @returns a serialized layer object
  104368. */
  104369. abstract serialize?(): any;
  104370. /**
  104371. * Initializes the effect layer with the required options.
  104372. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  104373. */
  104374. protected _init(options: Partial<IEffectLayerOptions>): void;
  104375. /**
  104376. * Generates the index buffer of the full screen quad blending to the main canvas.
  104377. */
  104378. private _generateIndexBuffer;
  104379. /**
  104380. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  104381. */
  104382. private _genrateVertexBuffer;
  104383. /**
  104384. * Sets the main texture desired size which is the closest power of two
  104385. * of the engine canvas size.
  104386. */
  104387. private _setMainTextureSize;
  104388. /**
  104389. * Creates the main texture for the effect layer.
  104390. */
  104391. protected _createMainTexture(): void;
  104392. /**
  104393. * Adds specific effects defines.
  104394. * @param defines The defines to add specifics to.
  104395. */
  104396. protected _addCustomEffectDefines(defines: string[]): void;
  104397. /**
  104398. * Checks for the readiness of the element composing the layer.
  104399. * @param subMesh the mesh to check for
  104400. * @param useInstances specify wether or not to use instances to render the mesh
  104401. * @param emissiveTexture the associated emissive texture used to generate the glow
  104402. * @return true if ready otherwise, false
  104403. */
  104404. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  104405. /**
  104406. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  104407. */
  104408. render(): void;
  104409. /**
  104410. * Determine if a given mesh will be used in the current effect.
  104411. * @param mesh mesh to test
  104412. * @returns true if the mesh will be used
  104413. */
  104414. hasMesh(mesh: AbstractMesh): boolean;
  104415. /**
  104416. * Returns true if the layer contains information to display, otherwise false.
  104417. * @returns true if the glow layer should be rendered
  104418. */
  104419. shouldRender(): boolean;
  104420. /**
  104421. * Returns true if the mesh should render, otherwise false.
  104422. * @param mesh The mesh to render
  104423. * @returns true if it should render otherwise false
  104424. */
  104425. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  104426. /**
  104427. * Returns true if the mesh can be rendered, otherwise false.
  104428. * @param mesh The mesh to render
  104429. * @param material The material used on the mesh
  104430. * @returns true if it can be rendered otherwise false
  104431. */
  104432. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104433. /**
  104434. * Returns true if the mesh should render, otherwise false.
  104435. * @param mesh The mesh to render
  104436. * @returns true if it should render otherwise false
  104437. */
  104438. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  104439. /**
  104440. * Renders the submesh passed in parameter to the generation map.
  104441. */
  104442. protected _renderSubMesh(subMesh: SubMesh): void;
  104443. /**
  104444. * Rebuild the required buffers.
  104445. * @hidden Internal use only.
  104446. */
  104447. _rebuild(): void;
  104448. /**
  104449. * Dispose only the render target textures and post process.
  104450. */
  104451. private _disposeTextureAndPostProcesses;
  104452. /**
  104453. * Dispose the highlight layer and free resources.
  104454. */
  104455. dispose(): void;
  104456. /**
  104457. * Gets the class name of the effect layer
  104458. * @returns the string with the class name of the effect layer
  104459. */
  104460. getClassName(): string;
  104461. /**
  104462. * Creates an effect layer from parsed effect layer data
  104463. * @param parsedEffectLayer defines effect layer data
  104464. * @param scene defines the current scene
  104465. * @param rootUrl defines the root URL containing the effect layer information
  104466. * @returns a parsed effect Layer
  104467. */
  104468. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  104469. }
  104470. }
  104471. declare module BABYLON {
  104472. interface AbstractScene {
  104473. /**
  104474. * The list of effect layers (highlights/glow) added to the scene
  104475. * @see http://doc.babylonjs.com/how_to/highlight_layer
  104476. * @see http://doc.babylonjs.com/how_to/glow_layer
  104477. */
  104478. effectLayers: Array<EffectLayer>;
  104479. /**
  104480. * Removes the given effect layer from this scene.
  104481. * @param toRemove defines the effect layer to remove
  104482. * @returns the index of the removed effect layer
  104483. */
  104484. removeEffectLayer(toRemove: EffectLayer): number;
  104485. /**
  104486. * Adds the given effect layer to this scene
  104487. * @param newEffectLayer defines the effect layer to add
  104488. */
  104489. addEffectLayer(newEffectLayer: EffectLayer): void;
  104490. }
  104491. /**
  104492. * Defines the layer scene component responsible to manage any effect layers
  104493. * in a given scene.
  104494. */
  104495. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  104496. /**
  104497. * The component name helpfull to identify the component in the list of scene components.
  104498. */
  104499. readonly name: string;
  104500. /**
  104501. * The scene the component belongs to.
  104502. */
  104503. scene: Scene;
  104504. private _engine;
  104505. private _renderEffects;
  104506. private _needStencil;
  104507. private _previousStencilState;
  104508. /**
  104509. * Creates a new instance of the component for the given scene
  104510. * @param scene Defines the scene to register the component in
  104511. */
  104512. constructor(scene: Scene);
  104513. /**
  104514. * Registers the component in a given scene
  104515. */
  104516. register(): void;
  104517. /**
  104518. * Rebuilds the elements related to this component in case of
  104519. * context lost for instance.
  104520. */
  104521. rebuild(): void;
  104522. /**
  104523. * Serializes the component data to the specified json object
  104524. * @param serializationObject The object to serialize to
  104525. */
  104526. serialize(serializationObject: any): void;
  104527. /**
  104528. * Adds all the element from the container to the scene
  104529. * @param container the container holding the elements
  104530. */
  104531. addFromContainer(container: AbstractScene): void;
  104532. /**
  104533. * Removes all the elements in the container from the scene
  104534. * @param container contains the elements to remove
  104535. * @param dispose if the removed element should be disposed (default: false)
  104536. */
  104537. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104538. /**
  104539. * Disposes the component and the associated ressources.
  104540. */
  104541. dispose(): void;
  104542. private _isReadyForMesh;
  104543. private _renderMainTexture;
  104544. private _setStencil;
  104545. private _setStencilBack;
  104546. private _draw;
  104547. private _drawCamera;
  104548. private _drawRenderingGroup;
  104549. }
  104550. }
  104551. declare module BABYLON {
  104552. /** @hidden */
  104553. export var glowMapMergePixelShader: {
  104554. name: string;
  104555. shader: string;
  104556. };
  104557. }
  104558. declare module BABYLON {
  104559. /** @hidden */
  104560. export var glowMapMergeVertexShader: {
  104561. name: string;
  104562. shader: string;
  104563. };
  104564. }
  104565. declare module BABYLON {
  104566. interface AbstractScene {
  104567. /**
  104568. * Return a the first highlight layer of the scene with a given name.
  104569. * @param name The name of the highlight layer to look for.
  104570. * @return The highlight layer if found otherwise null.
  104571. */
  104572. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  104573. }
  104574. /**
  104575. * Glow layer options. This helps customizing the behaviour
  104576. * of the glow layer.
  104577. */
  104578. export interface IGlowLayerOptions {
  104579. /**
  104580. * Multiplication factor apply to the canvas size to compute the render target size
  104581. * used to generated the glowing objects (the smaller the faster).
  104582. */
  104583. mainTextureRatio: number;
  104584. /**
  104585. * Enforces a fixed size texture to ensure resize independant blur.
  104586. */
  104587. mainTextureFixedSize?: number;
  104588. /**
  104589. * How big is the kernel of the blur texture.
  104590. */
  104591. blurKernelSize: number;
  104592. /**
  104593. * The camera attached to the layer.
  104594. */
  104595. camera: Nullable<Camera>;
  104596. /**
  104597. * Enable MSAA by chosing the number of samples.
  104598. */
  104599. mainTextureSamples?: number;
  104600. /**
  104601. * The rendering group to draw the layer in.
  104602. */
  104603. renderingGroupId: number;
  104604. }
  104605. /**
  104606. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  104607. *
  104608. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104609. * glowy meshes to your scene.
  104610. *
  104611. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  104612. */
  104613. export class GlowLayer extends EffectLayer {
  104614. /**
  104615. * Effect Name of the layer.
  104616. */
  104617. static readonly EffectName: string;
  104618. /**
  104619. * The default blur kernel size used for the glow.
  104620. */
  104621. static DefaultBlurKernelSize: number;
  104622. /**
  104623. * The default texture size ratio used for the glow.
  104624. */
  104625. static DefaultTextureRatio: number;
  104626. /**
  104627. * Sets the kernel size of the blur.
  104628. */
  104629. /**
  104630. * Gets the kernel size of the blur.
  104631. */
  104632. blurKernelSize: number;
  104633. /**
  104634. * Sets the glow intensity.
  104635. */
  104636. /**
  104637. * Gets the glow intensity.
  104638. */
  104639. intensity: number;
  104640. private _options;
  104641. private _intensity;
  104642. private _horizontalBlurPostprocess1;
  104643. private _verticalBlurPostprocess1;
  104644. private _horizontalBlurPostprocess2;
  104645. private _verticalBlurPostprocess2;
  104646. private _blurTexture1;
  104647. private _blurTexture2;
  104648. private _postProcesses1;
  104649. private _postProcesses2;
  104650. private _includedOnlyMeshes;
  104651. private _excludedMeshes;
  104652. /**
  104653. * Callback used to let the user override the color selection on a per mesh basis
  104654. */
  104655. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  104656. /**
  104657. * Callback used to let the user override the texture selection on a per mesh basis
  104658. */
  104659. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  104660. /**
  104661. * Instantiates a new glow Layer and references it to the scene.
  104662. * @param name The name of the layer
  104663. * @param scene The scene to use the layer in
  104664. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  104665. */
  104666. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  104667. /**
  104668. * Get the effect name of the layer.
  104669. * @return The effect name
  104670. */
  104671. getEffectName(): string;
  104672. /**
  104673. * Create the merge effect. This is the shader use to blit the information back
  104674. * to the main canvas at the end of the scene rendering.
  104675. */
  104676. protected _createMergeEffect(): Effect;
  104677. /**
  104678. * Creates the render target textures and post processes used in the glow layer.
  104679. */
  104680. protected _createTextureAndPostProcesses(): void;
  104681. /**
  104682. * Checks for the readiness of the element composing the layer.
  104683. * @param subMesh the mesh to check for
  104684. * @param useInstances specify wether or not to use instances to render the mesh
  104685. * @param emissiveTexture the associated emissive texture used to generate the glow
  104686. * @return true if ready otherwise, false
  104687. */
  104688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104689. /**
  104690. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104691. */
  104692. needStencil(): boolean;
  104693. /**
  104694. * Returns true if the mesh can be rendered, otherwise false.
  104695. * @param mesh The mesh to render
  104696. * @param material The material used on the mesh
  104697. * @returns true if it can be rendered otherwise false
  104698. */
  104699. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104700. /**
  104701. * Implementation specific of rendering the generating effect on the main canvas.
  104702. * @param effect The effect used to render through
  104703. */
  104704. protected _internalRender(effect: Effect): void;
  104705. /**
  104706. * Sets the required values for both the emissive texture and and the main color.
  104707. */
  104708. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104709. /**
  104710. * Returns true if the mesh should render, otherwise false.
  104711. * @param mesh The mesh to render
  104712. * @returns true if it should render otherwise false
  104713. */
  104714. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104715. /**
  104716. * Adds specific effects defines.
  104717. * @param defines The defines to add specifics to.
  104718. */
  104719. protected _addCustomEffectDefines(defines: string[]): void;
  104720. /**
  104721. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  104722. * @param mesh The mesh to exclude from the glow layer
  104723. */
  104724. addExcludedMesh(mesh: Mesh): void;
  104725. /**
  104726. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  104727. * @param mesh The mesh to remove
  104728. */
  104729. removeExcludedMesh(mesh: Mesh): void;
  104730. /**
  104731. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  104732. * @param mesh The mesh to include in the glow layer
  104733. */
  104734. addIncludedOnlyMesh(mesh: Mesh): void;
  104735. /**
  104736. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  104737. * @param mesh The mesh to remove
  104738. */
  104739. removeIncludedOnlyMesh(mesh: Mesh): void;
  104740. /**
  104741. * Determine if a given mesh will be used in the glow layer
  104742. * @param mesh The mesh to test
  104743. * @returns true if the mesh will be highlighted by the current glow layer
  104744. */
  104745. hasMesh(mesh: AbstractMesh): boolean;
  104746. /**
  104747. * Free any resources and references associated to a mesh.
  104748. * Internal use
  104749. * @param mesh The mesh to free.
  104750. * @hidden
  104751. */
  104752. _disposeMesh(mesh: Mesh): void;
  104753. /**
  104754. * Gets the class name of the effect layer
  104755. * @returns the string with the class name of the effect layer
  104756. */
  104757. getClassName(): string;
  104758. /**
  104759. * Serializes this glow layer
  104760. * @returns a serialized glow layer object
  104761. */
  104762. serialize(): any;
  104763. /**
  104764. * Creates a Glow Layer from parsed glow layer data
  104765. * @param parsedGlowLayer defines glow layer data
  104766. * @param scene defines the current scene
  104767. * @param rootUrl defines the root URL containing the glow layer information
  104768. * @returns a parsed Glow Layer
  104769. */
  104770. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  104771. }
  104772. }
  104773. declare module BABYLON {
  104774. /** @hidden */
  104775. export var glowBlurPostProcessPixelShader: {
  104776. name: string;
  104777. shader: string;
  104778. };
  104779. }
  104780. declare module BABYLON {
  104781. interface AbstractScene {
  104782. /**
  104783. * Return a the first highlight layer of the scene with a given name.
  104784. * @param name The name of the highlight layer to look for.
  104785. * @return The highlight layer if found otherwise null.
  104786. */
  104787. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  104788. }
  104789. /**
  104790. * Highlight layer options. This helps customizing the behaviour
  104791. * of the highlight layer.
  104792. */
  104793. export interface IHighlightLayerOptions {
  104794. /**
  104795. * Multiplication factor apply to the canvas size to compute the render target size
  104796. * used to generated the glowing objects (the smaller the faster).
  104797. */
  104798. mainTextureRatio: number;
  104799. /**
  104800. * Enforces a fixed size texture to ensure resize independant blur.
  104801. */
  104802. mainTextureFixedSize?: number;
  104803. /**
  104804. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  104805. * of the picture to blur (the smaller the faster).
  104806. */
  104807. blurTextureSizeRatio: number;
  104808. /**
  104809. * How big in texel of the blur texture is the vertical blur.
  104810. */
  104811. blurVerticalSize: number;
  104812. /**
  104813. * How big in texel of the blur texture is the horizontal blur.
  104814. */
  104815. blurHorizontalSize: number;
  104816. /**
  104817. * Alpha blending mode used to apply the blur. Default is combine.
  104818. */
  104819. alphaBlendingMode: number;
  104820. /**
  104821. * The camera attached to the layer.
  104822. */
  104823. camera: Nullable<Camera>;
  104824. /**
  104825. * Should we display highlight as a solid stroke?
  104826. */
  104827. isStroke?: boolean;
  104828. /**
  104829. * The rendering group to draw the layer in.
  104830. */
  104831. renderingGroupId: number;
  104832. }
  104833. /**
  104834. * The highlight layer Helps adding a glow effect around a mesh.
  104835. *
  104836. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104837. * glowy meshes to your scene.
  104838. *
  104839. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  104840. */
  104841. export class HighlightLayer extends EffectLayer {
  104842. name: string;
  104843. /**
  104844. * Effect Name of the highlight layer.
  104845. */
  104846. static readonly EffectName: string;
  104847. /**
  104848. * The neutral color used during the preparation of the glow effect.
  104849. * This is black by default as the blend operation is a blend operation.
  104850. */
  104851. static NeutralColor: Color4;
  104852. /**
  104853. * Stencil value used for glowing meshes.
  104854. */
  104855. static GlowingMeshStencilReference: number;
  104856. /**
  104857. * Stencil value used for the other meshes in the scene.
  104858. */
  104859. static NormalMeshStencilReference: number;
  104860. /**
  104861. * Specifies whether or not the inner glow is ACTIVE in the layer.
  104862. */
  104863. innerGlow: boolean;
  104864. /**
  104865. * Specifies whether or not the outer glow is ACTIVE in the layer.
  104866. */
  104867. outerGlow: boolean;
  104868. /**
  104869. * Specifies the horizontal size of the blur.
  104870. */
  104871. /**
  104872. * Gets the horizontal size of the blur.
  104873. */
  104874. blurHorizontalSize: number;
  104875. /**
  104876. * Specifies the vertical size of the blur.
  104877. */
  104878. /**
  104879. * Gets the vertical size of the blur.
  104880. */
  104881. blurVerticalSize: number;
  104882. /**
  104883. * An event triggered when the highlight layer is being blurred.
  104884. */
  104885. onBeforeBlurObservable: Observable<HighlightLayer>;
  104886. /**
  104887. * An event triggered when the highlight layer has been blurred.
  104888. */
  104889. onAfterBlurObservable: Observable<HighlightLayer>;
  104890. private _instanceGlowingMeshStencilReference;
  104891. private _options;
  104892. private _downSamplePostprocess;
  104893. private _horizontalBlurPostprocess;
  104894. private _verticalBlurPostprocess;
  104895. private _blurTexture;
  104896. private _meshes;
  104897. private _excludedMeshes;
  104898. /**
  104899. * Instantiates a new highlight Layer and references it to the scene..
  104900. * @param name The name of the layer
  104901. * @param scene The scene to use the layer in
  104902. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  104903. */
  104904. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  104905. /**
  104906. * Get the effect name of the layer.
  104907. * @return The effect name
  104908. */
  104909. getEffectName(): string;
  104910. /**
  104911. * Create the merge effect. This is the shader use to blit the information back
  104912. * to the main canvas at the end of the scene rendering.
  104913. */
  104914. protected _createMergeEffect(): Effect;
  104915. /**
  104916. * Creates the render target textures and post processes used in the highlight layer.
  104917. */
  104918. protected _createTextureAndPostProcesses(): void;
  104919. /**
  104920. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104921. */
  104922. needStencil(): boolean;
  104923. /**
  104924. * Checks for the readiness of the element composing the layer.
  104925. * @param subMesh the mesh to check for
  104926. * @param useInstances specify wether or not to use instances to render the mesh
  104927. * @param emissiveTexture the associated emissive texture used to generate the glow
  104928. * @return true if ready otherwise, false
  104929. */
  104930. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104931. /**
  104932. * Implementation specific of rendering the generating effect on the main canvas.
  104933. * @param effect The effect used to render through
  104934. */
  104935. protected _internalRender(effect: Effect): void;
  104936. /**
  104937. * Returns true if the layer contains information to display, otherwise false.
  104938. */
  104939. shouldRender(): boolean;
  104940. /**
  104941. * Returns true if the mesh should render, otherwise false.
  104942. * @param mesh The mesh to render
  104943. * @returns true if it should render otherwise false
  104944. */
  104945. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104946. /**
  104947. * Sets the required values for both the emissive texture and and the main color.
  104948. */
  104949. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104950. /**
  104951. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  104952. * @param mesh The mesh to exclude from the highlight layer
  104953. */
  104954. addExcludedMesh(mesh: Mesh): void;
  104955. /**
  104956. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  104957. * @param mesh The mesh to highlight
  104958. */
  104959. removeExcludedMesh(mesh: Mesh): void;
  104960. /**
  104961. * Determine if a given mesh will be highlighted by the current HighlightLayer
  104962. * @param mesh mesh to test
  104963. * @returns true if the mesh will be highlighted by the current HighlightLayer
  104964. */
  104965. hasMesh(mesh: AbstractMesh): boolean;
  104966. /**
  104967. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  104968. * @param mesh The mesh to highlight
  104969. * @param color The color of the highlight
  104970. * @param glowEmissiveOnly Extract the glow from the emissive texture
  104971. */
  104972. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  104973. /**
  104974. * Remove a mesh from the highlight layer in order to make it stop glowing.
  104975. * @param mesh The mesh to highlight
  104976. */
  104977. removeMesh(mesh: Mesh): void;
  104978. /**
  104979. * Force the stencil to the normal expected value for none glowing parts
  104980. */
  104981. private _defaultStencilReference;
  104982. /**
  104983. * Free any resources and references associated to a mesh.
  104984. * Internal use
  104985. * @param mesh The mesh to free.
  104986. * @hidden
  104987. */
  104988. _disposeMesh(mesh: Mesh): void;
  104989. /**
  104990. * Dispose the highlight layer and free resources.
  104991. */
  104992. dispose(): void;
  104993. /**
  104994. * Gets the class name of the effect layer
  104995. * @returns the string with the class name of the effect layer
  104996. */
  104997. getClassName(): string;
  104998. /**
  104999. * Serializes this Highlight layer
  105000. * @returns a serialized Highlight layer object
  105001. */
  105002. serialize(): any;
  105003. /**
  105004. * Creates a Highlight layer from parsed Highlight layer data
  105005. * @param parsedHightlightLayer defines the Highlight layer data
  105006. * @param scene defines the current scene
  105007. * @param rootUrl defines the root URL containing the Highlight layer information
  105008. * @returns a parsed Highlight layer
  105009. */
  105010. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  105011. }
  105012. }
  105013. declare module BABYLON {
  105014. /** @hidden */
  105015. export var lensFlarePixelShader: {
  105016. name: string;
  105017. shader: string;
  105018. };
  105019. }
  105020. declare module BABYLON {
  105021. /** @hidden */
  105022. export var lensFlareVertexShader: {
  105023. name: string;
  105024. shader: string;
  105025. };
  105026. }
  105027. declare module BABYLON {
  105028. /**
  105029. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  105030. * It is usually composed of several `lensFlare`.
  105031. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105032. */
  105033. export class LensFlareSystem {
  105034. /**
  105035. * Define the name of the lens flare system
  105036. */
  105037. name: string;
  105038. /**
  105039. * List of lens flares used in this system.
  105040. */
  105041. lensFlares: LensFlare[];
  105042. /**
  105043. * Define a limit from the border the lens flare can be visible.
  105044. */
  105045. borderLimit: number;
  105046. /**
  105047. * Define a viewport border we do not want to see the lens flare in.
  105048. */
  105049. viewportBorder: number;
  105050. /**
  105051. * Define a predicate which could limit the list of meshes able to occlude the effect.
  105052. */
  105053. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105054. /**
  105055. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  105056. */
  105057. layerMask: number;
  105058. /**
  105059. * Define the id of the lens flare system in the scene.
  105060. * (equal to name by default)
  105061. */
  105062. id: string;
  105063. private _scene;
  105064. private _emitter;
  105065. private _vertexBuffers;
  105066. private _indexBuffer;
  105067. private _effect;
  105068. private _positionX;
  105069. private _positionY;
  105070. private _isEnabled;
  105071. /** @hidden */
  105072. static _SceneComponentInitialization: (scene: Scene) => void;
  105073. /**
  105074. * Instantiates a lens flare system.
  105075. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  105076. * It is usually composed of several `lensFlare`.
  105077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105078. * @param name Define the name of the lens flare system in the scene
  105079. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  105080. * @param scene Define the scene the lens flare system belongs to
  105081. */
  105082. constructor(
  105083. /**
  105084. * Define the name of the lens flare system
  105085. */
  105086. name: string, emitter: any, scene: Scene);
  105087. /**
  105088. * Define if the lens flare system is enabled.
  105089. */
  105090. isEnabled: boolean;
  105091. /**
  105092. * Get the scene the effects belongs to.
  105093. * @returns the scene holding the lens flare system
  105094. */
  105095. getScene(): Scene;
  105096. /**
  105097. * Get the emitter of the lens flare system.
  105098. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  105099. * @returns the emitter of the lens flare system
  105100. */
  105101. getEmitter(): any;
  105102. /**
  105103. * Set the emitter of the lens flare system.
  105104. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  105105. * @param newEmitter Define the new emitter of the system
  105106. */
  105107. setEmitter(newEmitter: any): void;
  105108. /**
  105109. * Get the lens flare system emitter position.
  105110. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  105111. * @returns the position
  105112. */
  105113. getEmitterPosition(): Vector3;
  105114. /**
  105115. * @hidden
  105116. */
  105117. computeEffectivePosition(globalViewport: Viewport): boolean;
  105118. /** @hidden */
  105119. _isVisible(): boolean;
  105120. /**
  105121. * @hidden
  105122. */
  105123. render(): boolean;
  105124. /**
  105125. * Dispose and release the lens flare with its associated resources.
  105126. */
  105127. dispose(): void;
  105128. /**
  105129. * Parse a lens flare system from a JSON repressentation
  105130. * @param parsedLensFlareSystem Define the JSON to parse
  105131. * @param scene Define the scene the parsed system should be instantiated in
  105132. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  105133. * @returns the parsed system
  105134. */
  105135. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  105136. /**
  105137. * Serialize the current Lens Flare System into a JSON representation.
  105138. * @returns the serialized JSON
  105139. */
  105140. serialize(): any;
  105141. }
  105142. }
  105143. declare module BABYLON {
  105144. /**
  105145. * This represents one of the lens effect in a `lensFlareSystem`.
  105146. * It controls one of the indiviual texture used in the effect.
  105147. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105148. */
  105149. export class LensFlare {
  105150. /**
  105151. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  105152. */
  105153. size: number;
  105154. /**
  105155. * 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.
  105156. */
  105157. position: number;
  105158. /**
  105159. * Define the lens color.
  105160. */
  105161. color: Color3;
  105162. /**
  105163. * Define the lens texture.
  105164. */
  105165. texture: Nullable<Texture>;
  105166. /**
  105167. * Define the alpha mode to render this particular lens.
  105168. */
  105169. alphaMode: number;
  105170. private _system;
  105171. /**
  105172. * Creates a new Lens Flare.
  105173. * This represents one of the lens effect in a `lensFlareSystem`.
  105174. * It controls one of the indiviual texture used in the effect.
  105175. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105176. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  105177. * @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.
  105178. * @param color Define the lens color
  105179. * @param imgUrl Define the lens texture url
  105180. * @param system Define the `lensFlareSystem` this flare is part of
  105181. * @returns The newly created Lens Flare
  105182. */
  105183. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  105184. /**
  105185. * Instantiates a new Lens Flare.
  105186. * This represents one of the lens effect in a `lensFlareSystem`.
  105187. * It controls one of the indiviual texture used in the effect.
  105188. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105189. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  105190. * @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.
  105191. * @param color Define the lens color
  105192. * @param imgUrl Define the lens texture url
  105193. * @param system Define the `lensFlareSystem` this flare is part of
  105194. */
  105195. constructor(
  105196. /**
  105197. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  105198. */
  105199. size: number,
  105200. /**
  105201. * 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.
  105202. */
  105203. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  105204. /**
  105205. * Dispose and release the lens flare with its associated resources.
  105206. */
  105207. dispose(): void;
  105208. }
  105209. }
  105210. declare module BABYLON {
  105211. interface AbstractScene {
  105212. /**
  105213. * The list of lens flare system added to the scene
  105214. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  105215. */
  105216. lensFlareSystems: Array<LensFlareSystem>;
  105217. /**
  105218. * Removes the given lens flare system from this scene.
  105219. * @param toRemove The lens flare system to remove
  105220. * @returns The index of the removed lens flare system
  105221. */
  105222. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  105223. /**
  105224. * Adds the given lens flare system to this scene
  105225. * @param newLensFlareSystem The lens flare system to add
  105226. */
  105227. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  105228. /**
  105229. * Gets a lens flare system using its name
  105230. * @param name defines the name to look for
  105231. * @returns the lens flare system or null if not found
  105232. */
  105233. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  105234. /**
  105235. * Gets a lens flare system using its id
  105236. * @param id defines the id to look for
  105237. * @returns the lens flare system or null if not found
  105238. */
  105239. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  105240. }
  105241. /**
  105242. * Defines the lens flare scene component responsible to manage any lens flares
  105243. * in a given scene.
  105244. */
  105245. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  105246. /**
  105247. * The component name helpfull to identify the component in the list of scene components.
  105248. */
  105249. readonly name: string;
  105250. /**
  105251. * The scene the component belongs to.
  105252. */
  105253. scene: Scene;
  105254. /**
  105255. * Creates a new instance of the component for the given scene
  105256. * @param scene Defines the scene to register the component in
  105257. */
  105258. constructor(scene: Scene);
  105259. /**
  105260. * Registers the component in a given scene
  105261. */
  105262. register(): void;
  105263. /**
  105264. * Rebuilds the elements related to this component in case of
  105265. * context lost for instance.
  105266. */
  105267. rebuild(): void;
  105268. /**
  105269. * Adds all the element from the container to the scene
  105270. * @param container the container holding the elements
  105271. */
  105272. addFromContainer(container: AbstractScene): void;
  105273. /**
  105274. * Removes all the elements in the container from the scene
  105275. * @param container contains the elements to remove
  105276. * @param dispose if the removed element should be disposed (default: false)
  105277. */
  105278. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  105279. /**
  105280. * Serializes the component data to the specified json object
  105281. * @param serializationObject The object to serialize to
  105282. */
  105283. serialize(serializationObject: any): void;
  105284. /**
  105285. * Disposes the component and the associated ressources.
  105286. */
  105287. dispose(): void;
  105288. private _draw;
  105289. }
  105290. }
  105291. declare module BABYLON {
  105292. /**
  105293. * Defines the shadow generator component responsible to manage any shadow generators
  105294. * in a given scene.
  105295. */
  105296. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  105297. /**
  105298. * The component name helpfull to identify the component in the list of scene components.
  105299. */
  105300. readonly name: string;
  105301. /**
  105302. * The scene the component belongs to.
  105303. */
  105304. scene: Scene;
  105305. /**
  105306. * Creates a new instance of the component for the given scene
  105307. * @param scene Defines the scene to register the component in
  105308. */
  105309. constructor(scene: Scene);
  105310. /**
  105311. * Registers the component in a given scene
  105312. */
  105313. register(): void;
  105314. /**
  105315. * Rebuilds the elements related to this component in case of
  105316. * context lost for instance.
  105317. */
  105318. rebuild(): void;
  105319. /**
  105320. * Serializes the component data to the specified json object
  105321. * @param serializationObject The object to serialize to
  105322. */
  105323. serialize(serializationObject: any): void;
  105324. /**
  105325. * Adds all the element from the container to the scene
  105326. * @param container the container holding the elements
  105327. */
  105328. addFromContainer(container: AbstractScene): void;
  105329. /**
  105330. * Removes all the elements in the container from the scene
  105331. * @param container contains the elements to remove
  105332. * @param dispose if the removed element should be disposed (default: false)
  105333. */
  105334. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  105335. /**
  105336. * Rebuilds the elements related to this component in case of
  105337. * context lost for instance.
  105338. */
  105339. dispose(): void;
  105340. private _gatherRenderTargets;
  105341. }
  105342. }
  105343. declare module BABYLON {
  105344. /**
  105345. * A directional light is defined by a direction (what a surprise!).
  105346. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105347. * 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.
  105348. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105349. */
  105350. export class DirectionalLight extends ShadowLight {
  105351. private _shadowFrustumSize;
  105352. /**
  105353. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105354. */
  105355. /**
  105356. * Specifies a fix frustum size for the shadow generation.
  105357. */
  105358. shadowFrustumSize: number;
  105359. private _shadowOrthoScale;
  105360. /**
  105361. * Gets the shadow projection scale against the optimal computed one.
  105362. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105363. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105364. */
  105365. /**
  105366. * Sets the shadow projection scale against the optimal computed one.
  105367. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105368. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105369. */
  105370. shadowOrthoScale: number;
  105371. /**
  105372. * Automatically compute the projection matrix to best fit (including all the casters)
  105373. * on each frame.
  105374. */
  105375. autoUpdateExtends: boolean;
  105376. private _orthoLeft;
  105377. private _orthoRight;
  105378. private _orthoTop;
  105379. private _orthoBottom;
  105380. /**
  105381. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105382. * The directional light is emitted from everywhere in the given direction.
  105383. * It can cast shadows.
  105384. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105385. * @param name The friendly name of the light
  105386. * @param direction The direction of the light
  105387. * @param scene The scene the light belongs to
  105388. */
  105389. constructor(name: string, direction: Vector3, scene: Scene);
  105390. /**
  105391. * Returns the string "DirectionalLight".
  105392. * @return The class name
  105393. */
  105394. getClassName(): string;
  105395. /**
  105396. * Returns the integer 1.
  105397. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105398. */
  105399. getTypeID(): number;
  105400. /**
  105401. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105402. * Returns the DirectionalLight Shadow projection matrix.
  105403. */
  105404. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105405. /**
  105406. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105407. * Returns the DirectionalLight Shadow projection matrix.
  105408. */
  105409. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105410. /**
  105411. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105412. * Returns the DirectionalLight Shadow projection matrix.
  105413. */
  105414. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105415. protected _buildUniformLayout(): void;
  105416. /**
  105417. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105418. * @param effect The effect to update
  105419. * @param lightIndex The index of the light in the effect to update
  105420. * @returns The directional light
  105421. */
  105422. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105423. /**
  105424. * Gets the minZ used for shadow according to both the scene and the light.
  105425. *
  105426. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105427. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105428. * @param activeCamera The camera we are returning the min for
  105429. * @returns the depth min z
  105430. */
  105431. getDepthMinZ(activeCamera: Camera): number;
  105432. /**
  105433. * Gets the maxZ used for shadow according to both the scene and the light.
  105434. *
  105435. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105436. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105437. * @param activeCamera The camera we are returning the max for
  105438. * @returns the depth max z
  105439. */
  105440. getDepthMaxZ(activeCamera: Camera): number;
  105441. /**
  105442. * Prepares the list of defines specific to the light type.
  105443. * @param defines the list of defines
  105444. * @param lightIndex defines the index of the light for the effect
  105445. */
  105446. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105447. }
  105448. }
  105449. declare module BABYLON {
  105450. /**
  105451. * A point light is a light defined by an unique point in world space.
  105452. * The light is emitted in every direction from this point.
  105453. * A good example of a point light is a standard light bulb.
  105454. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105455. */
  105456. export class PointLight extends ShadowLight {
  105457. private _shadowAngle;
  105458. /**
  105459. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105460. * This specifies what angle the shadow will use to be created.
  105461. *
  105462. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105463. */
  105464. /**
  105465. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105466. * This specifies what angle the shadow will use to be created.
  105467. *
  105468. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105469. */
  105470. shadowAngle: number;
  105471. /**
  105472. * Gets the direction if it has been set.
  105473. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105474. */
  105475. /**
  105476. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105477. */
  105478. direction: Vector3;
  105479. /**
  105480. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  105481. * A PointLight emits the light in every direction.
  105482. * It can cast shadows.
  105483. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  105484. * ```javascript
  105485. * var pointLight = new PointLight("pl", camera.position, scene);
  105486. * ```
  105487. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105488. * @param name The light friendly name
  105489. * @param position The position of the point light in the scene
  105490. * @param scene The scene the lights belongs to
  105491. */
  105492. constructor(name: string, position: Vector3, scene: Scene);
  105493. /**
  105494. * Returns the string "PointLight"
  105495. * @returns the class name
  105496. */
  105497. getClassName(): string;
  105498. /**
  105499. * Returns the integer 0.
  105500. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105501. */
  105502. getTypeID(): number;
  105503. /**
  105504. * Specifies wether or not the shadowmap should be a cube texture.
  105505. * @returns true if the shadowmap needs to be a cube texture.
  105506. */
  105507. needCube(): boolean;
  105508. /**
  105509. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  105510. * @param faceIndex The index of the face we are computed the direction to generate shadow
  105511. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  105512. */
  105513. getShadowDirection(faceIndex?: number): Vector3;
  105514. /**
  105515. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  105516. * - fov = PI / 2
  105517. * - aspect ratio : 1.0
  105518. * - z-near and far equal to the active camera minZ and maxZ.
  105519. * Returns the PointLight.
  105520. */
  105521. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105522. protected _buildUniformLayout(): void;
  105523. /**
  105524. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  105525. * @param effect The effect to update
  105526. * @param lightIndex The index of the light in the effect to update
  105527. * @returns The point light
  105528. */
  105529. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  105530. /**
  105531. * Prepares the list of defines specific to the light type.
  105532. * @param defines the list of defines
  105533. * @param lightIndex defines the index of the light for the effect
  105534. */
  105535. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105536. }
  105537. }
  105538. declare module BABYLON {
  105539. /**
  105540. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105541. * These values define a cone of light starting from the position, emitting toward the direction.
  105542. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105543. * and the exponent defines the speed of the decay of the light with distance (reach).
  105544. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105545. */
  105546. export class SpotLight extends ShadowLight {
  105547. private _angle;
  105548. private _innerAngle;
  105549. private _cosHalfAngle;
  105550. private _lightAngleScale;
  105551. private _lightAngleOffset;
  105552. /**
  105553. * Gets the cone angle of the spot light in Radians.
  105554. */
  105555. /**
  105556. * Sets the cone angle of the spot light in Radians.
  105557. */
  105558. angle: number;
  105559. /**
  105560. * Only used in gltf falloff mode, this defines the angle where
  105561. * the directional falloff will start before cutting at angle which could be seen
  105562. * as outer angle.
  105563. */
  105564. /**
  105565. * Only used in gltf falloff mode, this defines the angle where
  105566. * the directional falloff will start before cutting at angle which could be seen
  105567. * as outer angle.
  105568. */
  105569. innerAngle: number;
  105570. private _shadowAngleScale;
  105571. /**
  105572. * Allows scaling the angle of the light for shadow generation only.
  105573. */
  105574. /**
  105575. * Allows scaling the angle of the light for shadow generation only.
  105576. */
  105577. shadowAngleScale: number;
  105578. /**
  105579. * The light decay speed with the distance from the emission spot.
  105580. */
  105581. exponent: number;
  105582. private _projectionTextureMatrix;
  105583. /**
  105584. * Allows reading the projecton texture
  105585. */
  105586. readonly projectionTextureMatrix: Matrix;
  105587. protected _projectionTextureLightNear: number;
  105588. /**
  105589. * Gets the near clip of the Spotlight for texture projection.
  105590. */
  105591. /**
  105592. * Sets the near clip of the Spotlight for texture projection.
  105593. */
  105594. projectionTextureLightNear: number;
  105595. protected _projectionTextureLightFar: number;
  105596. /**
  105597. * Gets the far clip of the Spotlight for texture projection.
  105598. */
  105599. /**
  105600. * Sets the far clip of the Spotlight for texture projection.
  105601. */
  105602. projectionTextureLightFar: number;
  105603. protected _projectionTextureUpDirection: Vector3;
  105604. /**
  105605. * Gets the Up vector of the Spotlight for texture projection.
  105606. */
  105607. /**
  105608. * Sets the Up vector of the Spotlight for texture projection.
  105609. */
  105610. projectionTextureUpDirection: Vector3;
  105611. private _projectionTexture;
  105612. /**
  105613. * Gets the projection texture of the light.
  105614. */
  105615. /**
  105616. * Sets the projection texture of the light.
  105617. */
  105618. projectionTexture: Nullable<BaseTexture>;
  105619. private _projectionTextureViewLightDirty;
  105620. private _projectionTextureProjectionLightDirty;
  105621. private _projectionTextureDirty;
  105622. private _projectionTextureViewTargetVector;
  105623. private _projectionTextureViewLightMatrix;
  105624. private _projectionTextureProjectionLightMatrix;
  105625. private _projectionTextureScalingMatrix;
  105626. /**
  105627. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105628. * It can cast shadows.
  105629. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105630. * @param name The light friendly name
  105631. * @param position The position of the spot light in the scene
  105632. * @param direction The direction of the light in the scene
  105633. * @param angle The cone angle of the light in Radians
  105634. * @param exponent The light decay speed with the distance from the emission spot
  105635. * @param scene The scene the lights belongs to
  105636. */
  105637. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105638. /**
  105639. * Returns the string "SpotLight".
  105640. * @returns the class name
  105641. */
  105642. getClassName(): string;
  105643. /**
  105644. * Returns the integer 2.
  105645. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105646. */
  105647. getTypeID(): number;
  105648. /**
  105649. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105650. */
  105651. protected _setDirection(value: Vector3): void;
  105652. /**
  105653. * Overrides the position setter to recompute the projection texture view light Matrix.
  105654. */
  105655. protected _setPosition(value: Vector3): void;
  105656. /**
  105657. * 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.
  105658. * Returns the SpotLight.
  105659. */
  105660. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105661. protected _computeProjectionTextureViewLightMatrix(): void;
  105662. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105663. /**
  105664. * Main function for light texture projection matrix computing.
  105665. */
  105666. protected _computeProjectionTextureMatrix(): void;
  105667. protected _buildUniformLayout(): void;
  105668. private _computeAngleValues;
  105669. /**
  105670. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105671. * @param effect The effect to update
  105672. * @param lightIndex The index of the light in the effect to update
  105673. * @returns The spot light
  105674. */
  105675. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105676. /**
  105677. * Disposes the light and the associated resources.
  105678. */
  105679. dispose(): void;
  105680. /**
  105681. * Prepares the list of defines specific to the light type.
  105682. * @param defines the list of defines
  105683. * @param lightIndex defines the index of the light for the effect
  105684. */
  105685. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105686. }
  105687. }
  105688. declare module BABYLON {
  105689. /**
  105690. * Header information of HDR texture files.
  105691. */
  105692. export interface HDRInfo {
  105693. /**
  105694. * The height of the texture in pixels.
  105695. */
  105696. height: number;
  105697. /**
  105698. * The width of the texture in pixels.
  105699. */
  105700. width: number;
  105701. /**
  105702. * The index of the beginning of the data in the binary file.
  105703. */
  105704. dataPosition: number;
  105705. }
  105706. /**
  105707. * This groups tools to convert HDR texture to native colors array.
  105708. */
  105709. export class HDRTools {
  105710. private static Ldexp;
  105711. private static Rgbe2float;
  105712. private static readStringLine;
  105713. /**
  105714. * Reads header information from an RGBE texture stored in a native array.
  105715. * More information on this format are available here:
  105716. * https://en.wikipedia.org/wiki/RGBE_image_format
  105717. *
  105718. * @param uint8array The binary file stored in native array.
  105719. * @return The header information.
  105720. */
  105721. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  105722. /**
  105723. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  105724. * This RGBE texture needs to store the information as a panorama.
  105725. *
  105726. * More information on this format are available here:
  105727. * https://en.wikipedia.org/wiki/RGBE_image_format
  105728. *
  105729. * @param buffer The binary file stored in an array buffer.
  105730. * @param size The expected size of the extracted cubemap.
  105731. * @return The Cube Map information.
  105732. */
  105733. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  105734. /**
  105735. * Returns the pixels data extracted from an RGBE texture.
  105736. * This pixels will be stored left to right up to down in the R G B order in one array.
  105737. *
  105738. * More information on this format are available here:
  105739. * https://en.wikipedia.org/wiki/RGBE_image_format
  105740. *
  105741. * @param uint8array The binary file stored in an array buffer.
  105742. * @param hdrInfo The header information of the file.
  105743. * @return The pixels data in RGB right to left up to down order.
  105744. */
  105745. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  105746. private static RGBE_ReadPixels_RLE;
  105747. }
  105748. }
  105749. declare module BABYLON {
  105750. /**
  105751. * This represents a texture coming from an HDR input.
  105752. *
  105753. * The only supported format is currently panorama picture stored in RGBE format.
  105754. * Example of such files can be found on HDRLib: http://hdrlib.com/
  105755. */
  105756. export class HDRCubeTexture extends BaseTexture {
  105757. private static _facesMapping;
  105758. private _generateHarmonics;
  105759. private _noMipmap;
  105760. private _textureMatrix;
  105761. private _size;
  105762. private _onLoad;
  105763. private _onError;
  105764. /**
  105765. * The texture URL.
  105766. */
  105767. url: string;
  105768. /**
  105769. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  105770. */
  105771. coordinatesMode: number;
  105772. protected _isBlocking: boolean;
  105773. /**
  105774. * Sets wether or not the texture is blocking during loading.
  105775. */
  105776. /**
  105777. * Gets wether or not the texture is blocking during loading.
  105778. */
  105779. isBlocking: boolean;
  105780. protected _rotationY: number;
  105781. /**
  105782. * Sets texture matrix rotation angle around Y axis in radians.
  105783. */
  105784. /**
  105785. * Gets texture matrix rotation angle around Y axis radians.
  105786. */
  105787. rotationY: number;
  105788. /**
  105789. * Gets or sets the center of the bounding box associated with the cube texture
  105790. * It must define where the camera used to render the texture was set
  105791. */
  105792. boundingBoxPosition: Vector3;
  105793. private _boundingBoxSize;
  105794. /**
  105795. * Gets or sets the size of the bounding box associated with the cube texture
  105796. * When defined, the cubemap will switch to local mode
  105797. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  105798. * @example https://www.babylonjs-playground.com/#RNASML
  105799. */
  105800. boundingBoxSize: Vector3;
  105801. /**
  105802. * Instantiates an HDRTexture from the following parameters.
  105803. *
  105804. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  105805. * @param scene The scene the texture will be used in
  105806. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105807. * @param noMipmap Forces to not generate the mipmap if true
  105808. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  105809. * @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)
  105810. * @param reserved Reserved flag for internal use.
  105811. */
  105812. 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>);
  105813. /**
  105814. * Get the current class name of the texture useful for serialization or dynamic coding.
  105815. * @returns "HDRCubeTexture"
  105816. */
  105817. getClassName(): string;
  105818. /**
  105819. * Occurs when the file is raw .hdr file.
  105820. */
  105821. private loadTexture;
  105822. clone(): HDRCubeTexture;
  105823. delayLoad(): void;
  105824. /**
  105825. * Get the texture reflection matrix used to rotate/transform the reflection.
  105826. * @returns the reflection matrix
  105827. */
  105828. getReflectionTextureMatrix(): Matrix;
  105829. /**
  105830. * Set the texture reflection matrix used to rotate/transform the reflection.
  105831. * @param value Define the reflection matrix to set
  105832. */
  105833. setReflectionTextureMatrix(value: Matrix): void;
  105834. /**
  105835. * Parses a JSON representation of an HDR Texture in order to create the texture
  105836. * @param parsedTexture Define the JSON representation
  105837. * @param scene Define the scene the texture should be created in
  105838. * @param rootUrl Define the root url in case we need to load relative dependencies
  105839. * @returns the newly created texture after parsing
  105840. */
  105841. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  105842. serialize(): any;
  105843. }
  105844. }
  105845. declare module BABYLON {
  105846. /**
  105847. * Class used to control physics engine
  105848. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105849. */
  105850. export class PhysicsEngine implements IPhysicsEngine {
  105851. private _physicsPlugin;
  105852. /**
  105853. * Global value used to control the smallest number supported by the simulation
  105854. */
  105855. static Epsilon: number;
  105856. private _impostors;
  105857. private _joints;
  105858. /**
  105859. * Gets the gravity vector used by the simulation
  105860. */
  105861. gravity: Vector3;
  105862. /**
  105863. * Factory used to create the default physics plugin.
  105864. * @returns The default physics plugin
  105865. */
  105866. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  105867. /**
  105868. * Creates a new Physics Engine
  105869. * @param gravity defines the gravity vector used by the simulation
  105870. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  105871. */
  105872. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  105873. /**
  105874. * Sets the gravity vector used by the simulation
  105875. * @param gravity defines the gravity vector to use
  105876. */
  105877. setGravity(gravity: Vector3): void;
  105878. /**
  105879. * Set the time step of the physics engine.
  105880. * Default is 1/60.
  105881. * To slow it down, enter 1/600 for example.
  105882. * To speed it up, 1/30
  105883. * @param newTimeStep defines the new timestep to apply to this world.
  105884. */
  105885. setTimeStep(newTimeStep?: number): void;
  105886. /**
  105887. * Get the time step of the physics engine.
  105888. * @returns the current time step
  105889. */
  105890. getTimeStep(): number;
  105891. /**
  105892. * Release all resources
  105893. */
  105894. dispose(): void;
  105895. /**
  105896. * Gets the name of the current physics plugin
  105897. * @returns the name of the plugin
  105898. */
  105899. getPhysicsPluginName(): string;
  105900. /**
  105901. * Adding a new impostor for the impostor tracking.
  105902. * This will be done by the impostor itself.
  105903. * @param impostor the impostor to add
  105904. */
  105905. addImpostor(impostor: PhysicsImpostor): void;
  105906. /**
  105907. * Remove an impostor from the engine.
  105908. * This impostor and its mesh will not longer be updated by the physics engine.
  105909. * @param impostor the impostor to remove
  105910. */
  105911. removeImpostor(impostor: PhysicsImpostor): void;
  105912. /**
  105913. * Add a joint to the physics engine
  105914. * @param mainImpostor defines the main impostor to which the joint is added.
  105915. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105916. * @param joint defines the joint that will connect both impostors.
  105917. */
  105918. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105919. /**
  105920. * Removes a joint from the simulation
  105921. * @param mainImpostor defines the impostor used with the joint
  105922. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105923. * @param joint defines the joint to remove
  105924. */
  105925. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105926. /**
  105927. * Called by the scene. No need to call it.
  105928. * @param delta defines the timespam between frames
  105929. */
  105930. _step(delta: number): void;
  105931. /**
  105932. * Gets the current plugin used to run the simulation
  105933. * @returns current plugin
  105934. */
  105935. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105936. /**
  105937. * Gets the list of physic impostors
  105938. * @returns an array of PhysicsImpostor
  105939. */
  105940. getImpostors(): Array<PhysicsImpostor>;
  105941. /**
  105942. * Gets the impostor for a physics enabled object
  105943. * @param object defines the object impersonated by the impostor
  105944. * @returns the PhysicsImpostor or null if not found
  105945. */
  105946. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105947. /**
  105948. * Gets the impostor for a physics body object
  105949. * @param body defines physics body used by the impostor
  105950. * @returns the PhysicsImpostor or null if not found
  105951. */
  105952. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105953. /**
  105954. * Does a raycast in the physics world
  105955. * @param from when should the ray start?
  105956. * @param to when should the ray end?
  105957. * @returns PhysicsRaycastResult
  105958. */
  105959. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105960. }
  105961. }
  105962. declare module BABYLON {
  105963. /** @hidden */
  105964. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  105965. private _useDeltaForWorldStep;
  105966. world: any;
  105967. name: string;
  105968. private _physicsMaterials;
  105969. private _fixedTimeStep;
  105970. private _cannonRaycastResult;
  105971. private _raycastResult;
  105972. BJSCANNON: any;
  105973. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  105974. setGravity(gravity: Vector3): void;
  105975. setTimeStep(timeStep: number): void;
  105976. getTimeStep(): number;
  105977. executeStep(delta: number): void;
  105978. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105979. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105980. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105981. private _processChildMeshes;
  105982. removePhysicsBody(impostor: PhysicsImpostor): void;
  105983. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105984. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105985. private _addMaterial;
  105986. private _checkWithEpsilon;
  105987. private _createShape;
  105988. private _createHeightmap;
  105989. private _minus90X;
  105990. private _plus90X;
  105991. private _tmpPosition;
  105992. private _tmpDeltaPosition;
  105993. private _tmpUnityRotation;
  105994. private _updatePhysicsBodyTransformation;
  105995. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105996. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105997. isSupported(): boolean;
  105998. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105999. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106000. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106001. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106002. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106003. getBodyMass(impostor: PhysicsImpostor): number;
  106004. getBodyFriction(impostor: PhysicsImpostor): number;
  106005. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106006. getBodyRestitution(impostor: PhysicsImpostor): number;
  106007. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106008. sleepBody(impostor: PhysicsImpostor): void;
  106009. wakeUpBody(impostor: PhysicsImpostor): void;
  106010. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  106011. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  106012. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  106013. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106014. getRadius(impostor: PhysicsImpostor): number;
  106015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106016. dispose(): void;
  106017. private _extendNamespace;
  106018. /**
  106019. * Does a raycast in the physics world
  106020. * @param from when should the ray start?
  106021. * @param to when should the ray end?
  106022. * @returns PhysicsRaycastResult
  106023. */
  106024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106025. }
  106026. }
  106027. declare module BABYLON {
  106028. /** @hidden */
  106029. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  106030. world: any;
  106031. name: string;
  106032. BJSOIMO: any;
  106033. private _raycastResult;
  106034. constructor(iterations?: number, oimoInjection?: any);
  106035. setGravity(gravity: Vector3): void;
  106036. setTimeStep(timeStep: number): void;
  106037. getTimeStep(): number;
  106038. private _tmpImpostorsArray;
  106039. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106040. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106041. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106042. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106043. private _tmpPositionVector;
  106044. removePhysicsBody(impostor: PhysicsImpostor): void;
  106045. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106046. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106047. isSupported(): boolean;
  106048. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106049. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106050. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106051. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106052. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106053. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106054. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106055. getBodyMass(impostor: PhysicsImpostor): number;
  106056. getBodyFriction(impostor: PhysicsImpostor): number;
  106057. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106058. getBodyRestitution(impostor: PhysicsImpostor): number;
  106059. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106060. sleepBody(impostor: PhysicsImpostor): void;
  106061. wakeUpBody(impostor: PhysicsImpostor): void;
  106062. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106063. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  106064. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106065. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106066. getRadius(impostor: PhysicsImpostor): number;
  106067. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106068. dispose(): void;
  106069. /**
  106070. * Does a raycast in the physics world
  106071. * @param from when should the ray start?
  106072. * @param to when should the ray end?
  106073. * @returns PhysicsRaycastResult
  106074. */
  106075. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106076. }
  106077. }
  106078. declare module BABYLON {
  106079. interface AbstractScene {
  106080. /**
  106081. * The list of reflection probes added to the scene
  106082. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  106083. */
  106084. reflectionProbes: Array<ReflectionProbe>;
  106085. /**
  106086. * Removes the given reflection probe from this scene.
  106087. * @param toRemove The reflection probe to remove
  106088. * @returns The index of the removed reflection probe
  106089. */
  106090. removeReflectionProbe(toRemove: ReflectionProbe): number;
  106091. /**
  106092. * Adds the given reflection probe to this scene.
  106093. * @param newReflectionProbe The reflection probe to add
  106094. */
  106095. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  106096. }
  106097. /**
  106098. * Class used to generate realtime reflection / refraction cube textures
  106099. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  106100. */
  106101. export class ReflectionProbe {
  106102. /** defines the name of the probe */
  106103. name: string;
  106104. private _scene;
  106105. private _renderTargetTexture;
  106106. private _projectionMatrix;
  106107. private _viewMatrix;
  106108. private _target;
  106109. private _add;
  106110. private _attachedMesh;
  106111. private _invertYAxis;
  106112. /** Gets or sets probe position (center of the cube map) */
  106113. position: Vector3;
  106114. /**
  106115. * Creates a new reflection probe
  106116. * @param name defines the name of the probe
  106117. * @param size defines the texture resolution (for each face)
  106118. * @param scene defines the hosting scene
  106119. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  106120. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  106121. */
  106122. constructor(
  106123. /** defines the name of the probe */
  106124. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  106125. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  106126. samples: number;
  106127. /** Gets or sets the refresh rate to use (on every frame by default) */
  106128. refreshRate: number;
  106129. /**
  106130. * Gets the hosting scene
  106131. * @returns a Scene
  106132. */
  106133. getScene(): Scene;
  106134. /** Gets the internal CubeTexture used to render to */
  106135. readonly cubeTexture: RenderTargetTexture;
  106136. /** Gets the list of meshes to render */
  106137. readonly renderList: Nullable<AbstractMesh[]>;
  106138. /**
  106139. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  106140. * @param mesh defines the mesh to attach to
  106141. */
  106142. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106143. /**
  106144. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  106145. * @param renderingGroupId The rendering group id corresponding to its index
  106146. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  106147. */
  106148. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  106149. /**
  106150. * Clean all associated resources
  106151. */
  106152. dispose(): void;
  106153. /**
  106154. * Converts the reflection probe information to a readable string for debug purpose.
  106155. * @param fullDetails Supports for multiple levels of logging within scene loading
  106156. * @returns the human readable reflection probe info
  106157. */
  106158. toString(fullDetails?: boolean): string;
  106159. /**
  106160. * Get the class name of the relfection probe.
  106161. * @returns "ReflectionProbe"
  106162. */
  106163. getClassName(): string;
  106164. /**
  106165. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  106166. * @returns The JSON representation of the texture
  106167. */
  106168. serialize(): any;
  106169. /**
  106170. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  106171. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  106172. * @param scene Define the scene the parsed reflection probe should be instantiated in
  106173. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  106174. * @returns The parsed reflection probe if successful
  106175. */
  106176. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  106177. }
  106178. }
  106179. declare module BABYLON {
  106180. /** @hidden */
  106181. export var _BabylonLoaderRegistered: boolean;
  106182. }
  106183. declare module BABYLON {
  106184. /**
  106185. * The Physically based simple base material of BJS.
  106186. *
  106187. * This enables better naming and convention enforcements on top of the pbrMaterial.
  106188. * It is used as the base class for both the specGloss and metalRough conventions.
  106189. */
  106190. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  106191. /**
  106192. * Number of Simultaneous lights allowed on the material.
  106193. */
  106194. maxSimultaneousLights: number;
  106195. /**
  106196. * If sets to true, disables all the lights affecting the material.
  106197. */
  106198. disableLighting: boolean;
  106199. /**
  106200. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  106201. */
  106202. environmentTexture: BaseTexture;
  106203. /**
  106204. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106205. */
  106206. invertNormalMapX: boolean;
  106207. /**
  106208. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106209. */
  106210. invertNormalMapY: boolean;
  106211. /**
  106212. * Normal map used in the model.
  106213. */
  106214. normalTexture: BaseTexture;
  106215. /**
  106216. * Emissivie color used to self-illuminate the model.
  106217. */
  106218. emissiveColor: Color3;
  106219. /**
  106220. * Emissivie texture used to self-illuminate the model.
  106221. */
  106222. emissiveTexture: BaseTexture;
  106223. /**
  106224. * Occlusion Channel Strenght.
  106225. */
  106226. occlusionStrength: number;
  106227. /**
  106228. * Occlusion Texture of the material (adding extra occlusion effects).
  106229. */
  106230. occlusionTexture: BaseTexture;
  106231. /**
  106232. * Defines the alpha limits in alpha test mode.
  106233. */
  106234. alphaCutOff: number;
  106235. /**
  106236. * Gets the current double sided mode.
  106237. */
  106238. /**
  106239. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106240. */
  106241. doubleSided: boolean;
  106242. /**
  106243. * Stores the pre-calculated light information of a mesh in a texture.
  106244. */
  106245. lightmapTexture: BaseTexture;
  106246. /**
  106247. * If true, the light map contains occlusion information instead of lighting info.
  106248. */
  106249. useLightmapAsShadowmap: boolean;
  106250. /**
  106251. * Instantiates a new PBRMaterial instance.
  106252. *
  106253. * @param name The material name
  106254. * @param scene The scene the material will be use in.
  106255. */
  106256. constructor(name: string, scene: Scene);
  106257. getClassName(): string;
  106258. }
  106259. }
  106260. declare module BABYLON {
  106261. /**
  106262. * The PBR material of BJS following the metal roughness convention.
  106263. *
  106264. * This fits to the PBR convention in the GLTF definition:
  106265. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  106266. */
  106267. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  106268. /**
  106269. * The base color has two different interpretations depending on the value of metalness.
  106270. * When the material is a metal, the base color is the specific measured reflectance value
  106271. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  106272. * of the material.
  106273. */
  106274. baseColor: Color3;
  106275. /**
  106276. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  106277. * well as opacity information in the alpha channel.
  106278. */
  106279. baseTexture: BaseTexture;
  106280. /**
  106281. * Specifies the metallic scalar value of the material.
  106282. * Can also be used to scale the metalness values of the metallic texture.
  106283. */
  106284. metallic: number;
  106285. /**
  106286. * Specifies the roughness scalar value of the material.
  106287. * Can also be used to scale the roughness values of the metallic texture.
  106288. */
  106289. roughness: number;
  106290. /**
  106291. * Texture containing both the metallic value in the B channel and the
  106292. * roughness value in the G channel to keep better precision.
  106293. */
  106294. metallicRoughnessTexture: BaseTexture;
  106295. /**
  106296. * Instantiates a new PBRMetalRoughnessMaterial instance.
  106297. *
  106298. * @param name The material name
  106299. * @param scene The scene the material will be use in.
  106300. */
  106301. constructor(name: string, scene: Scene);
  106302. /**
  106303. * Return the currrent class name of the material.
  106304. */
  106305. getClassName(): string;
  106306. /**
  106307. * Makes a duplicate of the current material.
  106308. * @param name - name to use for the new material.
  106309. */
  106310. clone(name: string): PBRMetallicRoughnessMaterial;
  106311. /**
  106312. * Serialize the material to a parsable JSON object.
  106313. */
  106314. serialize(): any;
  106315. /**
  106316. * Parses a JSON object correponding to the serialize function.
  106317. */
  106318. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  106319. }
  106320. }
  106321. declare module BABYLON {
  106322. /**
  106323. * The PBR material of BJS following the specular glossiness convention.
  106324. *
  106325. * This fits to the PBR convention in the GLTF definition:
  106326. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  106327. */
  106328. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  106329. /**
  106330. * Specifies the diffuse color of the material.
  106331. */
  106332. diffuseColor: Color3;
  106333. /**
  106334. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  106335. * channel.
  106336. */
  106337. diffuseTexture: BaseTexture;
  106338. /**
  106339. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  106340. */
  106341. specularColor: Color3;
  106342. /**
  106343. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  106344. */
  106345. glossiness: number;
  106346. /**
  106347. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  106348. */
  106349. specularGlossinessTexture: BaseTexture;
  106350. /**
  106351. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  106352. *
  106353. * @param name The material name
  106354. * @param scene The scene the material will be use in.
  106355. */
  106356. constructor(name: string, scene: Scene);
  106357. /**
  106358. * Return the currrent class name of the material.
  106359. */
  106360. getClassName(): string;
  106361. /**
  106362. * Makes a duplicate of the current material.
  106363. * @param name - name to use for the new material.
  106364. */
  106365. clone(name: string): PBRSpecularGlossinessMaterial;
  106366. /**
  106367. * Serialize the material to a parsable JSON object.
  106368. */
  106369. serialize(): any;
  106370. /**
  106371. * Parses a JSON object correponding to the serialize function.
  106372. */
  106373. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  106374. }
  106375. }
  106376. declare module BABYLON {
  106377. /**
  106378. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  106379. * It can help converting any input color in a desired output one. This can then be used to create effects
  106380. * from sepia, black and white to sixties or futuristic rendering...
  106381. *
  106382. * The only supported format is currently 3dl.
  106383. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  106384. */
  106385. export class ColorGradingTexture extends BaseTexture {
  106386. /**
  106387. * The current texture matrix. (will always be identity in color grading texture)
  106388. */
  106389. private _textureMatrix;
  106390. /**
  106391. * The texture URL.
  106392. */
  106393. url: string;
  106394. /**
  106395. * Empty line regex stored for GC.
  106396. */
  106397. private static _noneEmptyLineRegex;
  106398. private _engine;
  106399. /**
  106400. * Instantiates a ColorGradingTexture from the following parameters.
  106401. *
  106402. * @param url The location of the color gradind data (currently only supporting 3dl)
  106403. * @param scene The scene the texture will be used in
  106404. */
  106405. constructor(url: string, scene: Scene);
  106406. /**
  106407. * Returns the texture matrix used in most of the material.
  106408. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  106409. */
  106410. getTextureMatrix(): Matrix;
  106411. /**
  106412. * Occurs when the file being loaded is a .3dl LUT file.
  106413. */
  106414. private load3dlTexture;
  106415. /**
  106416. * Starts the loading process of the texture.
  106417. */
  106418. private loadTexture;
  106419. /**
  106420. * Clones the color gradind texture.
  106421. */
  106422. clone(): ColorGradingTexture;
  106423. /**
  106424. * Called during delayed load for textures.
  106425. */
  106426. delayLoad(): void;
  106427. /**
  106428. * Parses a color grading texture serialized by Babylon.
  106429. * @param parsedTexture The texture information being parsedTexture
  106430. * @param scene The scene to load the texture in
  106431. * @param rootUrl The root url of the data assets to load
  106432. * @return A color gradind texture
  106433. */
  106434. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  106435. /**
  106436. * Serializes the LUT texture to json format.
  106437. */
  106438. serialize(): any;
  106439. }
  106440. }
  106441. declare module BABYLON {
  106442. /**
  106443. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  106444. */
  106445. export class EquiRectangularCubeTexture extends BaseTexture {
  106446. /** The six faces of the cube. */
  106447. private static _FacesMapping;
  106448. private _noMipmap;
  106449. private _onLoad;
  106450. private _onError;
  106451. /** The size of the cubemap. */
  106452. private _size;
  106453. /** The buffer of the image. */
  106454. private _buffer;
  106455. /** The width of the input image. */
  106456. private _width;
  106457. /** The height of the input image. */
  106458. private _height;
  106459. /** The URL to the image. */
  106460. url: string;
  106461. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  106462. coordinatesMode: number;
  106463. /**
  106464. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  106465. * @param url The location of the image
  106466. * @param scene The scene the texture will be used in
  106467. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106468. * @param noMipmap Forces to not generate the mipmap if true
  106469. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  106470. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  106471. * @param onLoad — defines a callback called when texture is loaded
  106472. * @param onError — defines a callback called if there is an error
  106473. */
  106474. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  106475. /**
  106476. * Load the image data, by putting the image on a canvas and extracting its buffer.
  106477. */
  106478. private loadImage;
  106479. /**
  106480. * Convert the image buffer into a cubemap and create a CubeTexture.
  106481. */
  106482. private loadTexture;
  106483. /**
  106484. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  106485. * @param buffer The ArrayBuffer that should be converted.
  106486. * @returns The buffer as Float32Array.
  106487. */
  106488. private getFloat32ArrayFromArrayBuffer;
  106489. /**
  106490. * Get the current class name of the texture useful for serialization or dynamic coding.
  106491. * @returns "EquiRectangularCubeTexture"
  106492. */
  106493. getClassName(): string;
  106494. /**
  106495. * Create a clone of the current EquiRectangularCubeTexture and return it.
  106496. * @returns A clone of the current EquiRectangularCubeTexture.
  106497. */
  106498. clone(): EquiRectangularCubeTexture;
  106499. }
  106500. }
  106501. declare module BABYLON {
  106502. /**
  106503. * Based on jsTGALoader - Javascript loader for TGA file
  106504. * By Vincent Thibault
  106505. * @see http://blog.robrowser.com/javascript-tga-loader.html
  106506. */
  106507. export class TGATools {
  106508. private static _TYPE_INDEXED;
  106509. private static _TYPE_RGB;
  106510. private static _TYPE_GREY;
  106511. private static _TYPE_RLE_INDEXED;
  106512. private static _TYPE_RLE_RGB;
  106513. private static _TYPE_RLE_GREY;
  106514. private static _ORIGIN_MASK;
  106515. private static _ORIGIN_SHIFT;
  106516. private static _ORIGIN_BL;
  106517. private static _ORIGIN_BR;
  106518. private static _ORIGIN_UL;
  106519. private static _ORIGIN_UR;
  106520. /**
  106521. * Gets the header of a TGA file
  106522. * @param data defines the TGA data
  106523. * @returns the header
  106524. */
  106525. static GetTGAHeader(data: Uint8Array): any;
  106526. /**
  106527. * Uploads TGA content to a Babylon Texture
  106528. * @hidden
  106529. */
  106530. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  106531. /** @hidden */
  106532. 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;
  106533. /** @hidden */
  106534. 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;
  106535. /** @hidden */
  106536. 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;
  106537. /** @hidden */
  106538. 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;
  106539. /** @hidden */
  106540. 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;
  106541. /** @hidden */
  106542. 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;
  106543. }
  106544. }
  106545. declare module BABYLON {
  106546. /**
  106547. * Implementation of the TGA Texture Loader.
  106548. * @hidden
  106549. */
  106550. export class _TGATextureLoader implements IInternalTextureLoader {
  106551. /**
  106552. * Defines wether the loader supports cascade loading the different faces.
  106553. */
  106554. readonly supportCascades: boolean;
  106555. /**
  106556. * This returns if the loader support the current file information.
  106557. * @param extension defines the file extension of the file being loaded
  106558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106559. * @param fallback defines the fallback internal texture if any
  106560. * @param isBase64 defines whether the texture is encoded as a base64
  106561. * @param isBuffer defines whether the texture data are stored as a buffer
  106562. * @returns true if the loader can load the specified file
  106563. */
  106564. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106565. /**
  106566. * Transform the url before loading if required.
  106567. * @param rootUrl the url of the texture
  106568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106569. * @returns the transformed texture
  106570. */
  106571. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106572. /**
  106573. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106574. * @param rootUrl the url of the texture
  106575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106576. * @returns the fallback texture
  106577. */
  106578. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106579. /**
  106580. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106581. * @param data contains the texture data
  106582. * @param texture defines the BabylonJS internal texture
  106583. * @param createPolynomials will be true if polynomials have been requested
  106584. * @param onLoad defines the callback to trigger once the texture is ready
  106585. * @param onError defines the callback to trigger in case of error
  106586. */
  106587. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106588. /**
  106589. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106590. * @param data contains the texture data
  106591. * @param texture defines the BabylonJS internal texture
  106592. * @param callback defines the method to call once ready to upload
  106593. */
  106594. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106595. }
  106596. }
  106597. declare module BABYLON {
  106598. /**
  106599. * 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.
  106600. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106601. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106602. */
  106603. export class CustomProceduralTexture extends ProceduralTexture {
  106604. private _animate;
  106605. private _time;
  106606. private _config;
  106607. private _texturePath;
  106608. /**
  106609. * Instantiates a new Custom Procedural Texture.
  106610. * 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.
  106611. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106612. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106613. * @param name Define the name of the texture
  106614. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  106615. * @param size Define the size of the texture to create
  106616. * @param scene Define the scene the texture belongs to
  106617. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  106618. * @param generateMipMaps Define if the texture should creates mip maps or not
  106619. */
  106620. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106621. private _loadJson;
  106622. /**
  106623. * Is the texture ready to be used ? (rendered at least once)
  106624. * @returns true if ready, otherwise, false.
  106625. */
  106626. isReady(): boolean;
  106627. /**
  106628. * Render the texture to its associated render target.
  106629. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  106630. */
  106631. render(useCameraPostProcess?: boolean): void;
  106632. /**
  106633. * Update the list of dependant textures samplers in the shader.
  106634. */
  106635. updateTextures(): void;
  106636. /**
  106637. * Update the uniform values of the procedural texture in the shader.
  106638. */
  106639. updateShaderUniforms(): void;
  106640. /**
  106641. * Define if the texture animates or not.
  106642. */
  106643. animate: boolean;
  106644. }
  106645. }
  106646. declare module BABYLON {
  106647. /** @hidden */
  106648. export var noisePixelShader: {
  106649. name: string;
  106650. shader: string;
  106651. };
  106652. }
  106653. declare module BABYLON {
  106654. /**
  106655. * Class used to generate noise procedural textures
  106656. */
  106657. export class NoiseProceduralTexture extends ProceduralTexture {
  106658. private _time;
  106659. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  106660. brightness: number;
  106661. /** Defines the number of octaves to process */
  106662. octaves: number;
  106663. /** Defines the level of persistence (0.8 by default) */
  106664. persistence: number;
  106665. /** Gets or sets animation speed factor (default is 1) */
  106666. animationSpeedFactor: number;
  106667. /**
  106668. * Creates a new NoiseProceduralTexture
  106669. * @param name defines the name fo the texture
  106670. * @param size defines the size of the texture (default is 256)
  106671. * @param scene defines the hosting scene
  106672. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  106673. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  106674. */
  106675. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106676. private _updateShaderUniforms;
  106677. protected _getDefines(): string;
  106678. /** Generate the current state of the procedural texture */
  106679. render(useCameraPostProcess?: boolean): void;
  106680. /**
  106681. * Serializes this noise procedural texture
  106682. * @returns a serialized noise procedural texture object
  106683. */
  106684. serialize(): any;
  106685. /**
  106686. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  106687. * @param parsedTexture defines parsed texture data
  106688. * @param scene defines the current scene
  106689. * @param rootUrl defines the root URL containing noise procedural texture information
  106690. * @returns a parsed NoiseProceduralTexture
  106691. */
  106692. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  106693. }
  106694. }
  106695. declare module BABYLON {
  106696. /**
  106697. * Raw cube texture where the raw buffers are passed in
  106698. */
  106699. export class RawCubeTexture extends CubeTexture {
  106700. /**
  106701. * Creates a cube texture where the raw buffers are passed in.
  106702. * @param scene defines the scene the texture is attached to
  106703. * @param data defines the array of data to use to create each face
  106704. * @param size defines the size of the textures
  106705. * @param format defines the format of the data
  106706. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106707. * @param generateMipMaps defines if the engine should generate the mip levels
  106708. * @param invertY defines if data must be stored with Y axis inverted
  106709. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106710. * @param compression defines the compression used (null by default)
  106711. */
  106712. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  106713. /**
  106714. * Updates the raw cube texture.
  106715. * @param data defines the data to store
  106716. * @param format defines the data format
  106717. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106718. * @param invertY defines if data must be stored with Y axis inverted
  106719. * @param compression defines the compression used (null by default)
  106720. * @param level defines which level of the texture to update
  106721. */
  106722. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  106723. /**
  106724. * Updates a raw cube texture with RGBD encoded data.
  106725. * @param data defines the array of data [mipmap][face] to use to create each face
  106726. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  106727. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  106728. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  106729. * @returns a promsie that resolves when the operation is complete
  106730. */
  106731. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  106732. /**
  106733. * Clones the raw cube texture.
  106734. * @return a new cube texture
  106735. */
  106736. clone(): CubeTexture;
  106737. /** @hidden */
  106738. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106739. }
  106740. }
  106741. declare module BABYLON {
  106742. /**
  106743. * Class used to store 3D textures containing user data
  106744. */
  106745. export class RawTexture3D extends Texture {
  106746. /** Gets or sets the texture format to use */
  106747. format: number;
  106748. private _engine;
  106749. /**
  106750. * Create a new RawTexture3D
  106751. * @param data defines the data of the texture
  106752. * @param width defines the width of the texture
  106753. * @param height defines the height of the texture
  106754. * @param depth defines the depth of the texture
  106755. * @param format defines the texture format to use
  106756. * @param scene defines the hosting scene
  106757. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  106758. * @param invertY defines if texture must be stored with Y axis inverted
  106759. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  106760. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  106761. */
  106762. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  106763. /** Gets or sets the texture format to use */
  106764. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  106765. /**
  106766. * Update the texture with new data
  106767. * @param data defines the data to store in the texture
  106768. */
  106769. update(data: ArrayBufferView): void;
  106770. }
  106771. }
  106772. declare module BABYLON {
  106773. /**
  106774. * Creates a refraction texture used by refraction channel of the standard material.
  106775. * It is like a mirror but to see through a material.
  106776. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106777. */
  106778. export class RefractionTexture extends RenderTargetTexture {
  106779. /**
  106780. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  106781. * 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.
  106782. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106783. */
  106784. refractionPlane: Plane;
  106785. /**
  106786. * Define how deep under the surface we should see.
  106787. */
  106788. depth: number;
  106789. /**
  106790. * Creates a refraction texture used by refraction channel of the standard material.
  106791. * It is like a mirror but to see through a material.
  106792. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106793. * @param name Define the texture name
  106794. * @param size Define the size of the underlying texture
  106795. * @param scene Define the scene the refraction belongs to
  106796. * @param generateMipMaps Define if we need to generate mips level for the refraction
  106797. */
  106798. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  106799. /**
  106800. * Clone the refraction texture.
  106801. * @returns the cloned texture
  106802. */
  106803. clone(): RefractionTexture;
  106804. /**
  106805. * Serialize the texture to a JSON representation you could use in Parse later on
  106806. * @returns the serialized JSON representation
  106807. */
  106808. serialize(): any;
  106809. }
  106810. }
  106811. declare module BABYLON {
  106812. /**
  106813. * Configuration for Draco compression
  106814. */
  106815. export interface IDracoCompressionConfiguration {
  106816. /**
  106817. * Configuration for the decoder.
  106818. */
  106819. decoder?: {
  106820. /**
  106821. * The url to the WebAssembly module.
  106822. */
  106823. wasmUrl?: string;
  106824. /**
  106825. * The url to the WebAssembly binary.
  106826. */
  106827. wasmBinaryUrl?: string;
  106828. /**
  106829. * The url to the fallback JavaScript module.
  106830. */
  106831. fallbackUrl?: string;
  106832. };
  106833. }
  106834. /**
  106835. * Draco compression (https://google.github.io/draco/)
  106836. *
  106837. * This class wraps the Draco module.
  106838. *
  106839. * **Encoder**
  106840. *
  106841. * The encoder is not currently implemented.
  106842. *
  106843. * **Decoder**
  106844. *
  106845. * 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.
  106846. *
  106847. * To update the configuration, use the following code:
  106848. * ```javascript
  106849. * DracoCompression.Configuration = {
  106850. * decoder: {
  106851. * wasmUrl: "<url to the WebAssembly library>",
  106852. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  106853. * fallbackUrl: "<url to the fallback JavaScript library>",
  106854. * }
  106855. * };
  106856. * ```
  106857. *
  106858. * 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.
  106859. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  106860. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  106861. *
  106862. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  106863. * ```javascript
  106864. * var dracoCompression = new DracoCompression();
  106865. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  106866. * [VertexBuffer.PositionKind]: 0
  106867. * });
  106868. * ```
  106869. *
  106870. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  106871. */
  106872. export class DracoCompression implements IDisposable {
  106873. private static _DecoderModulePromise;
  106874. /**
  106875. * The configuration. Defaults to the following urls:
  106876. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  106877. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  106878. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  106879. */
  106880. static Configuration: IDracoCompressionConfiguration;
  106881. /**
  106882. * Returns true if the decoder is available.
  106883. */
  106884. static readonly DecoderAvailable: boolean;
  106885. /**
  106886. * Constructor
  106887. */
  106888. constructor();
  106889. /**
  106890. * Stop all async operations and release resources.
  106891. */
  106892. dispose(): void;
  106893. /**
  106894. * Decode Draco compressed mesh data to vertex data.
  106895. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  106896. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  106897. * @returns A promise that resolves with the decoded vertex data
  106898. */
  106899. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  106900. [kind: string]: number;
  106901. }): Promise<VertexData>;
  106902. private static _GetDecoderModule;
  106903. private static _LoadScriptAsync;
  106904. private static _LoadFileAsync;
  106905. }
  106906. }
  106907. declare module BABYLON {
  106908. /**
  106909. * Class for building Constructive Solid Geometry
  106910. */
  106911. export class CSG {
  106912. private polygons;
  106913. /**
  106914. * The world matrix
  106915. */
  106916. matrix: Matrix;
  106917. /**
  106918. * Stores the position
  106919. */
  106920. position: Vector3;
  106921. /**
  106922. * Stores the rotation
  106923. */
  106924. rotation: Vector3;
  106925. /**
  106926. * Stores the rotation quaternion
  106927. */
  106928. rotationQuaternion: Nullable<Quaternion>;
  106929. /**
  106930. * Stores the scaling vector
  106931. */
  106932. scaling: Vector3;
  106933. /**
  106934. * Convert the Mesh to CSG
  106935. * @param mesh The Mesh to convert to CSG
  106936. * @returns A new CSG from the Mesh
  106937. */
  106938. static FromMesh(mesh: Mesh): CSG;
  106939. /**
  106940. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  106941. * @param polygons Polygons used to construct a CSG solid
  106942. */
  106943. private static FromPolygons;
  106944. /**
  106945. * Clones, or makes a deep copy, of the CSG
  106946. * @returns A new CSG
  106947. */
  106948. clone(): CSG;
  106949. /**
  106950. * Unions this CSG with another CSG
  106951. * @param csg The CSG to union against this CSG
  106952. * @returns The unioned CSG
  106953. */
  106954. union(csg: CSG): CSG;
  106955. /**
  106956. * Unions this CSG with another CSG in place
  106957. * @param csg The CSG to union against this CSG
  106958. */
  106959. unionInPlace(csg: CSG): void;
  106960. /**
  106961. * Subtracts this CSG with another CSG
  106962. * @param csg The CSG to subtract against this CSG
  106963. * @returns A new CSG
  106964. */
  106965. subtract(csg: CSG): CSG;
  106966. /**
  106967. * Subtracts this CSG with another CSG in place
  106968. * @param csg The CSG to subtact against this CSG
  106969. */
  106970. subtractInPlace(csg: CSG): void;
  106971. /**
  106972. * Intersect this CSG with another CSG
  106973. * @param csg The CSG to intersect against this CSG
  106974. * @returns A new CSG
  106975. */
  106976. intersect(csg: CSG): CSG;
  106977. /**
  106978. * Intersects this CSG with another CSG in place
  106979. * @param csg The CSG to intersect against this CSG
  106980. */
  106981. intersectInPlace(csg: CSG): void;
  106982. /**
  106983. * Return a new CSG solid with solid and empty space switched. This solid is
  106984. * not modified.
  106985. * @returns A new CSG solid with solid and empty space switched
  106986. */
  106987. inverse(): CSG;
  106988. /**
  106989. * Inverses the CSG in place
  106990. */
  106991. inverseInPlace(): void;
  106992. /**
  106993. * This is used to keep meshes transformations so they can be restored
  106994. * when we build back a Babylon Mesh
  106995. * NB : All CSG operations are performed in world coordinates
  106996. * @param csg The CSG to copy the transform attributes from
  106997. * @returns This CSG
  106998. */
  106999. copyTransformAttributes(csg: CSG): CSG;
  107000. /**
  107001. * Build Raw mesh from CSG
  107002. * Coordinates here are in world space
  107003. * @param name The name of the mesh geometry
  107004. * @param scene The Scene
  107005. * @param keepSubMeshes Specifies if the submeshes should be kept
  107006. * @returns A new Mesh
  107007. */
  107008. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  107009. /**
  107010. * Build Mesh from CSG taking material and transforms into account
  107011. * @param name The name of the Mesh
  107012. * @param material The material of the Mesh
  107013. * @param scene The Scene
  107014. * @param keepSubMeshes Specifies if submeshes should be kept
  107015. * @returns The new Mesh
  107016. */
  107017. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  107018. }
  107019. }
  107020. declare module BABYLON {
  107021. /**
  107022. * Class used to create a trail following a mesh
  107023. */
  107024. export class TrailMesh extends Mesh {
  107025. private _generator;
  107026. private _autoStart;
  107027. private _running;
  107028. private _diameter;
  107029. private _length;
  107030. private _sectionPolygonPointsCount;
  107031. private _sectionVectors;
  107032. private _sectionNormalVectors;
  107033. private _beforeRenderObserver;
  107034. /**
  107035. * @constructor
  107036. * @param name The value used by scene.getMeshByName() to do a lookup.
  107037. * @param generator The mesh to generate a trail.
  107038. * @param scene The scene to add this mesh to.
  107039. * @param diameter Diameter of trailing mesh. Default is 1.
  107040. * @param length Length of trailing mesh. Default is 60.
  107041. * @param autoStart Automatically start trailing mesh. Default true.
  107042. */
  107043. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  107044. /**
  107045. * "TrailMesh"
  107046. * @returns "TrailMesh"
  107047. */
  107048. getClassName(): string;
  107049. private _createMesh;
  107050. /**
  107051. * Start trailing mesh.
  107052. */
  107053. start(): void;
  107054. /**
  107055. * Stop trailing mesh.
  107056. */
  107057. stop(): void;
  107058. /**
  107059. * Update trailing mesh geometry.
  107060. */
  107061. update(): void;
  107062. /**
  107063. * Returns a new TrailMesh object.
  107064. * @param name is a string, the name given to the new mesh
  107065. * @param newGenerator use new generator object for cloned trail mesh
  107066. * @returns a new mesh
  107067. */
  107068. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  107069. /**
  107070. * Serializes this trail mesh
  107071. * @param serializationObject object to write serialization to
  107072. */
  107073. serialize(serializationObject: any): void;
  107074. /**
  107075. * Parses a serialized trail mesh
  107076. * @param parsedMesh the serialized mesh
  107077. * @param scene the scene to create the trail mesh in
  107078. * @returns the created trail mesh
  107079. */
  107080. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  107081. }
  107082. }
  107083. declare module BABYLON {
  107084. /**
  107085. * Class containing static functions to help procedurally build meshes
  107086. */
  107087. export class RibbonBuilder {
  107088. /**
  107089. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107090. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107091. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107092. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107093. * * 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
  107094. * * 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
  107095. * * 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
  107096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107099. * * 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
  107100. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107101. * * 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
  107102. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107104. * @param name defines the name of the mesh
  107105. * @param options defines the options used to create the mesh
  107106. * @param scene defines the hosting scene
  107107. * @returns the ribbon mesh
  107108. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107109. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107110. */
  107111. static CreateRibbon(name: string, options: {
  107112. pathArray: Vector3[][];
  107113. closeArray?: boolean;
  107114. closePath?: boolean;
  107115. offset?: number;
  107116. updatable?: boolean;
  107117. sideOrientation?: number;
  107118. frontUVs?: Vector4;
  107119. backUVs?: Vector4;
  107120. instance?: Mesh;
  107121. invertUV?: boolean;
  107122. uvs?: Vector2[];
  107123. colors?: Color4[];
  107124. }, scene?: Nullable<Scene>): Mesh;
  107125. }
  107126. }
  107127. declare module BABYLON {
  107128. /**
  107129. * Class containing static functions to help procedurally build meshes
  107130. */
  107131. export class TorusKnotBuilder {
  107132. /**
  107133. * Creates a torus knot mesh
  107134. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107135. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107136. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107137. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107141. * @param name defines the name of the mesh
  107142. * @param options defines the options used to create the mesh
  107143. * @param scene defines the hosting scene
  107144. * @returns the torus knot mesh
  107145. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107146. */
  107147. static CreateTorusKnot(name: string, options: {
  107148. radius?: number;
  107149. tube?: number;
  107150. radialSegments?: number;
  107151. tubularSegments?: number;
  107152. p?: number;
  107153. q?: number;
  107154. updatable?: boolean;
  107155. sideOrientation?: number;
  107156. frontUVs?: Vector4;
  107157. backUVs?: Vector4;
  107158. }, scene: any): Mesh;
  107159. }
  107160. }
  107161. declare module BABYLON {
  107162. /**
  107163. * Polygon
  107164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107165. */
  107166. export class Polygon {
  107167. /**
  107168. * Creates a rectangle
  107169. * @param xmin bottom X coord
  107170. * @param ymin bottom Y coord
  107171. * @param xmax top X coord
  107172. * @param ymax top Y coord
  107173. * @returns points that make the resulting rectation
  107174. */
  107175. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  107176. /**
  107177. * Creates a circle
  107178. * @param radius radius of circle
  107179. * @param cx scale in x
  107180. * @param cy scale in y
  107181. * @param numberOfSides number of sides that make up the circle
  107182. * @returns points that make the resulting circle
  107183. */
  107184. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  107185. /**
  107186. * Creates a polygon from input string
  107187. * @param input Input polygon data
  107188. * @returns the parsed points
  107189. */
  107190. static Parse(input: string): Vector2[];
  107191. /**
  107192. * Starts building a polygon from x and y coordinates
  107193. * @param x x coordinate
  107194. * @param y y coordinate
  107195. * @returns the started path2
  107196. */
  107197. static StartingAt(x: number, y: number): Path2;
  107198. }
  107199. /**
  107200. * Builds a polygon
  107201. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  107202. */
  107203. export class PolygonMeshBuilder {
  107204. private _points;
  107205. private _outlinepoints;
  107206. private _holes;
  107207. private _name;
  107208. private _scene;
  107209. private _epoints;
  107210. private _eholes;
  107211. private _addToepoint;
  107212. /**
  107213. * Babylon reference to the earcut plugin.
  107214. */
  107215. bjsEarcut: any;
  107216. /**
  107217. * Creates a PolygonMeshBuilder
  107218. * @param name name of the builder
  107219. * @param contours Path of the polygon
  107220. * @param scene scene to add to when creating the mesh
  107221. * @param earcutInjection can be used to inject your own earcut reference
  107222. */
  107223. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  107224. /**
  107225. * Adds a whole within the polygon
  107226. * @param hole Array of points defining the hole
  107227. * @returns this
  107228. */
  107229. addHole(hole: Vector2[]): PolygonMeshBuilder;
  107230. /**
  107231. * Creates the polygon
  107232. * @param updatable If the mesh should be updatable
  107233. * @param depth The depth of the mesh created
  107234. * @returns the created mesh
  107235. */
  107236. build(updatable?: boolean, depth?: number): Mesh;
  107237. /**
  107238. * Creates the polygon
  107239. * @param depth The depth of the mesh created
  107240. * @returns the created VertexData
  107241. */
  107242. buildVertexData(depth?: number): VertexData;
  107243. /**
  107244. * Adds a side to the polygon
  107245. * @param positions points that make the polygon
  107246. * @param normals normals of the polygon
  107247. * @param uvs uvs of the polygon
  107248. * @param indices indices of the polygon
  107249. * @param bounds bounds of the polygon
  107250. * @param points points of the polygon
  107251. * @param depth depth of the polygon
  107252. * @param flip flip of the polygon
  107253. */
  107254. private addSide;
  107255. }
  107256. }
  107257. declare module BABYLON {
  107258. /**
  107259. * Class containing static functions to help procedurally build meshes
  107260. */
  107261. export class PolygonBuilder {
  107262. /**
  107263. * Creates a polygon mesh
  107264. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107265. * * 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
  107266. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107269. * * Remember you can only change the shape positions, not their number when updating a polygon
  107270. * @param name defines the name of the mesh
  107271. * @param options defines the options used to create the mesh
  107272. * @param scene defines the hosting scene
  107273. * @param earcutInjection can be used to inject your own earcut reference
  107274. * @returns the polygon mesh
  107275. */
  107276. static CreatePolygon(name: string, options: {
  107277. shape: Vector3[];
  107278. holes?: Vector3[][];
  107279. depth?: number;
  107280. faceUV?: Vector4[];
  107281. faceColors?: Color4[];
  107282. updatable?: boolean;
  107283. sideOrientation?: number;
  107284. frontUVs?: Vector4;
  107285. backUVs?: Vector4;
  107286. }, scene: Scene, earcutInjection?: any): Mesh;
  107287. /**
  107288. * Creates an extruded polygon mesh, with depth in the Y direction.
  107289. * * 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)
  107290. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107291. * @param name defines the name of the mesh
  107292. * @param options defines the options used to create the mesh
  107293. * @param scene defines the hosting scene
  107294. * @param earcutInjection can be used to inject your own earcut reference
  107295. * @returns the polygon mesh
  107296. */
  107297. static ExtrudePolygon(name: string, options: {
  107298. shape: Vector3[];
  107299. holes?: Vector3[][];
  107300. depth?: number;
  107301. faceUV?: Vector4[];
  107302. faceColors?: Color4[];
  107303. updatable?: boolean;
  107304. sideOrientation?: number;
  107305. frontUVs?: Vector4;
  107306. backUVs?: Vector4;
  107307. }, scene: Scene, earcutInjection?: any): Mesh;
  107308. }
  107309. }
  107310. declare module BABYLON {
  107311. /**
  107312. * Class containing static functions to help procedurally build meshes
  107313. */
  107314. export class ShapeBuilder {
  107315. /**
  107316. * 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.
  107317. * * 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.
  107318. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107319. * * 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.
  107320. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107321. * * 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
  107322. * * 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
  107323. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107326. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107328. * @param name defines the name of the mesh
  107329. * @param options defines the options used to create the mesh
  107330. * @param scene defines the hosting scene
  107331. * @returns the extruded shape mesh
  107332. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107334. */
  107335. static ExtrudeShape(name: string, options: {
  107336. shape: Vector3[];
  107337. path: Vector3[];
  107338. scale?: number;
  107339. rotation?: number;
  107340. cap?: number;
  107341. updatable?: boolean;
  107342. sideOrientation?: number;
  107343. frontUVs?: Vector4;
  107344. backUVs?: Vector4;
  107345. instance?: Mesh;
  107346. invertUV?: boolean;
  107347. }, scene?: Nullable<Scene>): Mesh;
  107348. /**
  107349. * Creates an custom extruded shape mesh.
  107350. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107351. * * 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.
  107352. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107353. * * 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
  107354. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107355. * * 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
  107356. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107357. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107358. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107359. * * 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
  107360. * * 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
  107361. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107366. * @param name defines the name of the mesh
  107367. * @param options defines the options used to create the mesh
  107368. * @param scene defines the hosting scene
  107369. * @returns the custom extruded shape mesh
  107370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107373. */
  107374. static ExtrudeShapeCustom(name: string, options: {
  107375. shape: Vector3[];
  107376. path: Vector3[];
  107377. scaleFunction?: any;
  107378. rotationFunction?: any;
  107379. ribbonCloseArray?: boolean;
  107380. ribbonClosePath?: boolean;
  107381. cap?: number;
  107382. updatable?: boolean;
  107383. sideOrientation?: number;
  107384. frontUVs?: Vector4;
  107385. backUVs?: Vector4;
  107386. instance?: Mesh;
  107387. invertUV?: boolean;
  107388. }, scene: Scene): Mesh;
  107389. private static _ExtrudeShapeGeneric;
  107390. }
  107391. }
  107392. declare module BABYLON {
  107393. /**
  107394. * Class containing static functions to help procedurally build meshes
  107395. */
  107396. export class LatheBuilder {
  107397. /**
  107398. * Creates lathe mesh.
  107399. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107400. * * 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
  107401. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107402. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107403. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107404. * * 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
  107405. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107406. * * 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
  107407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107411. * @param name defines the name of the mesh
  107412. * @param options defines the options used to create the mesh
  107413. * @param scene defines the hosting scene
  107414. * @returns the lathe mesh
  107415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107416. */
  107417. static CreateLathe(name: string, options: {
  107418. shape: Vector3[];
  107419. radius?: number;
  107420. tessellation?: number;
  107421. clip?: number;
  107422. arc?: number;
  107423. closed?: boolean;
  107424. updatable?: boolean;
  107425. sideOrientation?: number;
  107426. frontUVs?: Vector4;
  107427. backUVs?: Vector4;
  107428. cap?: number;
  107429. invertUV?: boolean;
  107430. }, scene: Scene): Mesh;
  107431. }
  107432. }
  107433. declare module BABYLON {
  107434. /**
  107435. * Class containing static functions to help procedurally build meshes
  107436. */
  107437. export class TubeBuilder {
  107438. /**
  107439. * Creates a tube mesh.
  107440. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107441. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107442. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107443. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107444. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107445. * * 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)
  107446. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107447. * * 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
  107448. * * 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
  107449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107453. * @param name defines the name of the mesh
  107454. * @param options defines the options used to create the mesh
  107455. * @param scene defines the hosting scene
  107456. * @returns the tube mesh
  107457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107458. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107459. */
  107460. static CreateTube(name: string, options: {
  107461. path: Vector3[];
  107462. radius?: number;
  107463. tessellation?: number;
  107464. radiusFunction?: {
  107465. (i: number, distance: number): number;
  107466. };
  107467. cap?: number;
  107468. arc?: number;
  107469. updatable?: boolean;
  107470. sideOrientation?: number;
  107471. frontUVs?: Vector4;
  107472. backUVs?: Vector4;
  107473. instance?: Mesh;
  107474. invertUV?: boolean;
  107475. }, scene: Scene): Mesh;
  107476. }
  107477. }
  107478. declare module BABYLON {
  107479. /**
  107480. * Class containing static functions to help procedurally build meshes
  107481. */
  107482. export class IcoSphereBuilder {
  107483. /**
  107484. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107485. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107486. * * 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`)
  107487. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107488. * * 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
  107489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107492. * @param name defines the name of the mesh
  107493. * @param options defines the options used to create the mesh
  107494. * @param scene defines the hosting scene
  107495. * @returns the icosahedron mesh
  107496. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107497. */
  107498. static CreateIcoSphere(name: string, options: {
  107499. radius?: number;
  107500. radiusX?: number;
  107501. radiusY?: number;
  107502. radiusZ?: number;
  107503. flat?: boolean;
  107504. subdivisions?: number;
  107505. sideOrientation?: number;
  107506. frontUVs?: Vector4;
  107507. backUVs?: Vector4;
  107508. updatable?: boolean;
  107509. }, scene: Scene): Mesh;
  107510. }
  107511. }
  107512. declare module BABYLON {
  107513. /**
  107514. * Class containing static functions to help procedurally build meshes
  107515. */
  107516. export class DecalBuilder {
  107517. /**
  107518. * Creates a decal mesh.
  107519. * 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
  107520. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107521. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107522. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107523. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107524. * @param name defines the name of the mesh
  107525. * @param sourceMesh defines the mesh where the decal must be applied
  107526. * @param options defines the options used to create the mesh
  107527. * @param scene defines the hosting scene
  107528. * @returns the decal mesh
  107529. * @see https://doc.babylonjs.com/how_to/decals
  107530. */
  107531. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107532. position?: Vector3;
  107533. normal?: Vector3;
  107534. size?: Vector3;
  107535. angle?: number;
  107536. }): Mesh;
  107537. }
  107538. }
  107539. declare module BABYLON {
  107540. /**
  107541. * Class containing static functions to help procedurally build meshes
  107542. */
  107543. export class MeshBuilder {
  107544. /**
  107545. * Creates a box mesh
  107546. * * The parameter `size` sets the size (float) of each box side (default 1)
  107547. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107548. * * 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)
  107549. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107553. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107554. * @param name defines the name of the mesh
  107555. * @param options defines the options used to create the mesh
  107556. * @param scene defines the hosting scene
  107557. * @returns the box mesh
  107558. */
  107559. static CreateBox(name: string, options: {
  107560. size?: number;
  107561. width?: number;
  107562. height?: number;
  107563. depth?: number;
  107564. faceUV?: Vector4[];
  107565. faceColors?: Color4[];
  107566. sideOrientation?: number;
  107567. frontUVs?: Vector4;
  107568. backUVs?: Vector4;
  107569. updatable?: boolean;
  107570. }, scene?: Nullable<Scene>): Mesh;
  107571. /**
  107572. * Creates a sphere mesh
  107573. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107574. * * 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`)
  107575. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107576. * * 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
  107577. * * 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)
  107578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107581. * @param name defines the name of the mesh
  107582. * @param options defines the options used to create the mesh
  107583. * @param scene defines the hosting scene
  107584. * @returns the sphere mesh
  107585. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107586. */
  107587. static CreateSphere(name: string, options: {
  107588. segments?: number;
  107589. diameter?: number;
  107590. diameterX?: number;
  107591. diameterY?: number;
  107592. diameterZ?: number;
  107593. arc?: number;
  107594. slice?: number;
  107595. sideOrientation?: number;
  107596. frontUVs?: Vector4;
  107597. backUVs?: Vector4;
  107598. updatable?: boolean;
  107599. }, scene: any): Mesh;
  107600. /**
  107601. * Creates a plane polygonal mesh. By default, this is a disc
  107602. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107603. * * 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
  107604. * * 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
  107605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107608. * @param name defines the name of the mesh
  107609. * @param options defines the options used to create the mesh
  107610. * @param scene defines the hosting scene
  107611. * @returns the plane polygonal mesh
  107612. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107613. */
  107614. static CreateDisc(name: string, options: {
  107615. radius?: number;
  107616. tessellation?: number;
  107617. arc?: number;
  107618. updatable?: boolean;
  107619. sideOrientation?: number;
  107620. frontUVs?: Vector4;
  107621. backUVs?: Vector4;
  107622. }, scene?: Nullable<Scene>): Mesh;
  107623. /**
  107624. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107625. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107626. * * 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`)
  107627. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107628. * * 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
  107629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107632. * @param name defines the name of the mesh
  107633. * @param options defines the options used to create the mesh
  107634. * @param scene defines the hosting scene
  107635. * @returns the icosahedron mesh
  107636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107637. */
  107638. static CreateIcoSphere(name: string, options: {
  107639. radius?: number;
  107640. radiusX?: number;
  107641. radiusY?: number;
  107642. radiusZ?: number;
  107643. flat?: boolean;
  107644. subdivisions?: number;
  107645. sideOrientation?: number;
  107646. frontUVs?: Vector4;
  107647. backUVs?: Vector4;
  107648. updatable?: boolean;
  107649. }, scene: Scene): Mesh;
  107650. /**
  107651. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107652. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107653. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107654. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107655. * * 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
  107656. * * 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
  107657. * * 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
  107658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107661. * * 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
  107662. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107663. * * 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
  107664. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107666. * @param name defines the name of the mesh
  107667. * @param options defines the options used to create the mesh
  107668. * @param scene defines the hosting scene
  107669. * @returns the ribbon mesh
  107670. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107672. */
  107673. static CreateRibbon(name: string, options: {
  107674. pathArray: Vector3[][];
  107675. closeArray?: boolean;
  107676. closePath?: boolean;
  107677. offset?: number;
  107678. updatable?: boolean;
  107679. sideOrientation?: number;
  107680. frontUVs?: Vector4;
  107681. backUVs?: Vector4;
  107682. instance?: Mesh;
  107683. invertUV?: boolean;
  107684. uvs?: Vector2[];
  107685. colors?: Color4[];
  107686. }, scene?: Nullable<Scene>): Mesh;
  107687. /**
  107688. * Creates a cylinder or a cone mesh
  107689. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107690. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107691. * * 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.
  107692. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107693. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107694. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107695. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107696. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107697. * * 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).
  107698. * * 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
  107699. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107700. * * 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
  107701. * * 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.
  107702. * * If `enclose` is false, a ring surface is one element.
  107703. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107704. * * 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
  107705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107708. * @param name defines the name of the mesh
  107709. * @param options defines the options used to create the mesh
  107710. * @param scene defines the hosting scene
  107711. * @returns the cylinder mesh
  107712. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107713. */
  107714. static CreateCylinder(name: string, options: {
  107715. height?: number;
  107716. diameterTop?: number;
  107717. diameterBottom?: number;
  107718. diameter?: number;
  107719. tessellation?: number;
  107720. subdivisions?: number;
  107721. arc?: number;
  107722. faceColors?: Color4[];
  107723. faceUV?: Vector4[];
  107724. updatable?: boolean;
  107725. hasRings?: boolean;
  107726. enclose?: boolean;
  107727. sideOrientation?: number;
  107728. frontUVs?: Vector4;
  107729. backUVs?: Vector4;
  107730. }, scene: any): Mesh;
  107731. /**
  107732. * Creates a torus mesh
  107733. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107734. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107735. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107739. * @param name defines the name of the mesh
  107740. * @param options defines the options used to create the mesh
  107741. * @param scene defines the hosting scene
  107742. * @returns the torus mesh
  107743. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107744. */
  107745. static CreateTorus(name: string, options: {
  107746. diameter?: number;
  107747. thickness?: number;
  107748. tessellation?: number;
  107749. updatable?: boolean;
  107750. sideOrientation?: number;
  107751. frontUVs?: Vector4;
  107752. backUVs?: Vector4;
  107753. }, scene: any): Mesh;
  107754. /**
  107755. * Creates a torus knot mesh
  107756. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107757. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107758. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107759. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107763. * @param name defines the name of the mesh
  107764. * @param options defines the options used to create the mesh
  107765. * @param scene defines the hosting scene
  107766. * @returns the torus knot mesh
  107767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107768. */
  107769. static CreateTorusKnot(name: string, options: {
  107770. radius?: number;
  107771. tube?: number;
  107772. radialSegments?: number;
  107773. tubularSegments?: number;
  107774. p?: number;
  107775. q?: number;
  107776. updatable?: boolean;
  107777. sideOrientation?: number;
  107778. frontUVs?: Vector4;
  107779. backUVs?: Vector4;
  107780. }, scene: any): Mesh;
  107781. /**
  107782. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107783. * * 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
  107784. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107785. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107786. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107787. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107788. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107789. * * 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
  107790. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107793. * @param name defines the name of the new line system
  107794. * @param options defines the options used to create the line system
  107795. * @param scene defines the hosting scene
  107796. * @returns a new line system mesh
  107797. */
  107798. static CreateLineSystem(name: string, options: {
  107799. lines: Vector3[][];
  107800. updatable?: boolean;
  107801. instance?: Nullable<LinesMesh>;
  107802. colors?: Nullable<Color4[][]>;
  107803. useVertexAlpha?: boolean;
  107804. }, scene: Nullable<Scene>): LinesMesh;
  107805. /**
  107806. * Creates a line mesh
  107807. * 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
  107808. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107809. * * The parameter `points` is an array successive Vector3
  107810. * * 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
  107811. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107812. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107813. * * When updating an instance, remember that only point positions can change, not the number of points
  107814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107816. * @param name defines the name of the new line system
  107817. * @param options defines the options used to create the line system
  107818. * @param scene defines the hosting scene
  107819. * @returns a new line mesh
  107820. */
  107821. static CreateLines(name: string, options: {
  107822. points: Vector3[];
  107823. updatable?: boolean;
  107824. instance?: Nullable<LinesMesh>;
  107825. colors?: Color4[];
  107826. useVertexAlpha?: boolean;
  107827. }, scene?: Nullable<Scene>): LinesMesh;
  107828. /**
  107829. * Creates a dashed line mesh
  107830. * * 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
  107831. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107832. * * The parameter `points` is an array successive Vector3
  107833. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107834. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107835. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107836. * * 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
  107837. * * When updating an instance, remember that only point positions can change, not the number of points
  107838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107839. * @param name defines the name of the mesh
  107840. * @param options defines the options used to create the mesh
  107841. * @param scene defines the hosting scene
  107842. * @returns the dashed line mesh
  107843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107844. */
  107845. static CreateDashedLines(name: string, options: {
  107846. points: Vector3[];
  107847. dashSize?: number;
  107848. gapSize?: number;
  107849. dashNb?: number;
  107850. updatable?: boolean;
  107851. instance?: LinesMesh;
  107852. }, scene?: Nullable<Scene>): LinesMesh;
  107853. /**
  107854. * 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.
  107855. * * 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.
  107856. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107857. * * 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.
  107858. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107859. * * 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
  107860. * * 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
  107861. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107866. * @param name defines the name of the mesh
  107867. * @param options defines the options used to create the mesh
  107868. * @param scene defines the hosting scene
  107869. * @returns the extruded shape mesh
  107870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107872. */
  107873. static ExtrudeShape(name: string, options: {
  107874. shape: Vector3[];
  107875. path: Vector3[];
  107876. scale?: number;
  107877. rotation?: number;
  107878. cap?: number;
  107879. updatable?: boolean;
  107880. sideOrientation?: number;
  107881. frontUVs?: Vector4;
  107882. backUVs?: Vector4;
  107883. instance?: Mesh;
  107884. invertUV?: boolean;
  107885. }, scene?: Nullable<Scene>): Mesh;
  107886. /**
  107887. * Creates an custom extruded shape mesh.
  107888. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107889. * * 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.
  107890. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107891. * * 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
  107892. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107893. * * 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
  107894. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107895. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107896. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107897. * * 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
  107898. * * 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
  107899. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107902. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107904. * @param name defines the name of the mesh
  107905. * @param options defines the options used to create the mesh
  107906. * @param scene defines the hosting scene
  107907. * @returns the custom extruded shape mesh
  107908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107911. */
  107912. static ExtrudeShapeCustom(name: string, options: {
  107913. shape: Vector3[];
  107914. path: Vector3[];
  107915. scaleFunction?: any;
  107916. rotationFunction?: any;
  107917. ribbonCloseArray?: boolean;
  107918. ribbonClosePath?: boolean;
  107919. cap?: number;
  107920. updatable?: boolean;
  107921. sideOrientation?: number;
  107922. frontUVs?: Vector4;
  107923. backUVs?: Vector4;
  107924. instance?: Mesh;
  107925. invertUV?: boolean;
  107926. }, scene: Scene): Mesh;
  107927. /**
  107928. * Creates lathe mesh.
  107929. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107930. * * 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
  107931. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107932. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107933. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107934. * * 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
  107935. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107936. * * 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
  107937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107939. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107941. * @param name defines the name of the mesh
  107942. * @param options defines the options used to create the mesh
  107943. * @param scene defines the hosting scene
  107944. * @returns the lathe mesh
  107945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107946. */
  107947. static CreateLathe(name: string, options: {
  107948. shape: Vector3[];
  107949. radius?: number;
  107950. tessellation?: number;
  107951. clip?: number;
  107952. arc?: number;
  107953. closed?: boolean;
  107954. updatable?: boolean;
  107955. sideOrientation?: number;
  107956. frontUVs?: Vector4;
  107957. backUVs?: Vector4;
  107958. cap?: number;
  107959. invertUV?: boolean;
  107960. }, scene: Scene): Mesh;
  107961. /**
  107962. * Creates a plane mesh
  107963. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107964. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107965. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107969. * @param name defines the name of the mesh
  107970. * @param options defines the options used to create the mesh
  107971. * @param scene defines the hosting scene
  107972. * @returns the plane mesh
  107973. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107974. */
  107975. static CreatePlane(name: string, options: {
  107976. size?: number;
  107977. width?: number;
  107978. height?: number;
  107979. sideOrientation?: number;
  107980. frontUVs?: Vector4;
  107981. backUVs?: Vector4;
  107982. updatable?: boolean;
  107983. sourcePlane?: Plane;
  107984. }, scene: Scene): Mesh;
  107985. /**
  107986. * Creates a ground mesh
  107987. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107988. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107990. * @param name defines the name of the mesh
  107991. * @param options defines the options used to create the mesh
  107992. * @param scene defines the hosting scene
  107993. * @returns the ground mesh
  107994. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107995. */
  107996. static CreateGround(name: string, options: {
  107997. width?: number;
  107998. height?: number;
  107999. subdivisions?: number;
  108000. subdivisionsX?: number;
  108001. subdivisionsY?: number;
  108002. updatable?: boolean;
  108003. }, scene: any): Mesh;
  108004. /**
  108005. * Creates a tiled ground mesh
  108006. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108007. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108008. * * 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
  108009. * * 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
  108010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108011. * @param name defines the name of the mesh
  108012. * @param options defines the options used to create the mesh
  108013. * @param scene defines the hosting scene
  108014. * @returns the tiled ground mesh
  108015. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108016. */
  108017. static CreateTiledGround(name: string, options: {
  108018. xmin: number;
  108019. zmin: number;
  108020. xmax: number;
  108021. zmax: number;
  108022. subdivisions?: {
  108023. w: number;
  108024. h: number;
  108025. };
  108026. precision?: {
  108027. w: number;
  108028. h: number;
  108029. };
  108030. updatable?: boolean;
  108031. }, scene: Scene): Mesh;
  108032. /**
  108033. * Creates a ground mesh from a height map
  108034. * * The parameter `url` sets the URL of the height map image resource.
  108035. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108036. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108037. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108038. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108039. * * 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.
  108040. * * 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).
  108041. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108043. * @param name defines the name of the mesh
  108044. * @param url defines the url to the height map
  108045. * @param options defines the options used to create the mesh
  108046. * @param scene defines the hosting scene
  108047. * @returns the ground mesh
  108048. * @see https://doc.babylonjs.com/babylon101/height_map
  108049. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108050. */
  108051. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108052. width?: number;
  108053. height?: number;
  108054. subdivisions?: number;
  108055. minHeight?: number;
  108056. maxHeight?: number;
  108057. colorFilter?: Color3;
  108058. alphaFilter?: number;
  108059. updatable?: boolean;
  108060. onReady?: (mesh: GroundMesh) => void;
  108061. }, scene: Scene): GroundMesh;
  108062. /**
  108063. * Creates a polygon mesh
  108064. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  108065. * * 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
  108066. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  108069. * * Remember you can only change the shape positions, not their number when updating a polygon
  108070. * @param name defines the name of the mesh
  108071. * @param options defines the options used to create the mesh
  108072. * @param scene defines the hosting scene
  108073. * @param earcutInjection can be used to inject your own earcut reference
  108074. * @returns the polygon mesh
  108075. */
  108076. static CreatePolygon(name: string, options: {
  108077. shape: Vector3[];
  108078. holes?: Vector3[][];
  108079. depth?: number;
  108080. faceUV?: Vector4[];
  108081. faceColors?: Color4[];
  108082. updatable?: boolean;
  108083. sideOrientation?: number;
  108084. frontUVs?: Vector4;
  108085. backUVs?: Vector4;
  108086. }, scene: Scene, earcutInjection?: any): Mesh;
  108087. /**
  108088. * Creates an extruded polygon mesh, with depth in the Y direction.
  108089. * * 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)
  108090. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108091. * @param name defines the name of the mesh
  108092. * @param options defines the options used to create the mesh
  108093. * @param scene defines the hosting scene
  108094. * @param earcutInjection can be used to inject your own earcut reference
  108095. * @returns the polygon mesh
  108096. */
  108097. static ExtrudePolygon(name: string, options: {
  108098. shape: Vector3[];
  108099. holes?: Vector3[][];
  108100. depth?: number;
  108101. faceUV?: Vector4[];
  108102. faceColors?: Color4[];
  108103. updatable?: boolean;
  108104. sideOrientation?: number;
  108105. frontUVs?: Vector4;
  108106. backUVs?: Vector4;
  108107. }, scene: Scene, earcutInjection?: any): Mesh;
  108108. /**
  108109. * Creates a tube mesh.
  108110. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108111. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  108112. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  108113. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  108114. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  108115. * * 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)
  108116. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  108117. * * 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
  108118. * * 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
  108119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108121. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108123. * @param name defines the name of the mesh
  108124. * @param options defines the options used to create the mesh
  108125. * @param scene defines the hosting scene
  108126. * @returns the tube mesh
  108127. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108128. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  108129. */
  108130. static CreateTube(name: string, options: {
  108131. path: Vector3[];
  108132. radius?: number;
  108133. tessellation?: number;
  108134. radiusFunction?: {
  108135. (i: number, distance: number): number;
  108136. };
  108137. cap?: number;
  108138. arc?: number;
  108139. updatable?: boolean;
  108140. sideOrientation?: number;
  108141. frontUVs?: Vector4;
  108142. backUVs?: Vector4;
  108143. instance?: Mesh;
  108144. invertUV?: boolean;
  108145. }, scene: Scene): Mesh;
  108146. /**
  108147. * Creates a polyhedron mesh
  108148. * * 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
  108149. * * The parameter `size` (positive float, default 1) sets the polygon size
  108150. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108151. * * 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`
  108152. * * 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
  108153. * * 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)`)
  108154. * * 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
  108155. * * 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
  108156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108159. * @param name defines the name of the mesh
  108160. * @param options defines the options used to create the mesh
  108161. * @param scene defines the hosting scene
  108162. * @returns the polyhedron mesh
  108163. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108164. */
  108165. static CreatePolyhedron(name: string, options: {
  108166. type?: number;
  108167. size?: number;
  108168. sizeX?: number;
  108169. sizeY?: number;
  108170. sizeZ?: number;
  108171. custom?: any;
  108172. faceUV?: Vector4[];
  108173. faceColors?: Color4[];
  108174. flat?: boolean;
  108175. updatable?: boolean;
  108176. sideOrientation?: number;
  108177. frontUVs?: Vector4;
  108178. backUVs?: Vector4;
  108179. }, scene: Scene): Mesh;
  108180. /**
  108181. * Creates a decal mesh.
  108182. * 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
  108183. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  108184. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  108185. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  108186. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  108187. * @param name defines the name of the mesh
  108188. * @param sourceMesh defines the mesh where the decal must be applied
  108189. * @param options defines the options used to create the mesh
  108190. * @param scene defines the hosting scene
  108191. * @returns the decal mesh
  108192. * @see https://doc.babylonjs.com/how_to/decals
  108193. */
  108194. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  108195. position?: Vector3;
  108196. normal?: Vector3;
  108197. size?: Vector3;
  108198. angle?: number;
  108199. }): Mesh;
  108200. }
  108201. }
  108202. declare module BABYLON {
  108203. /**
  108204. * A simplifier interface for future simplification implementations
  108205. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108206. */
  108207. export interface ISimplifier {
  108208. /**
  108209. * Simplification of a given mesh according to the given settings.
  108210. * Since this requires computation, it is assumed that the function runs async.
  108211. * @param settings The settings of the simplification, including quality and distance
  108212. * @param successCallback A callback that will be called after the mesh was simplified.
  108213. * @param errorCallback in case of an error, this callback will be called. optional.
  108214. */
  108215. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  108216. }
  108217. /**
  108218. * Expected simplification settings.
  108219. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  108220. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108221. */
  108222. export interface ISimplificationSettings {
  108223. /**
  108224. * Gets or sets the expected quality
  108225. */
  108226. quality: number;
  108227. /**
  108228. * Gets or sets the distance when this optimized version should be used
  108229. */
  108230. distance: number;
  108231. /**
  108232. * Gets an already optimized mesh
  108233. */
  108234. optimizeMesh?: boolean;
  108235. }
  108236. /**
  108237. * Class used to specify simplification options
  108238. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108239. */
  108240. export class SimplificationSettings implements ISimplificationSettings {
  108241. /** expected quality */
  108242. quality: number;
  108243. /** distance when this optimized version should be used */
  108244. distance: number;
  108245. /** already optimized mesh */
  108246. optimizeMesh?: boolean | undefined;
  108247. /**
  108248. * Creates a SimplificationSettings
  108249. * @param quality expected quality
  108250. * @param distance distance when this optimized version should be used
  108251. * @param optimizeMesh already optimized mesh
  108252. */
  108253. constructor(
  108254. /** expected quality */
  108255. quality: number,
  108256. /** distance when this optimized version should be used */
  108257. distance: number,
  108258. /** already optimized mesh */
  108259. optimizeMesh?: boolean | undefined);
  108260. }
  108261. /**
  108262. * Interface used to define a simplification task
  108263. */
  108264. export interface ISimplificationTask {
  108265. /**
  108266. * Array of settings
  108267. */
  108268. settings: Array<ISimplificationSettings>;
  108269. /**
  108270. * Simplification type
  108271. */
  108272. simplificationType: SimplificationType;
  108273. /**
  108274. * Mesh to simplify
  108275. */
  108276. mesh: Mesh;
  108277. /**
  108278. * Callback called on success
  108279. */
  108280. successCallback?: () => void;
  108281. /**
  108282. * Defines if parallel processing can be used
  108283. */
  108284. parallelProcessing: boolean;
  108285. }
  108286. /**
  108287. * Queue used to order the simplification tasks
  108288. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108289. */
  108290. export class SimplificationQueue {
  108291. private _simplificationArray;
  108292. /**
  108293. * Gets a boolean indicating that the process is still running
  108294. */
  108295. running: boolean;
  108296. /**
  108297. * Creates a new queue
  108298. */
  108299. constructor();
  108300. /**
  108301. * Adds a new simplification task
  108302. * @param task defines a task to add
  108303. */
  108304. addTask(task: ISimplificationTask): void;
  108305. /**
  108306. * Execute next task
  108307. */
  108308. executeNext(): void;
  108309. /**
  108310. * Execute a simplification task
  108311. * @param task defines the task to run
  108312. */
  108313. runSimplification(task: ISimplificationTask): void;
  108314. private getSimplifier;
  108315. }
  108316. /**
  108317. * The implemented types of simplification
  108318. * At the moment only Quadratic Error Decimation is implemented
  108319. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108320. */
  108321. export enum SimplificationType {
  108322. /** Quadratic error decimation */
  108323. QUADRATIC = 0
  108324. }
  108325. }
  108326. declare module BABYLON {
  108327. interface Scene {
  108328. /** @hidden (Backing field) */
  108329. _simplificationQueue: SimplificationQueue;
  108330. /**
  108331. * Gets or sets the simplification queue attached to the scene
  108332. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108333. */
  108334. simplificationQueue: SimplificationQueue;
  108335. }
  108336. interface Mesh {
  108337. /**
  108338. * Simplify the mesh according to the given array of settings.
  108339. * Function will return immediately and will simplify async
  108340. * @param settings a collection of simplification settings
  108341. * @param parallelProcessing should all levels calculate parallel or one after the other
  108342. * @param simplificationType the type of simplification to run
  108343. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  108344. * @returns the current mesh
  108345. */
  108346. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  108347. }
  108348. /**
  108349. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  108350. * created in a scene
  108351. */
  108352. export class SimplicationQueueSceneComponent implements ISceneComponent {
  108353. /**
  108354. * The component name helpfull to identify the component in the list of scene components.
  108355. */
  108356. readonly name: string;
  108357. /**
  108358. * The scene the component belongs to.
  108359. */
  108360. scene: Scene;
  108361. /**
  108362. * Creates a new instance of the component for the given scene
  108363. * @param scene Defines the scene to register the component in
  108364. */
  108365. constructor(scene: Scene);
  108366. /**
  108367. * Registers the component in a given scene
  108368. */
  108369. register(): void;
  108370. /**
  108371. * Rebuilds the elements related to this component in case of
  108372. * context lost for instance.
  108373. */
  108374. rebuild(): void;
  108375. /**
  108376. * Disposes the component and the associated ressources
  108377. */
  108378. dispose(): void;
  108379. private _beforeCameraUpdate;
  108380. }
  108381. }
  108382. declare module BABYLON {
  108383. /**
  108384. * Class used to enable access to IndexedDB
  108385. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108386. */
  108387. export class Database implements IOfflineProvider {
  108388. private _callbackManifestChecked;
  108389. private _currentSceneUrl;
  108390. private _db;
  108391. private _enableSceneOffline;
  108392. private _enableTexturesOffline;
  108393. private _manifestVersionFound;
  108394. private _mustUpdateRessources;
  108395. private _hasReachedQuota;
  108396. private _isSupported;
  108397. private _idbFactory;
  108398. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  108399. private static IsUASupportingBlobStorage;
  108400. /**
  108401. * Gets a boolean indicating if Database storate is enabled (off by default)
  108402. */
  108403. static IDBStorageEnabled: boolean;
  108404. /**
  108405. * Gets a boolean indicating if scene must be saved in the database
  108406. */
  108407. readonly enableSceneOffline: boolean;
  108408. /**
  108409. * Gets a boolean indicating if textures must be saved in the database
  108410. */
  108411. readonly enableTexturesOffline: boolean;
  108412. /**
  108413. * Creates a new Database
  108414. * @param urlToScene defines the url to load the scene
  108415. * @param callbackManifestChecked defines the callback to use when manifest is checked
  108416. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  108417. */
  108418. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  108419. private static _ParseURL;
  108420. private static _ReturnFullUrlLocation;
  108421. private _checkManifestFile;
  108422. /**
  108423. * Open the database and make it available
  108424. * @param successCallback defines the callback to call on success
  108425. * @param errorCallback defines the callback to call on error
  108426. */
  108427. open(successCallback: () => void, errorCallback: () => void): void;
  108428. /**
  108429. * Loads an image from the database
  108430. * @param url defines the url to load from
  108431. * @param image defines the target DOM image
  108432. */
  108433. loadImage(url: string, image: HTMLImageElement): void;
  108434. private _loadImageFromDBAsync;
  108435. private _saveImageIntoDBAsync;
  108436. private _checkVersionFromDB;
  108437. private _loadVersionFromDBAsync;
  108438. private _saveVersionIntoDBAsync;
  108439. /**
  108440. * Loads a file from database
  108441. * @param url defines the URL to load from
  108442. * @param sceneLoaded defines a callback to call on success
  108443. * @param progressCallBack defines a callback to call when progress changed
  108444. * @param errorCallback defines a callback to call on error
  108445. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  108446. */
  108447. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  108448. private _loadFileAsync;
  108449. private _saveFileAsync;
  108450. /**
  108451. * Validates if xhr data is correct
  108452. * @param xhr defines the request to validate
  108453. * @param dataType defines the expected data type
  108454. * @returns true if data is correct
  108455. */
  108456. private static _ValidateXHRData;
  108457. }
  108458. }
  108459. declare module BABYLON {
  108460. /** @hidden */
  108461. export var gpuUpdateParticlesPixelShader: {
  108462. name: string;
  108463. shader: string;
  108464. };
  108465. }
  108466. declare module BABYLON {
  108467. /** @hidden */
  108468. export var gpuUpdateParticlesVertexShader: {
  108469. name: string;
  108470. shader: string;
  108471. };
  108472. }
  108473. declare module BABYLON {
  108474. /** @hidden */
  108475. export var clipPlaneFragmentDeclaration2: {
  108476. name: string;
  108477. shader: string;
  108478. };
  108479. }
  108480. declare module BABYLON {
  108481. /** @hidden */
  108482. export var gpuRenderParticlesPixelShader: {
  108483. name: string;
  108484. shader: string;
  108485. };
  108486. }
  108487. declare module BABYLON {
  108488. /** @hidden */
  108489. export var clipPlaneVertexDeclaration2: {
  108490. name: string;
  108491. shader: string;
  108492. };
  108493. }
  108494. declare module BABYLON {
  108495. /** @hidden */
  108496. export var gpuRenderParticlesVertexShader: {
  108497. name: string;
  108498. shader: string;
  108499. };
  108500. }
  108501. declare module BABYLON {
  108502. /**
  108503. * This represents a GPU particle system in Babylon
  108504. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108505. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108506. */
  108507. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  108508. /**
  108509. * The layer mask we are rendering the particles through.
  108510. */
  108511. layerMask: number;
  108512. private _capacity;
  108513. private _activeCount;
  108514. private _currentActiveCount;
  108515. private _accumulatedCount;
  108516. private _renderEffect;
  108517. private _updateEffect;
  108518. private _buffer0;
  108519. private _buffer1;
  108520. private _spriteBuffer;
  108521. private _updateVAO;
  108522. private _renderVAO;
  108523. private _targetIndex;
  108524. private _sourceBuffer;
  108525. private _targetBuffer;
  108526. private _engine;
  108527. private _currentRenderId;
  108528. private _started;
  108529. private _stopped;
  108530. private _timeDelta;
  108531. private _randomTexture;
  108532. private _randomTexture2;
  108533. private _attributesStrideSize;
  108534. private _updateEffectOptions;
  108535. private _randomTextureSize;
  108536. private _actualFrame;
  108537. private readonly _rawTextureWidth;
  108538. /**
  108539. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108540. */
  108541. static readonly IsSupported: boolean;
  108542. /**
  108543. * An event triggered when the system is disposed.
  108544. */
  108545. onDisposeObservable: Observable<GPUParticleSystem>;
  108546. /**
  108547. * Gets the maximum number of particles active at the same time.
  108548. * @returns The max number of active particles.
  108549. */
  108550. getCapacity(): number;
  108551. /**
  108552. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108553. * to override the particles.
  108554. */
  108555. forceDepthWrite: boolean;
  108556. /**
  108557. * Gets or set the number of active particles
  108558. */
  108559. activeParticleCount: number;
  108560. private _preWarmDone;
  108561. /**
  108562. * Is this system ready to be used/rendered
  108563. * @return true if the system is ready
  108564. */
  108565. isReady(): boolean;
  108566. /**
  108567. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108568. * @returns True if it has been started, otherwise false.
  108569. */
  108570. isStarted(): boolean;
  108571. /**
  108572. * Starts the particle system and begins to emit
  108573. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108574. */
  108575. start(delay?: number): void;
  108576. /**
  108577. * Stops the particle system.
  108578. */
  108579. stop(): void;
  108580. /**
  108581. * Remove all active particles
  108582. */
  108583. reset(): void;
  108584. /**
  108585. * Returns the string "GPUParticleSystem"
  108586. * @returns a string containing the class name
  108587. */
  108588. getClassName(): string;
  108589. private _colorGradientsTexture;
  108590. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  108591. /**
  108592. * Adds a new color gradient
  108593. * @param gradient defines the gradient to use (between 0 and 1)
  108594. * @param color1 defines the color to affect to the specified gradient
  108595. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108596. * @returns the current particle system
  108597. */
  108598. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  108599. /**
  108600. * Remove a specific color gradient
  108601. * @param gradient defines the gradient to remove
  108602. * @returns the current particle system
  108603. */
  108604. removeColorGradient(gradient: number): GPUParticleSystem;
  108605. private _angularSpeedGradientsTexture;
  108606. private _sizeGradientsTexture;
  108607. private _velocityGradientsTexture;
  108608. private _limitVelocityGradientsTexture;
  108609. private _dragGradientsTexture;
  108610. private _addFactorGradient;
  108611. /**
  108612. * Adds a new size gradient
  108613. * @param gradient defines the gradient to use (between 0 and 1)
  108614. * @param factor defines the size factor to affect to the specified gradient
  108615. * @returns the current particle system
  108616. */
  108617. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  108618. /**
  108619. * Remove a specific size gradient
  108620. * @param gradient defines the gradient to remove
  108621. * @returns the current particle system
  108622. */
  108623. removeSizeGradient(gradient: number): GPUParticleSystem;
  108624. /**
  108625. * Adds a new angular speed gradient
  108626. * @param gradient defines the gradient to use (between 0 and 1)
  108627. * @param factor defines the angular speed to affect to the specified gradient
  108628. * @returns the current particle system
  108629. */
  108630. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  108631. /**
  108632. * Remove a specific angular speed gradient
  108633. * @param gradient defines the gradient to remove
  108634. * @returns the current particle system
  108635. */
  108636. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  108637. /**
  108638. * Adds a new velocity gradient
  108639. * @param gradient defines the gradient to use (between 0 and 1)
  108640. * @param factor defines the velocity to affect to the specified gradient
  108641. * @returns the current particle system
  108642. */
  108643. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108644. /**
  108645. * Remove a specific velocity gradient
  108646. * @param gradient defines the gradient to remove
  108647. * @returns the current particle system
  108648. */
  108649. removeVelocityGradient(gradient: number): GPUParticleSystem;
  108650. /**
  108651. * Adds a new limit velocity gradient
  108652. * @param gradient defines the gradient to use (between 0 and 1)
  108653. * @param factor defines the limit velocity value to affect to the specified gradient
  108654. * @returns the current particle system
  108655. */
  108656. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108657. /**
  108658. * Remove a specific limit velocity gradient
  108659. * @param gradient defines the gradient to remove
  108660. * @returns the current particle system
  108661. */
  108662. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  108663. /**
  108664. * Adds a new drag gradient
  108665. * @param gradient defines the gradient to use (between 0 and 1)
  108666. * @param factor defines the drag value to affect to the specified gradient
  108667. * @returns the current particle system
  108668. */
  108669. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  108670. /**
  108671. * Remove a specific drag gradient
  108672. * @param gradient defines the gradient to remove
  108673. * @returns the current particle system
  108674. */
  108675. removeDragGradient(gradient: number): GPUParticleSystem;
  108676. /**
  108677. * Not supported by GPUParticleSystem
  108678. * @param gradient defines the gradient to use (between 0 and 1)
  108679. * @param factor defines the emit rate value to affect to the specified gradient
  108680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108681. * @returns the current particle system
  108682. */
  108683. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108684. /**
  108685. * Not supported by GPUParticleSystem
  108686. * @param gradient defines the gradient to remove
  108687. * @returns the current particle system
  108688. */
  108689. removeEmitRateGradient(gradient: number): IParticleSystem;
  108690. /**
  108691. * Not supported by GPUParticleSystem
  108692. * @param gradient defines the gradient to use (between 0 and 1)
  108693. * @param factor defines the start size value to affect to the specified gradient
  108694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108695. * @returns the current particle system
  108696. */
  108697. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108698. /**
  108699. * Not supported by GPUParticleSystem
  108700. * @param gradient defines the gradient to remove
  108701. * @returns the current particle system
  108702. */
  108703. removeStartSizeGradient(gradient: number): IParticleSystem;
  108704. /**
  108705. * Not supported by GPUParticleSystem
  108706. * @param gradient defines the gradient to use (between 0 and 1)
  108707. * @param min defines the color remap minimal range
  108708. * @param max defines the color remap maximal range
  108709. * @returns the current particle system
  108710. */
  108711. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108712. /**
  108713. * Not supported by GPUParticleSystem
  108714. * @param gradient defines the gradient to remove
  108715. * @returns the current particle system
  108716. */
  108717. removeColorRemapGradient(): IParticleSystem;
  108718. /**
  108719. * Not supported by GPUParticleSystem
  108720. * @param gradient defines the gradient to use (between 0 and 1)
  108721. * @param min defines the alpha remap minimal range
  108722. * @param max defines the alpha remap maximal range
  108723. * @returns the current particle system
  108724. */
  108725. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108726. /**
  108727. * Not supported by GPUParticleSystem
  108728. * @param gradient defines the gradient to remove
  108729. * @returns the current particle system
  108730. */
  108731. removeAlphaRemapGradient(): IParticleSystem;
  108732. /**
  108733. * Not supported by GPUParticleSystem
  108734. * @param gradient defines the gradient to use (between 0 and 1)
  108735. * @param color defines the color to affect to the specified gradient
  108736. * @returns the current particle system
  108737. */
  108738. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  108739. /**
  108740. * Not supported by GPUParticleSystem
  108741. * @param gradient defines the gradient to remove
  108742. * @returns the current particle system
  108743. */
  108744. removeRampGradient(): IParticleSystem;
  108745. /**
  108746. * Not supported by GPUParticleSystem
  108747. * @returns the list of ramp gradients
  108748. */
  108749. getRampGradients(): Nullable<Array<Color3Gradient>>;
  108750. /**
  108751. * Not supported by GPUParticleSystem
  108752. * Gets or sets a boolean indicating that ramp gradients must be used
  108753. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108754. */
  108755. useRampGradients: boolean;
  108756. /**
  108757. * Not supported by GPUParticleSystem
  108758. * @param gradient defines the gradient to use (between 0 and 1)
  108759. * @param factor defines the life time factor to affect to the specified gradient
  108760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108761. * @returns the current particle system
  108762. */
  108763. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108764. /**
  108765. * Not supported by GPUParticleSystem
  108766. * @param gradient defines the gradient to remove
  108767. * @returns the current particle system
  108768. */
  108769. removeLifeTimeGradient(gradient: number): IParticleSystem;
  108770. /**
  108771. * Instantiates a GPU particle system.
  108772. * 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.
  108773. * @param name The name of the particle system
  108774. * @param options The options used to create the system
  108775. * @param scene The scene the particle system belongs to
  108776. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108777. */
  108778. constructor(name: string, options: Partial<{
  108779. capacity: number;
  108780. randomTextureSize: number;
  108781. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  108782. protected _reset(): void;
  108783. private _createUpdateVAO;
  108784. private _createRenderVAO;
  108785. private _initialize;
  108786. /** @hidden */
  108787. _recreateUpdateEffect(): void;
  108788. /** @hidden */
  108789. _recreateRenderEffect(): void;
  108790. /**
  108791. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108792. * @param preWarm defines if we are in the pre-warmimg phase
  108793. */
  108794. animate(preWarm?: boolean): void;
  108795. private _createFactorGradientTexture;
  108796. private _createSizeGradientTexture;
  108797. private _createAngularSpeedGradientTexture;
  108798. private _createVelocityGradientTexture;
  108799. private _createLimitVelocityGradientTexture;
  108800. private _createDragGradientTexture;
  108801. private _createColorGradientTexture;
  108802. /**
  108803. * Renders the particle system in its current state
  108804. * @param preWarm defines if the system should only update the particles but not render them
  108805. * @returns the current number of particles
  108806. */
  108807. render(preWarm?: boolean): number;
  108808. /**
  108809. * Rebuilds the particle system
  108810. */
  108811. rebuild(): void;
  108812. private _releaseBuffers;
  108813. private _releaseVAOs;
  108814. /**
  108815. * Disposes the particle system and free the associated resources
  108816. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108817. */
  108818. dispose(disposeTexture?: boolean): void;
  108819. /**
  108820. * Clones the particle system.
  108821. * @param name The name of the cloned object
  108822. * @param newEmitter The new emitter to use
  108823. * @returns the cloned particle system
  108824. */
  108825. clone(name: string, newEmitter: any): GPUParticleSystem;
  108826. /**
  108827. * Serializes the particle system to a JSON object.
  108828. * @returns the JSON object
  108829. */
  108830. serialize(): any;
  108831. /**
  108832. * Parses a JSON object to create a GPU particle system.
  108833. * @param parsedParticleSystem The JSON object to parse
  108834. * @param scene The scene to create the particle system in
  108835. * @param rootUrl The root url to use to load external dependencies like texture
  108836. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108837. * @returns the parsed GPU particle system
  108838. */
  108839. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  108840. }
  108841. }
  108842. declare module BABYLON {
  108843. /**
  108844. * Represents a set of particle systems working together to create a specific effect
  108845. */
  108846. export class ParticleSystemSet implements IDisposable {
  108847. private _emitterCreationOptions;
  108848. private _emitterNode;
  108849. /**
  108850. * Gets the particle system list
  108851. */
  108852. systems: IParticleSystem[];
  108853. /**
  108854. * Gets the emitter node used with this set
  108855. */
  108856. readonly emitterNode: Nullable<TransformNode>;
  108857. /**
  108858. * Creates a new emitter mesh as a sphere
  108859. * @param options defines the options used to create the sphere
  108860. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108861. * @param scene defines the hosting scene
  108862. */
  108863. setEmitterAsSphere(options: {
  108864. diameter: number;
  108865. segments: number;
  108866. color: Color3;
  108867. }, renderingGroupId: number, scene: Scene): void;
  108868. /**
  108869. * Starts all particle systems of the set
  108870. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108871. */
  108872. start(emitter?: AbstractMesh): void;
  108873. /**
  108874. * Release all associated resources
  108875. */
  108876. dispose(): void;
  108877. /**
  108878. * Serialize the set into a JSON compatible object
  108879. * @returns a JSON compatible representation of the set
  108880. */
  108881. serialize(): any;
  108882. /**
  108883. * Parse a new ParticleSystemSet from a serialized source
  108884. * @param data defines a JSON compatible representation of the set
  108885. * @param scene defines the hosting scene
  108886. * @param gpu defines if we want GPU particles or CPU particles
  108887. * @returns a new ParticleSystemSet
  108888. */
  108889. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  108890. }
  108891. }
  108892. declare module BABYLON {
  108893. /**
  108894. * This class is made for on one-liner static method to help creating particle system set.
  108895. */
  108896. export class ParticleHelper {
  108897. /**
  108898. * Gets or sets base Assets URL
  108899. */
  108900. static BaseAssetsUrl: string;
  108901. /**
  108902. * Create a default particle system that you can tweak
  108903. * @param emitter defines the emitter to use
  108904. * @param capacity defines the system capacity (default is 500 particles)
  108905. * @param scene defines the hosting scene
  108906. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108907. * @returns the new Particle system
  108908. */
  108909. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  108910. /**
  108911. * This is the main static method (one-liner) of this helper to create different particle systems
  108912. * @param type This string represents the type to the particle system to create
  108913. * @param scene The scene where the particle system should live
  108914. * @param gpu If the system will use gpu
  108915. * @returns the ParticleSystemSet created
  108916. */
  108917. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  108918. /**
  108919. * Static function used to export a particle system to a ParticleSystemSet variable.
  108920. * Please note that the emitter shape is not exported
  108921. * @param systems defines the particle systems to export
  108922. * @returns the created particle system set
  108923. */
  108924. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  108925. }
  108926. }
  108927. declare module BABYLON {
  108928. interface Engine {
  108929. /**
  108930. * Create an effect to use with particle systems.
  108931. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  108932. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  108933. * @param uniformsNames defines a list of attribute names
  108934. * @param samplers defines an array of string used to represent textures
  108935. * @param defines defines the string containing the defines to use to compile the shaders
  108936. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108937. * @param onCompiled defines a function to call when the effect creation is successful
  108938. * @param onError defines a function to call when the effect creation has failed
  108939. * @returns the new Effect
  108940. */
  108941. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  108942. }
  108943. interface Mesh {
  108944. /**
  108945. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  108946. * @returns an array of IParticleSystem
  108947. */
  108948. getEmittedParticleSystems(): IParticleSystem[];
  108949. /**
  108950. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  108951. * @returns an array of IParticleSystem
  108952. */
  108953. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  108954. }
  108955. /**
  108956. * @hidden
  108957. */
  108958. export var _IDoNeedToBeInTheBuild: number;
  108959. }
  108960. declare module BABYLON {
  108961. interface Scene {
  108962. /** @hidden (Backing field) */
  108963. _physicsEngine: Nullable<IPhysicsEngine>;
  108964. /**
  108965. * Gets the current physics engine
  108966. * @returns a IPhysicsEngine or null if none attached
  108967. */
  108968. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  108969. /**
  108970. * Enables physics to the current scene
  108971. * @param gravity defines the scene's gravity for the physics engine
  108972. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  108973. * @return a boolean indicating if the physics engine was initialized
  108974. */
  108975. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  108976. /**
  108977. * Disables and disposes the physics engine associated with the scene
  108978. */
  108979. disablePhysicsEngine(): void;
  108980. /**
  108981. * Gets a boolean indicating if there is an active physics engine
  108982. * @returns a boolean indicating if there is an active physics engine
  108983. */
  108984. isPhysicsEnabled(): boolean;
  108985. /**
  108986. * Deletes a physics compound impostor
  108987. * @param compound defines the compound to delete
  108988. */
  108989. deleteCompoundImpostor(compound: any): void;
  108990. /**
  108991. * An event triggered when physic simulation is about to be run
  108992. */
  108993. onBeforePhysicsObservable: Observable<Scene>;
  108994. /**
  108995. * An event triggered when physic simulation has been done
  108996. */
  108997. onAfterPhysicsObservable: Observable<Scene>;
  108998. }
  108999. interface AbstractMesh {
  109000. /** @hidden */
  109001. _physicsImpostor: Nullable<PhysicsImpostor>;
  109002. /**
  109003. * Gets or sets impostor used for physic simulation
  109004. * @see http://doc.babylonjs.com/features/physics_engine
  109005. */
  109006. physicsImpostor: Nullable<PhysicsImpostor>;
  109007. /**
  109008. * Gets the current physics impostor
  109009. * @see http://doc.babylonjs.com/features/physics_engine
  109010. * @returns a physics impostor or null
  109011. */
  109012. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  109013. /** Apply a physic impulse to the mesh
  109014. * @param force defines the force to apply
  109015. * @param contactPoint defines where to apply the force
  109016. * @returns the current mesh
  109017. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  109018. */
  109019. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  109020. /**
  109021. * Creates a physic joint between two meshes
  109022. * @param otherMesh defines the other mesh to use
  109023. * @param pivot1 defines the pivot to use on this mesh
  109024. * @param pivot2 defines the pivot to use on the other mesh
  109025. * @param options defines additional options (can be plugin dependent)
  109026. * @returns the current mesh
  109027. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  109028. */
  109029. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  109030. /** @hidden */
  109031. _disposePhysicsObserver: Nullable<Observer<Node>>;
  109032. }
  109033. /**
  109034. * Defines the physics engine scene component responsible to manage a physics engine
  109035. */
  109036. export class PhysicsEngineSceneComponent implements ISceneComponent {
  109037. /**
  109038. * The component name helpful to identify the component in the list of scene components.
  109039. */
  109040. readonly name: string;
  109041. /**
  109042. * The scene the component belongs to.
  109043. */
  109044. scene: Scene;
  109045. /**
  109046. * Creates a new instance of the component for the given scene
  109047. * @param scene Defines the scene to register the component in
  109048. */
  109049. constructor(scene: Scene);
  109050. /**
  109051. * Registers the component in a given scene
  109052. */
  109053. register(): void;
  109054. /**
  109055. * Rebuilds the elements related to this component in case of
  109056. * context lost for instance.
  109057. */
  109058. rebuild(): void;
  109059. /**
  109060. * Disposes the component and the associated ressources
  109061. */
  109062. dispose(): void;
  109063. }
  109064. }
  109065. declare module BABYLON {
  109066. /**
  109067. * A helper for physics simulations
  109068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109069. */
  109070. export class PhysicsHelper {
  109071. private _scene;
  109072. private _physicsEngine;
  109073. /**
  109074. * Initializes the Physics helper
  109075. * @param scene Babylon.js scene
  109076. */
  109077. constructor(scene: Scene);
  109078. /**
  109079. * Applies a radial explosion impulse
  109080. * @param origin the origin of the explosion
  109081. * @param radiusOrEventOptions the radius or the options of radial explosion
  109082. * @param strength the explosion strength
  109083. * @param falloff possible options: Constant & Linear. Defaults to Constant
  109084. * @returns A physics radial explosion event, or null
  109085. */
  109086. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  109087. /**
  109088. * Applies a radial explosion force
  109089. * @param origin the origin of the explosion
  109090. * @param radiusOrEventOptions the radius or the options of radial explosion
  109091. * @param strength the explosion strength
  109092. * @param falloff possible options: Constant & Linear. Defaults to Constant
  109093. * @returns A physics radial explosion event, or null
  109094. */
  109095. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  109096. /**
  109097. * Creates a gravitational field
  109098. * @param origin the origin of the explosion
  109099. * @param radiusOrEventOptions the radius or the options of radial explosion
  109100. * @param strength the explosion strength
  109101. * @param falloff possible options: Constant & Linear. Defaults to Constant
  109102. * @returns A physics gravitational field event, or null
  109103. */
  109104. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  109105. /**
  109106. * Creates a physics updraft event
  109107. * @param origin the origin of the updraft
  109108. * @param radiusOrEventOptions the radius or the options of the updraft
  109109. * @param strength the strength of the updraft
  109110. * @param height the height of the updraft
  109111. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  109112. * @returns A physics updraft event, or null
  109113. */
  109114. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  109115. /**
  109116. * Creates a physics vortex event
  109117. * @param origin the of the vortex
  109118. * @param radiusOrEventOptions the radius or the options of the vortex
  109119. * @param strength the strength of the vortex
  109120. * @param height the height of the vortex
  109121. * @returns a Physics vortex event, or null
  109122. * A physics vortex event or null
  109123. */
  109124. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  109125. }
  109126. /**
  109127. * Represents a physics radial explosion event
  109128. */
  109129. class PhysicsRadialExplosionEvent {
  109130. private _scene;
  109131. private _options;
  109132. private _sphere;
  109133. private _dataFetched;
  109134. /**
  109135. * Initializes a radial explosioin event
  109136. * @param _scene BabylonJS scene
  109137. * @param _options The options for the vortex event
  109138. */
  109139. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  109140. /**
  109141. * Returns the data related to the radial explosion event (sphere).
  109142. * @returns The radial explosion event data
  109143. */
  109144. getData(): PhysicsRadialExplosionEventData;
  109145. /**
  109146. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  109147. * @param impostor A physics imposter
  109148. * @param origin the origin of the explosion
  109149. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  109150. */
  109151. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  109152. /**
  109153. * Disposes the sphere.
  109154. * @param force Specifies if the sphere should be disposed by force
  109155. */
  109156. dispose(force?: boolean): void;
  109157. /*** Helpers ***/
  109158. private _prepareSphere;
  109159. private _intersectsWithSphere;
  109160. }
  109161. /**
  109162. * Represents a gravitational field event
  109163. */
  109164. class PhysicsGravitationalFieldEvent {
  109165. private _physicsHelper;
  109166. private _scene;
  109167. private _origin;
  109168. private _options;
  109169. private _tickCallback;
  109170. private _sphere;
  109171. private _dataFetched;
  109172. /**
  109173. * Initializes the physics gravitational field event
  109174. * @param _physicsHelper A physics helper
  109175. * @param _scene BabylonJS scene
  109176. * @param _origin The origin position of the gravitational field event
  109177. * @param _options The options for the vortex event
  109178. */
  109179. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  109180. /**
  109181. * Returns the data related to the gravitational field event (sphere).
  109182. * @returns A gravitational field event
  109183. */
  109184. getData(): PhysicsGravitationalFieldEventData;
  109185. /**
  109186. * Enables the gravitational field.
  109187. */
  109188. enable(): void;
  109189. /**
  109190. * Disables the gravitational field.
  109191. */
  109192. disable(): void;
  109193. /**
  109194. * Disposes the sphere.
  109195. * @param force The force to dispose from the gravitational field event
  109196. */
  109197. dispose(force?: boolean): void;
  109198. private _tick;
  109199. }
  109200. /**
  109201. * Represents a physics updraft event
  109202. */
  109203. class PhysicsUpdraftEvent {
  109204. private _scene;
  109205. private _origin;
  109206. private _options;
  109207. private _physicsEngine;
  109208. private _originTop;
  109209. private _originDirection;
  109210. private _tickCallback;
  109211. private _cylinder;
  109212. private _cylinderPosition;
  109213. private _dataFetched;
  109214. /**
  109215. * Initializes the physics updraft event
  109216. * @param _scene BabylonJS scene
  109217. * @param _origin The origin position of the updraft
  109218. * @param _options The options for the updraft event
  109219. */
  109220. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  109221. /**
  109222. * Returns the data related to the updraft event (cylinder).
  109223. * @returns A physics updraft event
  109224. */
  109225. getData(): PhysicsUpdraftEventData;
  109226. /**
  109227. * Enables the updraft.
  109228. */
  109229. enable(): void;
  109230. /**
  109231. * Disables the updraft.
  109232. */
  109233. disable(): void;
  109234. /**
  109235. * Disposes the cylinder.
  109236. * @param force Specifies if the updraft should be disposed by force
  109237. */
  109238. dispose(force?: boolean): void;
  109239. private getImpostorForceAndContactPoint;
  109240. private _tick;
  109241. /*** Helpers ***/
  109242. private _prepareCylinder;
  109243. private _intersectsWithCylinder;
  109244. }
  109245. /**
  109246. * Represents a physics vortex event
  109247. */
  109248. class PhysicsVortexEvent {
  109249. private _scene;
  109250. private _origin;
  109251. private _options;
  109252. private _physicsEngine;
  109253. private _originTop;
  109254. private _tickCallback;
  109255. private _cylinder;
  109256. private _cylinderPosition;
  109257. private _dataFetched;
  109258. /**
  109259. * Initializes the physics vortex event
  109260. * @param _scene The BabylonJS scene
  109261. * @param _origin The origin position of the vortex
  109262. * @param _options The options for the vortex event
  109263. */
  109264. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  109265. /**
  109266. * Returns the data related to the vortex event (cylinder).
  109267. * @returns The physics vortex event data
  109268. */
  109269. getData(): PhysicsVortexEventData;
  109270. /**
  109271. * Enables the vortex.
  109272. */
  109273. enable(): void;
  109274. /**
  109275. * Disables the cortex.
  109276. */
  109277. disable(): void;
  109278. /**
  109279. * Disposes the sphere.
  109280. * @param force
  109281. */
  109282. dispose(force?: boolean): void;
  109283. private getImpostorForceAndContactPoint;
  109284. private _tick;
  109285. /*** Helpers ***/
  109286. private _prepareCylinder;
  109287. private _intersectsWithCylinder;
  109288. }
  109289. /**
  109290. * Options fot the radial explosion event
  109291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109292. */
  109293. export class PhysicsRadialExplosionEventOptions {
  109294. /**
  109295. * The radius of the sphere for the radial explosion.
  109296. */
  109297. radius: number;
  109298. /**
  109299. * The strenth of the explosion.
  109300. */
  109301. strength: number;
  109302. /**
  109303. * The strenght of the force in correspondence to the distance of the affected object
  109304. */
  109305. falloff: PhysicsRadialImpulseFalloff;
  109306. /**
  109307. * Sphere options for the radial explosion.
  109308. */
  109309. sphere: {
  109310. segments: number;
  109311. diameter: number;
  109312. };
  109313. }
  109314. /**
  109315. * Options fot the updraft event
  109316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109317. */
  109318. export class PhysicsUpdraftEventOptions {
  109319. /**
  109320. * The radius of the cylinder for the vortex
  109321. */
  109322. radius: number;
  109323. /**
  109324. * The strenth of the updraft.
  109325. */
  109326. strength: number;
  109327. /**
  109328. * The height of the cylinder for the updraft.
  109329. */
  109330. height: number;
  109331. /**
  109332. * The mode for the the updraft.
  109333. */
  109334. updraftMode: PhysicsUpdraftMode;
  109335. }
  109336. /**
  109337. * Options fot the vortex event
  109338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109339. */
  109340. export class PhysicsVortexEventOptions {
  109341. /**
  109342. * The radius of the cylinder for the vortex
  109343. */
  109344. radius: number;
  109345. /**
  109346. * The strenth of the vortex.
  109347. */
  109348. strength: number;
  109349. /**
  109350. * The height of the cylinder for the vortex.
  109351. */
  109352. height: number;
  109353. /**
  109354. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  109355. */
  109356. centripetalForceThreshold: number;
  109357. /**
  109358. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  109359. */
  109360. centripetalForceMultiplier: number;
  109361. /**
  109362. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  109363. */
  109364. centrifugalForceMultiplier: number;
  109365. /**
  109366. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  109367. */
  109368. updraftForceMultiplier: number;
  109369. }
  109370. /**
  109371. * The strenght of the force in correspondence to the distance of the affected object
  109372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109373. */
  109374. export enum PhysicsRadialImpulseFalloff {
  109375. /** Defines that impulse is constant in strength across it's whole radius */
  109376. Constant = 0,
  109377. /** Defines that impulse gets weaker if it's further from the origin */
  109378. Linear = 1
  109379. }
  109380. /**
  109381. * The strength of the force in correspondence to the distance of the affected object
  109382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109383. */
  109384. export enum PhysicsUpdraftMode {
  109385. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  109386. Center = 0,
  109387. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  109388. Perpendicular = 1
  109389. }
  109390. /**
  109391. * Interface for a physics force and contact point
  109392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109393. */
  109394. export interface PhysicsForceAndContactPoint {
  109395. /**
  109396. * The force applied at the contact point
  109397. */
  109398. force: Vector3;
  109399. /**
  109400. * The contact point
  109401. */
  109402. contactPoint: Vector3;
  109403. }
  109404. /**
  109405. * Interface for radial explosion event data
  109406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109407. */
  109408. export interface PhysicsRadialExplosionEventData {
  109409. /**
  109410. * A sphere used for the radial explosion event
  109411. */
  109412. sphere: Mesh;
  109413. }
  109414. /**
  109415. * Interface for gravitational field event data
  109416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109417. */
  109418. export interface PhysicsGravitationalFieldEventData {
  109419. /**
  109420. * A sphere mesh used for the gravitational field event
  109421. */
  109422. sphere: Mesh;
  109423. }
  109424. /**
  109425. * Interface for updraft event data
  109426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109427. */
  109428. export interface PhysicsUpdraftEventData {
  109429. /**
  109430. * A cylinder used for the updraft event
  109431. */
  109432. cylinder: Mesh;
  109433. }
  109434. /**
  109435. * Interface for vortex event data
  109436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109437. */
  109438. export interface PhysicsVortexEventData {
  109439. /**
  109440. * A cylinder used for the vortex event
  109441. */
  109442. cylinder: Mesh;
  109443. }
  109444. }
  109445. declare module BABYLON {
  109446. /**
  109447. * AmmoJS Physics plugin
  109448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109449. * @see https://github.com/kripken/ammo.js/
  109450. */
  109451. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  109452. private _useDeltaForWorldStep;
  109453. /**
  109454. * Reference to the Ammo library
  109455. */
  109456. bjsAMMO: any;
  109457. /**
  109458. * Created ammoJS world which physics bodies are added to
  109459. */
  109460. world: any;
  109461. /**
  109462. * Name of the plugin
  109463. */
  109464. name: string;
  109465. private _timeStep;
  109466. private _fixedTimeStep;
  109467. private _maxSteps;
  109468. private _tmpQuaternion;
  109469. private _tmpAmmoTransform;
  109470. private _tmpAmmoQuaternion;
  109471. private _tmpAmmoConcreteContactResultCallback;
  109472. private _collisionConfiguration;
  109473. private _dispatcher;
  109474. private _overlappingPairCache;
  109475. private _solver;
  109476. private _softBodySolver;
  109477. private _tmpAmmoVectorA;
  109478. private _tmpAmmoVectorB;
  109479. private _tmpAmmoVectorC;
  109480. private _tmpAmmoVectorD;
  109481. private _tmpContactCallbackResult;
  109482. private _tmpAmmoVectorRCA;
  109483. private _tmpAmmoVectorRCB;
  109484. private _raycastResult;
  109485. private static readonly DISABLE_COLLISION_FLAG;
  109486. private static readonly KINEMATIC_FLAG;
  109487. private static readonly DISABLE_DEACTIVATION_FLAG;
  109488. /**
  109489. * Initializes the ammoJS plugin
  109490. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109491. * @param ammoInjection can be used to inject your own ammo reference
  109492. */
  109493. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  109494. /**
  109495. * Sets the gravity of the physics world (m/(s^2))
  109496. * @param gravity Gravity to set
  109497. */
  109498. setGravity(gravity: Vector3): void;
  109499. /**
  109500. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109501. * @param timeStep timestep to use in seconds
  109502. */
  109503. setTimeStep(timeStep: number): void;
  109504. /**
  109505. * 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)
  109506. * @param fixedTimeStep fixedTimeStep to use in seconds
  109507. */
  109508. setFixedTimeStep(fixedTimeStep: number): void;
  109509. /**
  109510. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109511. * @param maxSteps the maximum number of steps by the physics engine per frame
  109512. */
  109513. setMaxSteps(maxSteps: number): void;
  109514. /**
  109515. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109516. * @returns the current timestep in seconds
  109517. */
  109518. getTimeStep(): number;
  109519. private _isImpostorInContact;
  109520. private _isImpostorPairInContact;
  109521. private _stepSimulation;
  109522. /**
  109523. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109524. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109525. * After the step the babylon meshes are set to the position of the physics imposters
  109526. * @param delta amount of time to step forward
  109527. * @param impostors array of imposters to update before/after the step
  109528. */
  109529. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  109530. /**
  109531. * Update babylon mesh to match physics world object
  109532. * @param impostor imposter to match
  109533. */
  109534. private _afterSoftStep;
  109535. /**
  109536. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  109537. * @param impostor imposter to match
  109538. */
  109539. private _ropeStep;
  109540. /**
  109541. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  109542. * @param impostor imposter to match
  109543. */
  109544. private _softbodyOrClothStep;
  109545. private _tmpVector;
  109546. private _tmpMatrix;
  109547. /**
  109548. * Applies an impulse on the imposter
  109549. * @param impostor imposter to apply impulse to
  109550. * @param force amount of force to be applied to the imposter
  109551. * @param contactPoint the location to apply the impulse on the imposter
  109552. */
  109553. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109554. /**
  109555. * Applies a force on the imposter
  109556. * @param impostor imposter to apply force
  109557. * @param force amount of force to be applied to the imposter
  109558. * @param contactPoint the location to apply the force on the imposter
  109559. */
  109560. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109561. /**
  109562. * Creates a physics body using the plugin
  109563. * @param impostor the imposter to create the physics body on
  109564. */
  109565. generatePhysicsBody(impostor: PhysicsImpostor): void;
  109566. /**
  109567. * Removes the physics body from the imposter and disposes of the body's memory
  109568. * @param impostor imposter to remove the physics body from
  109569. */
  109570. removePhysicsBody(impostor: PhysicsImpostor): void;
  109571. /**
  109572. * Generates a joint
  109573. * @param impostorJoint the imposter joint to create the joint with
  109574. */
  109575. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  109576. /**
  109577. * Removes a joint
  109578. * @param impostorJoint the imposter joint to remove the joint from
  109579. */
  109580. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  109581. private _addMeshVerts;
  109582. /**
  109583. * Initialise the soft body vertices to match its object's (mesh) vertices
  109584. * Softbody vertices (nodes) are in world space and to match this
  109585. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  109586. * @param impostor to create the softbody for
  109587. */
  109588. private _softVertexData;
  109589. /**
  109590. * Create an impostor's soft body
  109591. * @param impostor to create the softbody for
  109592. */
  109593. private _createSoftbody;
  109594. /**
  109595. * Create cloth for an impostor
  109596. * @param impostor to create the softbody for
  109597. */
  109598. private _createCloth;
  109599. /**
  109600. * Create rope for an impostor
  109601. * @param impostor to create the softbody for
  109602. */
  109603. private _createRope;
  109604. private _addHullVerts;
  109605. private _createShape;
  109606. /**
  109607. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109608. * @param impostor imposter containing the physics body and babylon object
  109609. */
  109610. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  109611. /**
  109612. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109613. * @param impostor imposter containing the physics body and babylon object
  109614. * @param newPosition new position
  109615. * @param newRotation new rotation
  109616. */
  109617. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  109618. /**
  109619. * If this plugin is supported
  109620. * @returns true if its supported
  109621. */
  109622. isSupported(): boolean;
  109623. /**
  109624. * Sets the linear velocity of the physics body
  109625. * @param impostor imposter to set the velocity on
  109626. * @param velocity velocity to set
  109627. */
  109628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109629. /**
  109630. * Sets the angular velocity of the physics body
  109631. * @param impostor imposter to set the velocity on
  109632. * @param velocity velocity to set
  109633. */
  109634. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109635. /**
  109636. * gets the linear velocity
  109637. * @param impostor imposter to get linear velocity from
  109638. * @returns linear velocity
  109639. */
  109640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109641. /**
  109642. * gets the angular velocity
  109643. * @param impostor imposter to get angular velocity from
  109644. * @returns angular velocity
  109645. */
  109646. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109647. /**
  109648. * Sets the mass of physics body
  109649. * @param impostor imposter to set the mass on
  109650. * @param mass mass to set
  109651. */
  109652. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  109653. /**
  109654. * Gets the mass of the physics body
  109655. * @param impostor imposter to get the mass from
  109656. * @returns mass
  109657. */
  109658. getBodyMass(impostor: PhysicsImpostor): number;
  109659. /**
  109660. * Gets friction of the impostor
  109661. * @param impostor impostor to get friction from
  109662. * @returns friction value
  109663. */
  109664. getBodyFriction(impostor: PhysicsImpostor): number;
  109665. /**
  109666. * Sets friction of the impostor
  109667. * @param impostor impostor to set friction on
  109668. * @param friction friction value
  109669. */
  109670. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  109671. /**
  109672. * Gets restitution of the impostor
  109673. * @param impostor impostor to get restitution from
  109674. * @returns restitution value
  109675. */
  109676. getBodyRestitution(impostor: PhysicsImpostor): number;
  109677. /**
  109678. * Sets resitution of the impostor
  109679. * @param impostor impostor to set resitution on
  109680. * @param restitution resitution value
  109681. */
  109682. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  109683. /**
  109684. * Gets pressure inside the impostor
  109685. * @param impostor impostor to get pressure from
  109686. * @returns pressure value
  109687. */
  109688. getBodyPressure(impostor: PhysicsImpostor): number;
  109689. /**
  109690. * Sets pressure inside a soft body impostor
  109691. * Cloth and rope must remain 0 pressure
  109692. * @param impostor impostor to set pressure on
  109693. * @param pressure pressure value
  109694. */
  109695. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  109696. /**
  109697. * Gets stiffness of the impostor
  109698. * @param impostor impostor to get stiffness from
  109699. * @returns pressure value
  109700. */
  109701. getBodyStiffness(impostor: PhysicsImpostor): number;
  109702. /**
  109703. * Sets stiffness of the impostor
  109704. * @param impostor impostor to set stiffness on
  109705. * @param stiffness stiffness value from 0 to 1
  109706. */
  109707. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  109708. /**
  109709. * Gets velocityIterations of the impostor
  109710. * @param impostor impostor to get velocity iterations from
  109711. * @returns velocityIterations value
  109712. */
  109713. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  109714. /**
  109715. * Sets velocityIterations of the impostor
  109716. * @param impostor impostor to set velocity iterations on
  109717. * @param velocityIterations velocityIterations value
  109718. */
  109719. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  109720. /**
  109721. * Gets positionIterations of the impostor
  109722. * @param impostor impostor to get position iterations from
  109723. * @returns positionIterations value
  109724. */
  109725. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  109726. /**
  109727. * Sets positionIterations of the impostor
  109728. * @param impostor impostor to set position on
  109729. * @param positionIterations positionIterations value
  109730. */
  109731. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  109732. /**
  109733. * Append an anchor to a cloth object
  109734. * @param impostor is the cloth impostor to add anchor to
  109735. * @param otherImpostor is the rigid impostor to anchor to
  109736. * @param width ratio across width from 0 to 1
  109737. * @param height ratio up height from 0 to 1
  109738. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  109739. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109740. */
  109741. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109742. /**
  109743. * Append an hook to a rope object
  109744. * @param impostor is the rope impostor to add hook to
  109745. * @param otherImpostor is the rigid impostor to hook to
  109746. * @param length ratio along the rope from 0 to 1
  109747. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  109748. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109749. */
  109750. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109751. /**
  109752. * Sleeps the physics body and stops it from being active
  109753. * @param impostor impostor to sleep
  109754. */
  109755. sleepBody(impostor: PhysicsImpostor): void;
  109756. /**
  109757. * Activates the physics body
  109758. * @param impostor impostor to activate
  109759. */
  109760. wakeUpBody(impostor: PhysicsImpostor): void;
  109761. /**
  109762. * Updates the distance parameters of the joint
  109763. * @param joint joint to update
  109764. * @param maxDistance maximum distance of the joint
  109765. * @param minDistance minimum distance of the joint
  109766. */
  109767. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  109768. /**
  109769. * Sets a motor on the joint
  109770. * @param joint joint to set motor on
  109771. * @param speed speed of the motor
  109772. * @param maxForce maximum force of the motor
  109773. * @param motorIndex index of the motor
  109774. */
  109775. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  109776. /**
  109777. * Sets the motors limit
  109778. * @param joint joint to set limit on
  109779. * @param upperLimit upper limit
  109780. * @param lowerLimit lower limit
  109781. */
  109782. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  109783. /**
  109784. * Syncs the position and rotation of a mesh with the impostor
  109785. * @param mesh mesh to sync
  109786. * @param impostor impostor to update the mesh with
  109787. */
  109788. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  109789. /**
  109790. * Gets the radius of the impostor
  109791. * @param impostor impostor to get radius from
  109792. * @returns the radius
  109793. */
  109794. getRadius(impostor: PhysicsImpostor): number;
  109795. /**
  109796. * Gets the box size of the impostor
  109797. * @param impostor impostor to get box size from
  109798. * @param result the resulting box size
  109799. */
  109800. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  109801. /**
  109802. * Disposes of the impostor
  109803. */
  109804. dispose(): void;
  109805. /**
  109806. * Does a raycast in the physics world
  109807. * @param from when should the ray start?
  109808. * @param to when should the ray end?
  109809. * @returns PhysicsRaycastResult
  109810. */
  109811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  109812. }
  109813. }
  109814. declare module BABYLON {
  109815. /** @hidden */
  109816. export var blackAndWhitePixelShader: {
  109817. name: string;
  109818. shader: string;
  109819. };
  109820. }
  109821. declare module BABYLON {
  109822. /**
  109823. * Post process used to render in black and white
  109824. */
  109825. export class BlackAndWhitePostProcess extends PostProcess {
  109826. /**
  109827. * Linear about to convert he result to black and white (default: 1)
  109828. */
  109829. degree: number;
  109830. /**
  109831. * Creates a black and white post process
  109832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  109833. * @param name The name of the effect.
  109834. * @param options The required width/height ratio to downsize to before computing the render pass.
  109835. * @param camera The camera to apply the render pass to.
  109836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109837. * @param engine The engine which the post process will be applied. (default: current engine)
  109838. * @param reusable If the post process can be reused on the same frame. (default: false)
  109839. */
  109840. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109841. }
  109842. }
  109843. declare module BABYLON {
  109844. /**
  109845. * This represents a set of one or more post processes in Babylon.
  109846. * A post process can be used to apply a shader to a texture after it is rendered.
  109847. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109848. */
  109849. export class PostProcessRenderEffect {
  109850. private _postProcesses;
  109851. private _getPostProcesses;
  109852. private _singleInstance;
  109853. private _cameras;
  109854. private _indicesForCamera;
  109855. /**
  109856. * Name of the effect
  109857. * @hidden
  109858. */
  109859. _name: string;
  109860. /**
  109861. * Instantiates a post process render effect.
  109862. * A post process can be used to apply a shader to a texture after it is rendered.
  109863. * @param engine The engine the effect is tied to
  109864. * @param name The name of the effect
  109865. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  109866. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  109867. */
  109868. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  109869. /**
  109870. * Checks if all the post processes in the effect are supported.
  109871. */
  109872. readonly isSupported: boolean;
  109873. /**
  109874. * Updates the current state of the effect
  109875. * @hidden
  109876. */
  109877. _update(): void;
  109878. /**
  109879. * Attaches the effect on cameras
  109880. * @param cameras The camera to attach to.
  109881. * @hidden
  109882. */
  109883. _attachCameras(cameras: Camera): void;
  109884. /**
  109885. * Attaches the effect on cameras
  109886. * @param cameras The camera to attach to.
  109887. * @hidden
  109888. */
  109889. _attachCameras(cameras: Camera[]): void;
  109890. /**
  109891. * Detatches the effect on cameras
  109892. * @param cameras The camera to detatch from.
  109893. * @hidden
  109894. */
  109895. _detachCameras(cameras: Camera): void;
  109896. /**
  109897. * Detatches the effect on cameras
  109898. * @param cameras The camera to detatch from.
  109899. * @hidden
  109900. */
  109901. _detachCameras(cameras: Camera[]): void;
  109902. /**
  109903. * Enables the effect on given cameras
  109904. * @param cameras The camera to enable.
  109905. * @hidden
  109906. */
  109907. _enable(cameras: Camera): void;
  109908. /**
  109909. * Enables the effect on given cameras
  109910. * @param cameras The camera to enable.
  109911. * @hidden
  109912. */
  109913. _enable(cameras: Nullable<Camera[]>): void;
  109914. /**
  109915. * Disables the effect on the given cameras
  109916. * @param cameras The camera to disable.
  109917. * @hidden
  109918. */
  109919. _disable(cameras: Camera): void;
  109920. /**
  109921. * Disables the effect on the given cameras
  109922. * @param cameras The camera to disable.
  109923. * @hidden
  109924. */
  109925. _disable(cameras: Nullable<Camera[]>): void;
  109926. /**
  109927. * Gets a list of the post processes contained in the effect.
  109928. * @param camera The camera to get the post processes on.
  109929. * @returns The list of the post processes in the effect.
  109930. */
  109931. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  109932. }
  109933. }
  109934. declare module BABYLON {
  109935. /** @hidden */
  109936. export var extractHighlightsPixelShader: {
  109937. name: string;
  109938. shader: string;
  109939. };
  109940. }
  109941. declare module BABYLON {
  109942. /**
  109943. * 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.
  109944. */
  109945. export class ExtractHighlightsPostProcess extends PostProcess {
  109946. /**
  109947. * The luminance threshold, pixels below this value will be set to black.
  109948. */
  109949. threshold: number;
  109950. /** @hidden */
  109951. _exposure: number;
  109952. /**
  109953. * Post process which has the input texture to be used when performing highlight extraction
  109954. * @hidden
  109955. */
  109956. _inputPostProcess: Nullable<PostProcess>;
  109957. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109958. }
  109959. }
  109960. declare module BABYLON {
  109961. /** @hidden */
  109962. export var bloomMergePixelShader: {
  109963. name: string;
  109964. shader: string;
  109965. };
  109966. }
  109967. declare module BABYLON {
  109968. /**
  109969. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109970. */
  109971. export class BloomMergePostProcess extends PostProcess {
  109972. /** Weight of the bloom to be added to the original input. */
  109973. weight: number;
  109974. /**
  109975. * Creates a new instance of @see BloomMergePostProcess
  109976. * @param name The name of the effect.
  109977. * @param originalFromInput Post process which's input will be used for the merge.
  109978. * @param blurred Blurred highlights post process which's output will be used.
  109979. * @param weight Weight of the bloom to be added to the original input.
  109980. * @param options The required width/height ratio to downsize to before computing the render pass.
  109981. * @param camera The camera to apply the render pass to.
  109982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109983. * @param engine The engine which the post process will be applied. (default: current engine)
  109984. * @param reusable If the post process can be reused on the same frame. (default: false)
  109985. * @param textureType Type of textures used when performing the post process. (default: 0)
  109986. * @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)
  109987. */
  109988. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  109989. /** Weight of the bloom to be added to the original input. */
  109990. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109991. }
  109992. }
  109993. declare module BABYLON {
  109994. /**
  109995. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  109996. */
  109997. export class BloomEffect extends PostProcessRenderEffect {
  109998. private bloomScale;
  109999. /**
  110000. * @hidden Internal
  110001. */
  110002. _effects: Array<PostProcess>;
  110003. /**
  110004. * @hidden Internal
  110005. */
  110006. _downscale: ExtractHighlightsPostProcess;
  110007. private _blurX;
  110008. private _blurY;
  110009. private _merge;
  110010. /**
  110011. * The luminance threshold to find bright areas of the image to bloom.
  110012. */
  110013. threshold: number;
  110014. /**
  110015. * The strength of the bloom.
  110016. */
  110017. weight: number;
  110018. /**
  110019. * Specifies the size of the bloom blur kernel, relative to the final output size
  110020. */
  110021. kernel: number;
  110022. /**
  110023. * Creates a new instance of @see BloomEffect
  110024. * @param scene The scene the effect belongs to.
  110025. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  110026. * @param bloomKernel The size of the kernel to be used when applying the blur.
  110027. * @param bloomWeight The the strength of bloom.
  110028. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110029. * @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)
  110030. */
  110031. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  110032. /**
  110033. * Disposes each of the internal effects for a given camera.
  110034. * @param camera The camera to dispose the effect on.
  110035. */
  110036. disposeEffects(camera: Camera): void;
  110037. /**
  110038. * @hidden Internal
  110039. */
  110040. _updateEffects(): void;
  110041. /**
  110042. * Internal
  110043. * @returns if all the contained post processes are ready.
  110044. * @hidden
  110045. */
  110046. _isReady(): boolean;
  110047. }
  110048. }
  110049. declare module BABYLON {
  110050. /** @hidden */
  110051. export var chromaticAberrationPixelShader: {
  110052. name: string;
  110053. shader: string;
  110054. };
  110055. }
  110056. declare module BABYLON {
  110057. /**
  110058. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  110059. */
  110060. export class ChromaticAberrationPostProcess extends PostProcess {
  110061. /**
  110062. * The amount of seperation of rgb channels (default: 30)
  110063. */
  110064. aberrationAmount: number;
  110065. /**
  110066. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  110067. */
  110068. radialIntensity: number;
  110069. /**
  110070. * 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))
  110071. */
  110072. direction: Vector2;
  110073. /**
  110074. * 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))
  110075. */
  110076. centerPosition: Vector2;
  110077. /**
  110078. * Creates a new instance ChromaticAberrationPostProcess
  110079. * @param name The name of the effect.
  110080. * @param screenWidth The width of the screen to apply the effect on.
  110081. * @param screenHeight The height of the screen to apply the effect on.
  110082. * @param options The required width/height ratio to downsize to before computing the render pass.
  110083. * @param camera The camera to apply the render pass to.
  110084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110085. * @param engine The engine which the post process will be applied. (default: current engine)
  110086. * @param reusable If the post process can be reused on the same frame. (default: false)
  110087. * @param textureType Type of textures used when performing the post process. (default: 0)
  110088. * @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)
  110089. */
  110090. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110091. }
  110092. }
  110093. declare module BABYLON {
  110094. /** @hidden */
  110095. export var circleOfConfusionPixelShader: {
  110096. name: string;
  110097. shader: string;
  110098. };
  110099. }
  110100. declare module BABYLON {
  110101. /**
  110102. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  110103. */
  110104. export class CircleOfConfusionPostProcess extends PostProcess {
  110105. /**
  110106. * 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.
  110107. */
  110108. lensSize: number;
  110109. /**
  110110. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110111. */
  110112. fStop: number;
  110113. /**
  110114. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110115. */
  110116. focusDistance: number;
  110117. /**
  110118. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  110119. */
  110120. focalLength: number;
  110121. private _depthTexture;
  110122. /**
  110123. * Creates a new instance CircleOfConfusionPostProcess
  110124. * @param name The name of the effect.
  110125. * @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.
  110126. * @param options The required width/height ratio to downsize to before computing the render pass.
  110127. * @param camera The camera to apply the render pass to.
  110128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110129. * @param engine The engine which the post process will be applied. (default: current engine)
  110130. * @param reusable If the post process can be reused on the same frame. (default: false)
  110131. * @param textureType Type of textures used when performing the post process. (default: 0)
  110132. * @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)
  110133. */
  110134. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110135. /**
  110136. * 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.
  110137. */
  110138. depthTexture: RenderTargetTexture;
  110139. }
  110140. }
  110141. declare module BABYLON {
  110142. /** @hidden */
  110143. export var colorCorrectionPixelShader: {
  110144. name: string;
  110145. shader: string;
  110146. };
  110147. }
  110148. declare module BABYLON {
  110149. /**
  110150. *
  110151. * This post-process allows the modification of rendered colors by using
  110152. * a 'look-up table' (LUT). This effect is also called Color Grading.
  110153. *
  110154. * The object needs to be provided an url to a texture containing the color
  110155. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  110156. * Use an image editing software to tweak the LUT to match your needs.
  110157. *
  110158. * For an example of a color LUT, see here:
  110159. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  110160. * For explanations on color grading, see here:
  110161. * @see http://udn.epicgames.com/Three/ColorGrading.html
  110162. *
  110163. */
  110164. export class ColorCorrectionPostProcess extends PostProcess {
  110165. private _colorTableTexture;
  110166. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110167. }
  110168. }
  110169. declare module BABYLON {
  110170. /** @hidden */
  110171. export var convolutionPixelShader: {
  110172. name: string;
  110173. shader: string;
  110174. };
  110175. }
  110176. declare module BABYLON {
  110177. /**
  110178. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  110179. * input texture to perform effects such as edge detection or sharpening
  110180. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110181. */
  110182. export class ConvolutionPostProcess extends PostProcess {
  110183. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110184. kernel: number[];
  110185. /**
  110186. * Creates a new instance ConvolutionPostProcess
  110187. * @param name The name of the effect.
  110188. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  110189. * @param options The required width/height ratio to downsize to before computing the render pass.
  110190. * @param camera The camera to apply the render pass to.
  110191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110192. * @param engine The engine which the post process will be applied. (default: current engine)
  110193. * @param reusable If the post process can be reused on the same frame. (default: false)
  110194. * @param textureType Type of textures used when performing the post process. (default: 0)
  110195. */
  110196. constructor(name: string,
  110197. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110198. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110199. /**
  110200. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110201. */
  110202. static EdgeDetect0Kernel: number[];
  110203. /**
  110204. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110205. */
  110206. static EdgeDetect1Kernel: number[];
  110207. /**
  110208. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110209. */
  110210. static EdgeDetect2Kernel: number[];
  110211. /**
  110212. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110213. */
  110214. static SharpenKernel: number[];
  110215. /**
  110216. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110217. */
  110218. static EmbossKernel: number[];
  110219. /**
  110220. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  110221. */
  110222. static GaussianKernel: number[];
  110223. }
  110224. }
  110225. declare module BABYLON {
  110226. /**
  110227. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  110228. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  110229. * based on samples that have a large difference in distance than the center pixel.
  110230. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  110231. */
  110232. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  110233. direction: Vector2;
  110234. /**
  110235. * Creates a new instance CircleOfConfusionPostProcess
  110236. * @param name The name of the effect.
  110237. * @param scene The scene the effect belongs to.
  110238. * @param direction The direction the blur should be applied.
  110239. * @param kernel The size of the kernel used to blur.
  110240. * @param options The required width/height ratio to downsize to before computing the render pass.
  110241. * @param camera The camera to apply the render pass to.
  110242. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  110243. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  110244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110245. * @param engine The engine which the post process will be applied. (default: current engine)
  110246. * @param reusable If the post process can be reused on the same frame. (default: false)
  110247. * @param textureType Type of textures used when performing the post process. (default: 0)
  110248. * @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)
  110249. */
  110250. 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);
  110251. }
  110252. }
  110253. declare module BABYLON {
  110254. /** @hidden */
  110255. export var depthOfFieldMergePixelShader: {
  110256. name: string;
  110257. shader: string;
  110258. };
  110259. }
  110260. declare module BABYLON {
  110261. /**
  110262. * Options to be set when merging outputs from the default pipeline.
  110263. */
  110264. export class DepthOfFieldMergePostProcessOptions {
  110265. /**
  110266. * The original image to merge on top of
  110267. */
  110268. originalFromInput: PostProcess;
  110269. /**
  110270. * Parameters to perform the merge of the depth of field effect
  110271. */
  110272. depthOfField?: {
  110273. circleOfConfusion: PostProcess;
  110274. blurSteps: Array<PostProcess>;
  110275. };
  110276. /**
  110277. * Parameters to perform the merge of bloom effect
  110278. */
  110279. bloom?: {
  110280. blurred: PostProcess;
  110281. weight: number;
  110282. };
  110283. }
  110284. /**
  110285. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  110286. */
  110287. export class DepthOfFieldMergePostProcess extends PostProcess {
  110288. private blurSteps;
  110289. /**
  110290. * Creates a new instance of DepthOfFieldMergePostProcess
  110291. * @param name The name of the effect.
  110292. * @param originalFromInput Post process which's input will be used for the merge.
  110293. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  110294. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  110295. * @param options The required width/height ratio to downsize to before computing the render pass.
  110296. * @param camera The camera to apply the render pass to.
  110297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110298. * @param engine The engine which the post process will be applied. (default: current engine)
  110299. * @param reusable If the post process can be reused on the same frame. (default: false)
  110300. * @param textureType Type of textures used when performing the post process. (default: 0)
  110301. * @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)
  110302. */
  110303. 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);
  110304. /**
  110305. * Updates the effect with the current post process compile time values and recompiles the shader.
  110306. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  110307. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  110308. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  110309. * @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
  110310. * @param onCompiled Called when the shader has been compiled.
  110311. * @param onError Called if there is an error when compiling a shader.
  110312. */
  110313. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  110314. }
  110315. }
  110316. declare module BABYLON {
  110317. /**
  110318. * Specifies the level of max blur that should be applied when using the depth of field effect
  110319. */
  110320. export enum DepthOfFieldEffectBlurLevel {
  110321. /**
  110322. * Subtle blur
  110323. */
  110324. Low = 0,
  110325. /**
  110326. * Medium blur
  110327. */
  110328. Medium = 1,
  110329. /**
  110330. * Large blur
  110331. */
  110332. High = 2
  110333. }
  110334. /**
  110335. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  110336. */
  110337. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  110338. private _circleOfConfusion;
  110339. /**
  110340. * @hidden Internal, blurs from high to low
  110341. */
  110342. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  110343. private _depthOfFieldBlurY;
  110344. private _dofMerge;
  110345. /**
  110346. * @hidden Internal post processes in depth of field effect
  110347. */
  110348. _effects: Array<PostProcess>;
  110349. /**
  110350. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  110351. */
  110352. focalLength: number;
  110353. /**
  110354. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110355. */
  110356. fStop: number;
  110357. /**
  110358. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110359. */
  110360. focusDistance: number;
  110361. /**
  110362. * 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.
  110363. */
  110364. lensSize: number;
  110365. /**
  110366. * Creates a new instance DepthOfFieldEffect
  110367. * @param scene The scene the effect belongs to.
  110368. * @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.
  110369. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110370. * @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)
  110371. */
  110372. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  110373. /**
  110374. * 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.
  110375. */
  110376. depthTexture: RenderTargetTexture;
  110377. /**
  110378. * Disposes each of the internal effects for a given camera.
  110379. * @param camera The camera to dispose the effect on.
  110380. */
  110381. disposeEffects(camera: Camera): void;
  110382. /**
  110383. * @hidden Internal
  110384. */
  110385. _updateEffects(): void;
  110386. /**
  110387. * Internal
  110388. * @returns if all the contained post processes are ready.
  110389. * @hidden
  110390. */
  110391. _isReady(): boolean;
  110392. }
  110393. }
  110394. declare module BABYLON {
  110395. /** @hidden */
  110396. export var displayPassPixelShader: {
  110397. name: string;
  110398. shader: string;
  110399. };
  110400. }
  110401. declare module BABYLON {
  110402. /**
  110403. * DisplayPassPostProcess which produces an output the same as it's input
  110404. */
  110405. export class DisplayPassPostProcess extends PostProcess {
  110406. /**
  110407. * Creates the DisplayPassPostProcess
  110408. * @param name The name of the effect.
  110409. * @param options The required width/height ratio to downsize to before computing the render pass.
  110410. * @param camera The camera to apply the render pass to.
  110411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110412. * @param engine The engine which the post process will be applied. (default: current engine)
  110413. * @param reusable If the post process can be reused on the same frame. (default: false)
  110414. */
  110415. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110416. }
  110417. }
  110418. declare module BABYLON {
  110419. /** @hidden */
  110420. export var filterPixelShader: {
  110421. name: string;
  110422. shader: string;
  110423. };
  110424. }
  110425. declare module BABYLON {
  110426. /**
  110427. * Applies a kernel filter to the image
  110428. */
  110429. export class FilterPostProcess extends PostProcess {
  110430. /** The matrix to be applied to the image */
  110431. kernelMatrix: Matrix;
  110432. /**
  110433. *
  110434. * @param name The name of the effect.
  110435. * @param kernelMatrix The matrix to be applied to the image
  110436. * @param options The required width/height ratio to downsize to before computing the render pass.
  110437. * @param camera The camera to apply the render pass to.
  110438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110439. * @param engine The engine which the post process will be applied. (default: current engine)
  110440. * @param reusable If the post process can be reused on the same frame. (default: false)
  110441. */
  110442. constructor(name: string,
  110443. /** The matrix to be applied to the image */
  110444. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110445. }
  110446. }
  110447. declare module BABYLON {
  110448. /** @hidden */
  110449. export var fxaaPixelShader: {
  110450. name: string;
  110451. shader: string;
  110452. };
  110453. }
  110454. declare module BABYLON {
  110455. /** @hidden */
  110456. export var fxaaVertexShader: {
  110457. name: string;
  110458. shader: string;
  110459. };
  110460. }
  110461. declare module BABYLON {
  110462. /**
  110463. * Fxaa post process
  110464. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  110465. */
  110466. export class FxaaPostProcess extends PostProcess {
  110467. /** @hidden */
  110468. texelWidth: number;
  110469. /** @hidden */
  110470. texelHeight: number;
  110471. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110472. private _getDefines;
  110473. }
  110474. }
  110475. declare module BABYLON {
  110476. /** @hidden */
  110477. export var grainPixelShader: {
  110478. name: string;
  110479. shader: string;
  110480. };
  110481. }
  110482. declare module BABYLON {
  110483. /**
  110484. * The GrainPostProcess adds noise to the image at mid luminance levels
  110485. */
  110486. export class GrainPostProcess extends PostProcess {
  110487. /**
  110488. * The intensity of the grain added (default: 30)
  110489. */
  110490. intensity: number;
  110491. /**
  110492. * If the grain should be randomized on every frame
  110493. */
  110494. animated: boolean;
  110495. /**
  110496. * Creates a new instance of @see GrainPostProcess
  110497. * @param name The name of the effect.
  110498. * @param options The required width/height ratio to downsize to before computing the render pass.
  110499. * @param camera The camera to apply the render pass to.
  110500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110501. * @param engine The engine which the post process will be applied. (default: current engine)
  110502. * @param reusable If the post process can be reused on the same frame. (default: false)
  110503. * @param textureType Type of textures used when performing the post process. (default: 0)
  110504. * @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)
  110505. */
  110506. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110507. }
  110508. }
  110509. declare module BABYLON {
  110510. /** @hidden */
  110511. export var highlightsPixelShader: {
  110512. name: string;
  110513. shader: string;
  110514. };
  110515. }
  110516. declare module BABYLON {
  110517. /**
  110518. * Extracts highlights from the image
  110519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110520. */
  110521. export class HighlightsPostProcess extends PostProcess {
  110522. /**
  110523. * Extracts highlights from the image
  110524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110525. * @param name The name of the effect.
  110526. * @param options The required width/height ratio to downsize to before computing the render pass.
  110527. * @param camera The camera to apply the render pass to.
  110528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110529. * @param engine The engine which the post process will be applied. (default: current engine)
  110530. * @param reusable If the post process can be reused on the same frame. (default: false)
  110531. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  110532. */
  110533. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110534. }
  110535. }
  110536. declare module BABYLON {
  110537. /** @hidden */
  110538. export var mrtFragmentDeclaration: {
  110539. name: string;
  110540. shader: string;
  110541. };
  110542. }
  110543. declare module BABYLON {
  110544. /** @hidden */
  110545. export var geometryPixelShader: {
  110546. name: string;
  110547. shader: string;
  110548. };
  110549. }
  110550. declare module BABYLON {
  110551. /** @hidden */
  110552. export var geometryVertexShader: {
  110553. name: string;
  110554. shader: string;
  110555. };
  110556. }
  110557. declare module BABYLON {
  110558. /**
  110559. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  110560. */
  110561. export class GeometryBufferRenderer {
  110562. /**
  110563. * Constant used to retrieve the position texture index in the G-Buffer textures array
  110564. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  110565. */
  110566. static readonly POSITION_TEXTURE_TYPE: number;
  110567. /**
  110568. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  110569. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  110570. */
  110571. static readonly VELOCITY_TEXTURE_TYPE: number;
  110572. /**
  110573. * Dictionary used to store the previous transformation matrices of each rendered mesh
  110574. * in order to compute objects velocities when enableVelocity is set to "true"
  110575. * @hidden
  110576. */
  110577. _previousTransformationMatrices: {
  110578. [index: number]: Matrix;
  110579. };
  110580. private _scene;
  110581. private _multiRenderTarget;
  110582. private _ratio;
  110583. private _enablePosition;
  110584. private _enableVelocity;
  110585. private _positionIndex;
  110586. private _velocityIndex;
  110587. protected _effect: Effect;
  110588. protected _cachedDefines: string;
  110589. /**
  110590. * Set the render list (meshes to be rendered) used in the G buffer.
  110591. */
  110592. renderList: Mesh[];
  110593. /**
  110594. * Gets wether or not G buffer are supported by the running hardware.
  110595. * This requires draw buffer supports
  110596. */
  110597. readonly isSupported: boolean;
  110598. /**
  110599. * Returns the index of the given texture type in the G-Buffer textures array
  110600. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  110601. * @returns the index of the given texture type in the G-Buffer textures array
  110602. */
  110603. getTextureIndex(textureType: number): number;
  110604. /**
  110605. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  110606. */
  110607. /**
  110608. * Sets whether or not objects positions are enabled for the G buffer.
  110609. */
  110610. enablePosition: boolean;
  110611. /**
  110612. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  110613. */
  110614. /**
  110615. * Sets wether or not objects velocities are enabled for the G buffer.
  110616. */
  110617. enableVelocity: boolean;
  110618. /**
  110619. * Gets the scene associated with the buffer.
  110620. */
  110621. readonly scene: Scene;
  110622. /**
  110623. * Gets the ratio used by the buffer during its creation.
  110624. * How big is the buffer related to the main canvas.
  110625. */
  110626. readonly ratio: number;
  110627. /** @hidden */
  110628. static _SceneComponentInitialization: (scene: Scene) => void;
  110629. /**
  110630. * Creates a new G Buffer for the scene
  110631. * @param scene The scene the buffer belongs to
  110632. * @param ratio How big is the buffer related to the main canvas.
  110633. */
  110634. constructor(scene: Scene, ratio?: number);
  110635. /**
  110636. * Checks wether everything is ready to render a submesh to the G buffer.
  110637. * @param subMesh the submesh to check readiness for
  110638. * @param useInstances is the mesh drawn using instance or not
  110639. * @returns true if ready otherwise false
  110640. */
  110641. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110642. /**
  110643. * Gets the current underlying G Buffer.
  110644. * @returns the buffer
  110645. */
  110646. getGBuffer(): MultiRenderTarget;
  110647. /**
  110648. * Gets the number of samples used to render the buffer (anti aliasing).
  110649. */
  110650. /**
  110651. * Sets the number of samples used to render the buffer (anti aliasing).
  110652. */
  110653. samples: number;
  110654. /**
  110655. * Disposes the renderer and frees up associated resources.
  110656. */
  110657. dispose(): void;
  110658. protected _createRenderTargets(): void;
  110659. }
  110660. }
  110661. declare module BABYLON {
  110662. interface Scene {
  110663. /** @hidden (Backing field) */
  110664. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110665. /**
  110666. * Gets or Sets the current geometry buffer associated to the scene.
  110667. */
  110668. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110669. /**
  110670. * Enables a GeometryBufferRender and associates it with the scene
  110671. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110672. * @returns the GeometryBufferRenderer
  110673. */
  110674. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110675. /**
  110676. * Disables the GeometryBufferRender associated with the scene
  110677. */
  110678. disableGeometryBufferRenderer(): void;
  110679. }
  110680. /**
  110681. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110682. * in several rendering techniques.
  110683. */
  110684. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110685. /**
  110686. * The component name helpful to identify the component in the list of scene components.
  110687. */
  110688. readonly name: string;
  110689. /**
  110690. * The scene the component belongs to.
  110691. */
  110692. scene: Scene;
  110693. /**
  110694. * Creates a new instance of the component for the given scene
  110695. * @param scene Defines the scene to register the component in
  110696. */
  110697. constructor(scene: Scene);
  110698. /**
  110699. * Registers the component in a given scene
  110700. */
  110701. register(): void;
  110702. /**
  110703. * Rebuilds the elements related to this component in case of
  110704. * context lost for instance.
  110705. */
  110706. rebuild(): void;
  110707. /**
  110708. * Disposes the component and the associated ressources
  110709. */
  110710. dispose(): void;
  110711. private _gatherRenderTargets;
  110712. }
  110713. }
  110714. declare module BABYLON {
  110715. /** @hidden */
  110716. export var motionBlurPixelShader: {
  110717. name: string;
  110718. shader: string;
  110719. };
  110720. }
  110721. declare module BABYLON {
  110722. /**
  110723. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  110724. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  110725. * As an example, all you have to do is to create the post-process:
  110726. * var mb = new BABYLON.MotionBlurPostProcess(
  110727. * 'mb', // The name of the effect.
  110728. * scene, // The scene containing the objects to blur according to their velocity.
  110729. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  110730. * camera // The camera to apply the render pass to.
  110731. * );
  110732. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  110733. */
  110734. export class MotionBlurPostProcess extends PostProcess {
  110735. /**
  110736. * Defines how much the image is blurred by the movement. Default value is equal to 1
  110737. */
  110738. motionStrength: number;
  110739. /**
  110740. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  110741. */
  110742. /**
  110743. * Sets the number of iterations to be used for motion blur quality
  110744. */
  110745. motionBlurSamples: number;
  110746. private _motionBlurSamples;
  110747. private _geometryBufferRenderer;
  110748. /**
  110749. * Creates a new instance MotionBlurPostProcess
  110750. * @param name The name of the effect.
  110751. * @param scene The scene containing the objects to blur according to their velocity.
  110752. * @param options The required width/height ratio to downsize to before computing the render pass.
  110753. * @param camera The camera to apply the render pass to.
  110754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110755. * @param engine The engine which the post process will be applied. (default: current engine)
  110756. * @param reusable If the post process can be reused on the same frame. (default: false)
  110757. * @param textureType Type of textures used when performing the post process. (default: 0)
  110758. * @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)
  110759. */
  110760. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110761. /**
  110762. * Disposes the post process.
  110763. * @param camera The camera to dispose the post process on.
  110764. */
  110765. dispose(camera?: Camera): void;
  110766. }
  110767. }
  110768. declare module BABYLON {
  110769. /** @hidden */
  110770. export var refractionPixelShader: {
  110771. name: string;
  110772. shader: string;
  110773. };
  110774. }
  110775. declare module BABYLON {
  110776. /**
  110777. * Post process which applies a refractin texture
  110778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110779. */
  110780. export class RefractionPostProcess extends PostProcess {
  110781. /** the base color of the refraction (used to taint the rendering) */
  110782. color: Color3;
  110783. /** simulated refraction depth */
  110784. depth: number;
  110785. /** the coefficient of the base color (0 to remove base color tainting) */
  110786. colorLevel: number;
  110787. private _refTexture;
  110788. private _ownRefractionTexture;
  110789. /**
  110790. * Gets or sets the refraction texture
  110791. * Please note that you are responsible for disposing the texture if you set it manually
  110792. */
  110793. refractionTexture: Texture;
  110794. /**
  110795. * Initializes the RefractionPostProcess
  110796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110797. * @param name The name of the effect.
  110798. * @param refractionTextureUrl Url of the refraction texture to use
  110799. * @param color the base color of the refraction (used to taint the rendering)
  110800. * @param depth simulated refraction depth
  110801. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  110802. * @param camera The camera to apply the render pass to.
  110803. * @param options The required width/height ratio to downsize to before computing the render pass.
  110804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110805. * @param engine The engine which the post process will be applied. (default: current engine)
  110806. * @param reusable If the post process can be reused on the same frame. (default: false)
  110807. */
  110808. constructor(name: string, refractionTextureUrl: string,
  110809. /** the base color of the refraction (used to taint the rendering) */
  110810. color: Color3,
  110811. /** simulated refraction depth */
  110812. depth: number,
  110813. /** the coefficient of the base color (0 to remove base color tainting) */
  110814. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110815. /**
  110816. * Disposes of the post process
  110817. * @param camera Camera to dispose post process on
  110818. */
  110819. dispose(camera: Camera): void;
  110820. }
  110821. }
  110822. declare module BABYLON {
  110823. /** @hidden */
  110824. export var sharpenPixelShader: {
  110825. name: string;
  110826. shader: string;
  110827. };
  110828. }
  110829. declare module BABYLON {
  110830. /**
  110831. * The SharpenPostProcess applies a sharpen kernel to every pixel
  110832. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110833. */
  110834. export class SharpenPostProcess extends PostProcess {
  110835. /**
  110836. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  110837. */
  110838. colorAmount: number;
  110839. /**
  110840. * How much sharpness should be applied (default: 0.3)
  110841. */
  110842. edgeAmount: number;
  110843. /**
  110844. * Creates a new instance ConvolutionPostProcess
  110845. * @param name The name of the effect.
  110846. * @param options The required width/height ratio to downsize to before computing the render pass.
  110847. * @param camera The camera to apply the render pass to.
  110848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110849. * @param engine The engine which the post process will be applied. (default: current engine)
  110850. * @param reusable If the post process can be reused on the same frame. (default: false)
  110851. * @param textureType Type of textures used when performing the post process. (default: 0)
  110852. * @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)
  110853. */
  110854. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110855. }
  110856. }
  110857. declare module BABYLON {
  110858. /**
  110859. * PostProcessRenderPipeline
  110860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110861. */
  110862. export class PostProcessRenderPipeline {
  110863. private engine;
  110864. private _renderEffects;
  110865. private _renderEffectsForIsolatedPass;
  110866. /**
  110867. * List of inspectable custom properties (used by the Inspector)
  110868. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110869. */
  110870. inspectableCustomProperties: IInspectable[];
  110871. /**
  110872. * @hidden
  110873. */
  110874. protected _cameras: Camera[];
  110875. /** @hidden */
  110876. _name: string;
  110877. /**
  110878. * Gets pipeline name
  110879. */
  110880. readonly name: string;
  110881. /**
  110882. * Initializes a PostProcessRenderPipeline
  110883. * @param engine engine to add the pipeline to
  110884. * @param name name of the pipeline
  110885. */
  110886. constructor(engine: Engine, name: string);
  110887. /**
  110888. * Gets the class name
  110889. * @returns "PostProcessRenderPipeline"
  110890. */
  110891. getClassName(): string;
  110892. /**
  110893. * If all the render effects in the pipeline are supported
  110894. */
  110895. readonly isSupported: boolean;
  110896. /**
  110897. * Adds an effect to the pipeline
  110898. * @param renderEffect the effect to add
  110899. */
  110900. addEffect(renderEffect: PostProcessRenderEffect): void;
  110901. /** @hidden */
  110902. _rebuild(): void;
  110903. /** @hidden */
  110904. _enableEffect(renderEffectName: string, cameras: Camera): void;
  110905. /** @hidden */
  110906. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  110907. /** @hidden */
  110908. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110909. /** @hidden */
  110910. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110911. /** @hidden */
  110912. _attachCameras(cameras: Camera, unique: boolean): void;
  110913. /** @hidden */
  110914. _attachCameras(cameras: Camera[], unique: boolean): void;
  110915. /** @hidden */
  110916. _detachCameras(cameras: Camera): void;
  110917. /** @hidden */
  110918. _detachCameras(cameras: Nullable<Camera[]>): void;
  110919. /** @hidden */
  110920. _update(): void;
  110921. /** @hidden */
  110922. _reset(): void;
  110923. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  110924. /**
  110925. * Disposes of the pipeline
  110926. */
  110927. dispose(): void;
  110928. }
  110929. }
  110930. declare module BABYLON {
  110931. /**
  110932. * PostProcessRenderPipelineManager class
  110933. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110934. */
  110935. export class PostProcessRenderPipelineManager {
  110936. private _renderPipelines;
  110937. /**
  110938. * Initializes a PostProcessRenderPipelineManager
  110939. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110940. */
  110941. constructor();
  110942. /**
  110943. * Gets the list of supported render pipelines
  110944. */
  110945. readonly supportedPipelines: PostProcessRenderPipeline[];
  110946. /**
  110947. * Adds a pipeline to the manager
  110948. * @param renderPipeline The pipeline to add
  110949. */
  110950. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  110951. /**
  110952. * Attaches a camera to the pipeline
  110953. * @param renderPipelineName The name of the pipeline to attach to
  110954. * @param cameras the camera to attach
  110955. * @param unique if the camera can be attached multiple times to the pipeline
  110956. */
  110957. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  110958. /**
  110959. * Detaches a camera from the pipeline
  110960. * @param renderPipelineName The name of the pipeline to detach from
  110961. * @param cameras the camera to detach
  110962. */
  110963. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  110964. /**
  110965. * Enables an effect by name on a pipeline
  110966. * @param renderPipelineName the name of the pipeline to enable the effect in
  110967. * @param renderEffectName the name of the effect to enable
  110968. * @param cameras the cameras that the effect should be enabled on
  110969. */
  110970. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110971. /**
  110972. * Disables an effect by name on a pipeline
  110973. * @param renderPipelineName the name of the pipeline to disable the effect in
  110974. * @param renderEffectName the name of the effect to disable
  110975. * @param cameras the cameras that the effect should be disabled on
  110976. */
  110977. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110978. /**
  110979. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  110980. */
  110981. update(): void;
  110982. /** @hidden */
  110983. _rebuild(): void;
  110984. /**
  110985. * Disposes of the manager and pipelines
  110986. */
  110987. dispose(): void;
  110988. }
  110989. }
  110990. declare module BABYLON {
  110991. interface Scene {
  110992. /** @hidden (Backing field) */
  110993. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110994. /**
  110995. * Gets the postprocess render pipeline manager
  110996. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110997. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110998. */
  110999. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111000. }
  111001. /**
  111002. * Defines the Render Pipeline scene component responsible to rendering pipelines
  111003. */
  111004. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  111005. /**
  111006. * The component name helpfull to identify the component in the list of scene components.
  111007. */
  111008. readonly name: string;
  111009. /**
  111010. * The scene the component belongs to.
  111011. */
  111012. scene: Scene;
  111013. /**
  111014. * Creates a new instance of the component for the given scene
  111015. * @param scene Defines the scene to register the component in
  111016. */
  111017. constructor(scene: Scene);
  111018. /**
  111019. * Registers the component in a given scene
  111020. */
  111021. register(): void;
  111022. /**
  111023. * Rebuilds the elements related to this component in case of
  111024. * context lost for instance.
  111025. */
  111026. rebuild(): void;
  111027. /**
  111028. * Disposes the component and the associated ressources
  111029. */
  111030. dispose(): void;
  111031. private _gatherRenderTargets;
  111032. }
  111033. }
  111034. declare module BABYLON {
  111035. /**
  111036. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  111037. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111038. */
  111039. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111040. private _scene;
  111041. private _camerasToBeAttached;
  111042. /**
  111043. * ID of the sharpen post process,
  111044. */
  111045. private readonly SharpenPostProcessId;
  111046. /**
  111047. * @ignore
  111048. * ID of the image processing post process;
  111049. */
  111050. readonly ImageProcessingPostProcessId: string;
  111051. /**
  111052. * @ignore
  111053. * ID of the Fast Approximate Anti-Aliasing post process;
  111054. */
  111055. readonly FxaaPostProcessId: string;
  111056. /**
  111057. * ID of the chromatic aberration post process,
  111058. */
  111059. private readonly ChromaticAberrationPostProcessId;
  111060. /**
  111061. * ID of the grain post process
  111062. */
  111063. private readonly GrainPostProcessId;
  111064. /**
  111065. * Sharpen post process which will apply a sharpen convolution to enhance edges
  111066. */
  111067. sharpen: SharpenPostProcess;
  111068. private _sharpenEffect;
  111069. private bloom;
  111070. /**
  111071. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  111072. */
  111073. depthOfField: DepthOfFieldEffect;
  111074. /**
  111075. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111076. */
  111077. fxaa: FxaaPostProcess;
  111078. /**
  111079. * Image post processing pass used to perform operations such as tone mapping or color grading.
  111080. */
  111081. imageProcessing: ImageProcessingPostProcess;
  111082. /**
  111083. * Chromatic aberration post process which will shift rgb colors in the image
  111084. */
  111085. chromaticAberration: ChromaticAberrationPostProcess;
  111086. private _chromaticAberrationEffect;
  111087. /**
  111088. * Grain post process which add noise to the image
  111089. */
  111090. grain: GrainPostProcess;
  111091. private _grainEffect;
  111092. /**
  111093. * Glow post process which adds a glow to emissive areas of the image
  111094. */
  111095. private _glowLayer;
  111096. /**
  111097. * Animations which can be used to tweak settings over a period of time
  111098. */
  111099. animations: Animation[];
  111100. private _imageProcessingConfigurationObserver;
  111101. private _sharpenEnabled;
  111102. private _bloomEnabled;
  111103. private _depthOfFieldEnabled;
  111104. private _depthOfFieldBlurLevel;
  111105. private _fxaaEnabled;
  111106. private _imageProcessingEnabled;
  111107. private _defaultPipelineTextureType;
  111108. private _bloomScale;
  111109. private _chromaticAberrationEnabled;
  111110. private _grainEnabled;
  111111. private _buildAllowed;
  111112. /**
  111113. * Gets active scene
  111114. */
  111115. readonly scene: Scene;
  111116. /**
  111117. * Enable or disable the sharpen process from the pipeline
  111118. */
  111119. sharpenEnabled: boolean;
  111120. private _resizeObserver;
  111121. private _hardwareScaleLevel;
  111122. private _bloomKernel;
  111123. /**
  111124. * Specifies the size of the bloom blur kernel, relative to the final output size
  111125. */
  111126. bloomKernel: number;
  111127. /**
  111128. * Specifies the weight of the bloom in the final rendering
  111129. */
  111130. private _bloomWeight;
  111131. /**
  111132. * Specifies the luma threshold for the area that will be blurred by the bloom
  111133. */
  111134. private _bloomThreshold;
  111135. private _hdr;
  111136. /**
  111137. * The strength of the bloom.
  111138. */
  111139. bloomWeight: number;
  111140. /**
  111141. * The strength of the bloom.
  111142. */
  111143. bloomThreshold: number;
  111144. /**
  111145. * The scale of the bloom, lower value will provide better performance.
  111146. */
  111147. bloomScale: number;
  111148. /**
  111149. * Enable or disable the bloom from the pipeline
  111150. */
  111151. bloomEnabled: boolean;
  111152. private _rebuildBloom;
  111153. /**
  111154. * If the depth of field is enabled.
  111155. */
  111156. depthOfFieldEnabled: boolean;
  111157. /**
  111158. * Blur level of the depth of field effect. (Higher blur will effect performance)
  111159. */
  111160. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  111161. /**
  111162. * If the anti aliasing is enabled.
  111163. */
  111164. fxaaEnabled: boolean;
  111165. private _samples;
  111166. /**
  111167. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111168. */
  111169. samples: number;
  111170. /**
  111171. * If image processing is enabled.
  111172. */
  111173. imageProcessingEnabled: boolean;
  111174. /**
  111175. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  111176. */
  111177. glowLayerEnabled: boolean;
  111178. /**
  111179. * Enable or disable the chromaticAberration process from the pipeline
  111180. */
  111181. chromaticAberrationEnabled: boolean;
  111182. /**
  111183. * Enable or disable the grain process from the pipeline
  111184. */
  111185. grainEnabled: boolean;
  111186. /**
  111187. * @constructor
  111188. * @param name - The rendering pipeline name (default: "")
  111189. * @param hdr - If high dynamic range textures should be used (default: true)
  111190. * @param scene - The scene linked to this pipeline (default: the last created scene)
  111191. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  111192. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  111193. */
  111194. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  111195. /**
  111196. * Get the class name
  111197. * @returns "DefaultRenderingPipeline"
  111198. */
  111199. getClassName(): string;
  111200. /**
  111201. * Force the compilation of the entire pipeline.
  111202. */
  111203. prepare(): void;
  111204. private _hasCleared;
  111205. private _prevPostProcess;
  111206. private _prevPrevPostProcess;
  111207. private _setAutoClearAndTextureSharing;
  111208. private _depthOfFieldSceneObserver;
  111209. private _buildPipeline;
  111210. private _disposePostProcesses;
  111211. /**
  111212. * Adds a camera to the pipeline
  111213. * @param camera the camera to be added
  111214. */
  111215. addCamera(camera: Camera): void;
  111216. /**
  111217. * Removes a camera from the pipeline
  111218. * @param camera the camera to remove
  111219. */
  111220. removeCamera(camera: Camera): void;
  111221. /**
  111222. * Dispose of the pipeline and stop all post processes
  111223. */
  111224. dispose(): void;
  111225. /**
  111226. * Serialize the rendering pipeline (Used when exporting)
  111227. * @returns the serialized object
  111228. */
  111229. serialize(): any;
  111230. /**
  111231. * Parse the serialized pipeline
  111232. * @param source Source pipeline.
  111233. * @param scene The scene to load the pipeline to.
  111234. * @param rootUrl The URL of the serialized pipeline.
  111235. * @returns An instantiated pipeline from the serialized object.
  111236. */
  111237. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  111238. }
  111239. }
  111240. declare module BABYLON {
  111241. /** @hidden */
  111242. export var lensHighlightsPixelShader: {
  111243. name: string;
  111244. shader: string;
  111245. };
  111246. }
  111247. declare module BABYLON {
  111248. /** @hidden */
  111249. export var depthOfFieldPixelShader: {
  111250. name: string;
  111251. shader: string;
  111252. };
  111253. }
  111254. declare module BABYLON {
  111255. /**
  111256. * BABYLON.JS Chromatic Aberration GLSL Shader
  111257. * Author: Olivier Guyot
  111258. * Separates very slightly R, G and B colors on the edges of the screen
  111259. * Inspired by Francois Tarlier & Martins Upitis
  111260. */
  111261. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  111262. /**
  111263. * @ignore
  111264. * The chromatic aberration PostProcess id in the pipeline
  111265. */
  111266. LensChromaticAberrationEffect: string;
  111267. /**
  111268. * @ignore
  111269. * The highlights enhancing PostProcess id in the pipeline
  111270. */
  111271. HighlightsEnhancingEffect: string;
  111272. /**
  111273. * @ignore
  111274. * The depth-of-field PostProcess id in the pipeline
  111275. */
  111276. LensDepthOfFieldEffect: string;
  111277. private _scene;
  111278. private _depthTexture;
  111279. private _grainTexture;
  111280. private _chromaticAberrationPostProcess;
  111281. private _highlightsPostProcess;
  111282. private _depthOfFieldPostProcess;
  111283. private _edgeBlur;
  111284. private _grainAmount;
  111285. private _chromaticAberration;
  111286. private _distortion;
  111287. private _highlightsGain;
  111288. private _highlightsThreshold;
  111289. private _dofDistance;
  111290. private _dofAperture;
  111291. private _dofDarken;
  111292. private _dofPentagon;
  111293. private _blurNoise;
  111294. /**
  111295. * @constructor
  111296. *
  111297. * Effect parameters are as follow:
  111298. * {
  111299. * chromatic_aberration: number; // from 0 to x (1 for realism)
  111300. * edge_blur: number; // from 0 to x (1 for realism)
  111301. * distortion: number; // from 0 to x (1 for realism)
  111302. * grain_amount: number; // from 0 to 1
  111303. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  111304. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  111305. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  111306. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  111307. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  111308. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  111309. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  111310. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  111311. * }
  111312. * Note: if an effect parameter is unset, effect is disabled
  111313. *
  111314. * @param name The rendering pipeline name
  111315. * @param parameters - An object containing all parameters (see above)
  111316. * @param scene The scene linked to this pipeline
  111317. * @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)
  111318. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111319. */
  111320. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  111321. /**
  111322. * Get the class name
  111323. * @returns "LensRenderingPipeline"
  111324. */
  111325. getClassName(): string;
  111326. /**
  111327. * Gets associated scene
  111328. */
  111329. readonly scene: Scene;
  111330. /**
  111331. * Gets or sets the edge blur
  111332. */
  111333. edgeBlur: number;
  111334. /**
  111335. * Gets or sets the grain amount
  111336. */
  111337. grainAmount: number;
  111338. /**
  111339. * Gets or sets the chromatic aberration amount
  111340. */
  111341. chromaticAberration: number;
  111342. /**
  111343. * Gets or sets the depth of field aperture
  111344. */
  111345. dofAperture: number;
  111346. /**
  111347. * Gets or sets the edge distortion
  111348. */
  111349. edgeDistortion: number;
  111350. /**
  111351. * Gets or sets the depth of field distortion
  111352. */
  111353. dofDistortion: number;
  111354. /**
  111355. * Gets or sets the darken out of focus amount
  111356. */
  111357. darkenOutOfFocus: number;
  111358. /**
  111359. * Gets or sets a boolean indicating if blur noise is enabled
  111360. */
  111361. blurNoise: boolean;
  111362. /**
  111363. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  111364. */
  111365. pentagonBokeh: boolean;
  111366. /**
  111367. * Gets or sets the highlight grain amount
  111368. */
  111369. highlightsGain: number;
  111370. /**
  111371. * Gets or sets the highlight threshold
  111372. */
  111373. highlightsThreshold: number;
  111374. /**
  111375. * Sets the amount of blur at the edges
  111376. * @param amount blur amount
  111377. */
  111378. setEdgeBlur(amount: number): void;
  111379. /**
  111380. * Sets edge blur to 0
  111381. */
  111382. disableEdgeBlur(): void;
  111383. /**
  111384. * Sets the amout of grain
  111385. * @param amount Amount of grain
  111386. */
  111387. setGrainAmount(amount: number): void;
  111388. /**
  111389. * Set grain amount to 0
  111390. */
  111391. disableGrain(): void;
  111392. /**
  111393. * Sets the chromatic aberration amount
  111394. * @param amount amount of chromatic aberration
  111395. */
  111396. setChromaticAberration(amount: number): void;
  111397. /**
  111398. * Sets chromatic aberration amount to 0
  111399. */
  111400. disableChromaticAberration(): void;
  111401. /**
  111402. * Sets the EdgeDistortion amount
  111403. * @param amount amount of EdgeDistortion
  111404. */
  111405. setEdgeDistortion(amount: number): void;
  111406. /**
  111407. * Sets edge distortion to 0
  111408. */
  111409. disableEdgeDistortion(): void;
  111410. /**
  111411. * Sets the FocusDistance amount
  111412. * @param amount amount of FocusDistance
  111413. */
  111414. setFocusDistance(amount: number): void;
  111415. /**
  111416. * Disables depth of field
  111417. */
  111418. disableDepthOfField(): void;
  111419. /**
  111420. * Sets the Aperture amount
  111421. * @param amount amount of Aperture
  111422. */
  111423. setAperture(amount: number): void;
  111424. /**
  111425. * Sets the DarkenOutOfFocus amount
  111426. * @param amount amount of DarkenOutOfFocus
  111427. */
  111428. setDarkenOutOfFocus(amount: number): void;
  111429. private _pentagonBokehIsEnabled;
  111430. /**
  111431. * Creates a pentagon bokeh effect
  111432. */
  111433. enablePentagonBokeh(): void;
  111434. /**
  111435. * Disables the pentagon bokeh effect
  111436. */
  111437. disablePentagonBokeh(): void;
  111438. /**
  111439. * Enables noise blur
  111440. */
  111441. enableNoiseBlur(): void;
  111442. /**
  111443. * Disables noise blur
  111444. */
  111445. disableNoiseBlur(): void;
  111446. /**
  111447. * Sets the HighlightsGain amount
  111448. * @param amount amount of HighlightsGain
  111449. */
  111450. setHighlightsGain(amount: number): void;
  111451. /**
  111452. * Sets the HighlightsThreshold amount
  111453. * @param amount amount of HighlightsThreshold
  111454. */
  111455. setHighlightsThreshold(amount: number): void;
  111456. /**
  111457. * Disables highlights
  111458. */
  111459. disableHighlights(): void;
  111460. /**
  111461. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  111462. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  111463. */
  111464. dispose(disableDepthRender?: boolean): void;
  111465. private _createChromaticAberrationPostProcess;
  111466. private _createHighlightsPostProcess;
  111467. private _createDepthOfFieldPostProcess;
  111468. private _createGrainTexture;
  111469. }
  111470. }
  111471. declare module BABYLON {
  111472. /** @hidden */
  111473. export var ssao2PixelShader: {
  111474. name: string;
  111475. shader: string;
  111476. };
  111477. }
  111478. declare module BABYLON {
  111479. /** @hidden */
  111480. export var ssaoCombinePixelShader: {
  111481. name: string;
  111482. shader: string;
  111483. };
  111484. }
  111485. declare module BABYLON {
  111486. /**
  111487. * Render pipeline to produce ssao effect
  111488. */
  111489. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  111490. /**
  111491. * @ignore
  111492. * The PassPostProcess id in the pipeline that contains the original scene color
  111493. */
  111494. SSAOOriginalSceneColorEffect: string;
  111495. /**
  111496. * @ignore
  111497. * The SSAO PostProcess id in the pipeline
  111498. */
  111499. SSAORenderEffect: string;
  111500. /**
  111501. * @ignore
  111502. * The horizontal blur PostProcess id in the pipeline
  111503. */
  111504. SSAOBlurHRenderEffect: string;
  111505. /**
  111506. * @ignore
  111507. * The vertical blur PostProcess id in the pipeline
  111508. */
  111509. SSAOBlurVRenderEffect: string;
  111510. /**
  111511. * @ignore
  111512. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111513. */
  111514. SSAOCombineRenderEffect: string;
  111515. /**
  111516. * The output strength of the SSAO post-process. Default value is 1.0.
  111517. */
  111518. totalStrength: number;
  111519. /**
  111520. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  111521. */
  111522. maxZ: number;
  111523. /**
  111524. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  111525. */
  111526. minZAspect: number;
  111527. private _samples;
  111528. /**
  111529. * Number of samples used for the SSAO calculations. Default value is 8
  111530. */
  111531. samples: number;
  111532. private _textureSamples;
  111533. /**
  111534. * Number of samples to use for antialiasing
  111535. */
  111536. textureSamples: number;
  111537. /**
  111538. * Ratio object used for SSAO ratio and blur ratio
  111539. */
  111540. private _ratio;
  111541. /**
  111542. * Dynamically generated sphere sampler.
  111543. */
  111544. private _sampleSphere;
  111545. /**
  111546. * Blur filter offsets
  111547. */
  111548. private _samplerOffsets;
  111549. private _expensiveBlur;
  111550. /**
  111551. * If bilateral blur should be used
  111552. */
  111553. expensiveBlur: boolean;
  111554. /**
  111555. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  111556. */
  111557. radius: number;
  111558. /**
  111559. * The base color of the SSAO post-process
  111560. * The final result is "base + ssao" between [0, 1]
  111561. */
  111562. base: number;
  111563. /**
  111564. * Support test.
  111565. */
  111566. static readonly IsSupported: boolean;
  111567. private _scene;
  111568. private _depthTexture;
  111569. private _normalTexture;
  111570. private _randomTexture;
  111571. private _originalColorPostProcess;
  111572. private _ssaoPostProcess;
  111573. private _blurHPostProcess;
  111574. private _blurVPostProcess;
  111575. private _ssaoCombinePostProcess;
  111576. private _firstUpdate;
  111577. /**
  111578. * Gets active scene
  111579. */
  111580. readonly scene: Scene;
  111581. /**
  111582. * @constructor
  111583. * @param name The rendering pipeline name
  111584. * @param scene The scene linked to this pipeline
  111585. * @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 }
  111586. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111587. */
  111588. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111589. /**
  111590. * Get the class name
  111591. * @returns "SSAO2RenderingPipeline"
  111592. */
  111593. getClassName(): string;
  111594. /**
  111595. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111596. */
  111597. dispose(disableGeometryBufferRenderer?: boolean): void;
  111598. private _createBlurPostProcess;
  111599. /** @hidden */
  111600. _rebuild(): void;
  111601. private _bits;
  111602. private _radicalInverse_VdC;
  111603. private _hammersley;
  111604. private _hemisphereSample_uniform;
  111605. private _generateHemisphere;
  111606. private _createSSAOPostProcess;
  111607. private _createSSAOCombinePostProcess;
  111608. private _createRandomTexture;
  111609. /**
  111610. * Serialize the rendering pipeline (Used when exporting)
  111611. * @returns the serialized object
  111612. */
  111613. serialize(): any;
  111614. /**
  111615. * Parse the serialized pipeline
  111616. * @param source Source pipeline.
  111617. * @param scene The scene to load the pipeline to.
  111618. * @param rootUrl The URL of the serialized pipeline.
  111619. * @returns An instantiated pipeline from the serialized object.
  111620. */
  111621. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  111622. }
  111623. }
  111624. declare module BABYLON {
  111625. /** @hidden */
  111626. export var ssaoPixelShader: {
  111627. name: string;
  111628. shader: string;
  111629. };
  111630. }
  111631. declare module BABYLON {
  111632. /**
  111633. * Render pipeline to produce ssao effect
  111634. */
  111635. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  111636. /**
  111637. * @ignore
  111638. * The PassPostProcess id in the pipeline that contains the original scene color
  111639. */
  111640. SSAOOriginalSceneColorEffect: string;
  111641. /**
  111642. * @ignore
  111643. * The SSAO PostProcess id in the pipeline
  111644. */
  111645. SSAORenderEffect: string;
  111646. /**
  111647. * @ignore
  111648. * The horizontal blur PostProcess id in the pipeline
  111649. */
  111650. SSAOBlurHRenderEffect: string;
  111651. /**
  111652. * @ignore
  111653. * The vertical blur PostProcess id in the pipeline
  111654. */
  111655. SSAOBlurVRenderEffect: string;
  111656. /**
  111657. * @ignore
  111658. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111659. */
  111660. SSAOCombineRenderEffect: string;
  111661. /**
  111662. * The output strength of the SSAO post-process. Default value is 1.0.
  111663. */
  111664. totalStrength: number;
  111665. /**
  111666. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  111667. */
  111668. radius: number;
  111669. /**
  111670. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  111671. * Must not be equal to fallOff and superior to fallOff.
  111672. * Default value is 0.0075
  111673. */
  111674. area: number;
  111675. /**
  111676. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  111677. * Must not be equal to area and inferior to area.
  111678. * Default value is 0.000001
  111679. */
  111680. fallOff: number;
  111681. /**
  111682. * The base color of the SSAO post-process
  111683. * The final result is "base + ssao" between [0, 1]
  111684. */
  111685. base: number;
  111686. private _scene;
  111687. private _depthTexture;
  111688. private _randomTexture;
  111689. private _originalColorPostProcess;
  111690. private _ssaoPostProcess;
  111691. private _blurHPostProcess;
  111692. private _blurVPostProcess;
  111693. private _ssaoCombinePostProcess;
  111694. private _firstUpdate;
  111695. /**
  111696. * Gets active scene
  111697. */
  111698. readonly scene: Scene;
  111699. /**
  111700. * @constructor
  111701. * @param name - The rendering pipeline name
  111702. * @param scene - The scene linked to this pipeline
  111703. * @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 }
  111704. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  111705. */
  111706. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111707. /**
  111708. * Get the class name
  111709. * @returns "SSAORenderingPipeline"
  111710. */
  111711. getClassName(): string;
  111712. /**
  111713. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111714. */
  111715. dispose(disableDepthRender?: boolean): void;
  111716. private _createBlurPostProcess;
  111717. /** @hidden */
  111718. _rebuild(): void;
  111719. private _createSSAOPostProcess;
  111720. private _createSSAOCombinePostProcess;
  111721. private _createRandomTexture;
  111722. }
  111723. }
  111724. declare module BABYLON {
  111725. /** @hidden */
  111726. export var standardPixelShader: {
  111727. name: string;
  111728. shader: string;
  111729. };
  111730. }
  111731. declare module BABYLON {
  111732. /**
  111733. * Standard rendering pipeline
  111734. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111735. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  111736. */
  111737. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111738. /**
  111739. * Public members
  111740. */
  111741. /**
  111742. * Post-process which contains the original scene color before the pipeline applies all the effects
  111743. */
  111744. originalPostProcess: Nullable<PostProcess>;
  111745. /**
  111746. * Post-process used to down scale an image x4
  111747. */
  111748. downSampleX4PostProcess: Nullable<PostProcess>;
  111749. /**
  111750. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  111751. */
  111752. brightPassPostProcess: Nullable<PostProcess>;
  111753. /**
  111754. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  111755. */
  111756. blurHPostProcesses: PostProcess[];
  111757. /**
  111758. * Post-process array storing all the vertical blur post-processes used by the pipeline
  111759. */
  111760. blurVPostProcesses: PostProcess[];
  111761. /**
  111762. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  111763. */
  111764. textureAdderPostProcess: Nullable<PostProcess>;
  111765. /**
  111766. * Post-process used to create volumetric lighting effect
  111767. */
  111768. volumetricLightPostProcess: Nullable<PostProcess>;
  111769. /**
  111770. * Post-process used to smooth the previous volumetric light post-process on the X axis
  111771. */
  111772. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  111773. /**
  111774. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  111775. */
  111776. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  111777. /**
  111778. * Post-process used to merge the volumetric light effect and the real scene color
  111779. */
  111780. volumetricLightMergePostProces: Nullable<PostProcess>;
  111781. /**
  111782. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  111783. */
  111784. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  111785. /**
  111786. * Base post-process used to calculate the average luminance of the final image for HDR
  111787. */
  111788. luminancePostProcess: Nullable<PostProcess>;
  111789. /**
  111790. * Post-processes used to create down sample post-processes in order to get
  111791. * the average luminance of the final image for HDR
  111792. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  111793. */
  111794. luminanceDownSamplePostProcesses: PostProcess[];
  111795. /**
  111796. * Post-process used to create a HDR effect (light adaptation)
  111797. */
  111798. hdrPostProcess: Nullable<PostProcess>;
  111799. /**
  111800. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  111801. */
  111802. textureAdderFinalPostProcess: Nullable<PostProcess>;
  111803. /**
  111804. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  111805. */
  111806. lensFlareFinalPostProcess: Nullable<PostProcess>;
  111807. /**
  111808. * Post-process used to merge the final HDR post-process and the real scene color
  111809. */
  111810. hdrFinalPostProcess: Nullable<PostProcess>;
  111811. /**
  111812. * Post-process used to create a lens flare effect
  111813. */
  111814. lensFlarePostProcess: Nullable<PostProcess>;
  111815. /**
  111816. * Post-process that merges the result of the lens flare post-process and the real scene color
  111817. */
  111818. lensFlareComposePostProcess: Nullable<PostProcess>;
  111819. /**
  111820. * Post-process used to create a motion blur effect
  111821. */
  111822. motionBlurPostProcess: Nullable<PostProcess>;
  111823. /**
  111824. * Post-process used to create a depth of field effect
  111825. */
  111826. depthOfFieldPostProcess: Nullable<PostProcess>;
  111827. /**
  111828. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111829. */
  111830. fxaaPostProcess: Nullable<FxaaPostProcess>;
  111831. /**
  111832. * Represents the brightness threshold in order to configure the illuminated surfaces
  111833. */
  111834. brightThreshold: number;
  111835. /**
  111836. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  111837. */
  111838. blurWidth: number;
  111839. /**
  111840. * Sets if the blur for highlighted surfaces must be only horizontal
  111841. */
  111842. horizontalBlur: boolean;
  111843. /**
  111844. * Sets the overall exposure used by the pipeline
  111845. */
  111846. exposure: number;
  111847. /**
  111848. * Texture used typically to simulate "dirty" on camera lens
  111849. */
  111850. lensTexture: Nullable<Texture>;
  111851. /**
  111852. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  111853. */
  111854. volumetricLightCoefficient: number;
  111855. /**
  111856. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  111857. */
  111858. volumetricLightPower: number;
  111859. /**
  111860. * Used the set the blur intensity to smooth the volumetric lights
  111861. */
  111862. volumetricLightBlurScale: number;
  111863. /**
  111864. * Light (spot or directional) used to generate the volumetric lights rays
  111865. * The source light must have a shadow generate so the pipeline can get its
  111866. * depth map
  111867. */
  111868. sourceLight: Nullable<SpotLight | DirectionalLight>;
  111869. /**
  111870. * For eye adaptation, represents the minimum luminance the eye can see
  111871. */
  111872. hdrMinimumLuminance: number;
  111873. /**
  111874. * For eye adaptation, represents the decrease luminance speed
  111875. */
  111876. hdrDecreaseRate: number;
  111877. /**
  111878. * For eye adaptation, represents the increase luminance speed
  111879. */
  111880. hdrIncreaseRate: number;
  111881. /**
  111882. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  111883. */
  111884. lensColorTexture: Nullable<Texture>;
  111885. /**
  111886. * The overall strengh for the lens flare effect
  111887. */
  111888. lensFlareStrength: number;
  111889. /**
  111890. * Dispersion coefficient for lens flare ghosts
  111891. */
  111892. lensFlareGhostDispersal: number;
  111893. /**
  111894. * Main lens flare halo width
  111895. */
  111896. lensFlareHaloWidth: number;
  111897. /**
  111898. * Based on the lens distortion effect, defines how much the lens flare result
  111899. * is distorted
  111900. */
  111901. lensFlareDistortionStrength: number;
  111902. /**
  111903. * Lens star texture must be used to simulate rays on the flares and is available
  111904. * in the documentation
  111905. */
  111906. lensStarTexture: Nullable<Texture>;
  111907. /**
  111908. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  111909. * flare effect by taking account of the dirt texture
  111910. */
  111911. lensFlareDirtTexture: Nullable<Texture>;
  111912. /**
  111913. * Represents the focal length for the depth of field effect
  111914. */
  111915. depthOfFieldDistance: number;
  111916. /**
  111917. * Represents the blur intensity for the blurred part of the depth of field effect
  111918. */
  111919. depthOfFieldBlurWidth: number;
  111920. /**
  111921. * For motion blur, defines how much the image is blurred by the movement
  111922. */
  111923. motionStrength: number;
  111924. /**
  111925. * List of animations for the pipeline (IAnimatable implementation)
  111926. */
  111927. animations: Animation[];
  111928. /**
  111929. * Private members
  111930. */
  111931. private _scene;
  111932. private _currentDepthOfFieldSource;
  111933. private _basePostProcess;
  111934. private _hdrCurrentLuminance;
  111935. private _floatTextureType;
  111936. private _ratio;
  111937. private _bloomEnabled;
  111938. private _depthOfFieldEnabled;
  111939. private _vlsEnabled;
  111940. private _lensFlareEnabled;
  111941. private _hdrEnabled;
  111942. private _motionBlurEnabled;
  111943. private _fxaaEnabled;
  111944. private _motionBlurSamples;
  111945. private _volumetricLightStepsCount;
  111946. private _samples;
  111947. /**
  111948. * @ignore
  111949. * Specifies if the bloom pipeline is enabled
  111950. */
  111951. BloomEnabled: boolean;
  111952. /**
  111953. * @ignore
  111954. * Specifies if the depth of field pipeline is enabed
  111955. */
  111956. DepthOfFieldEnabled: boolean;
  111957. /**
  111958. * @ignore
  111959. * Specifies if the lens flare pipeline is enabed
  111960. */
  111961. LensFlareEnabled: boolean;
  111962. /**
  111963. * @ignore
  111964. * Specifies if the HDR pipeline is enabled
  111965. */
  111966. HDREnabled: boolean;
  111967. /**
  111968. * @ignore
  111969. * Specifies if the volumetric lights scattering effect is enabled
  111970. */
  111971. VLSEnabled: boolean;
  111972. /**
  111973. * @ignore
  111974. * Specifies if the motion blur effect is enabled
  111975. */
  111976. MotionBlurEnabled: boolean;
  111977. /**
  111978. * Specifies if anti-aliasing is enabled
  111979. */
  111980. fxaaEnabled: boolean;
  111981. /**
  111982. * Specifies the number of steps used to calculate the volumetric lights
  111983. * Typically in interval [50, 200]
  111984. */
  111985. volumetricLightStepsCount: number;
  111986. /**
  111987. * Specifies the number of samples used for the motion blur effect
  111988. * Typically in interval [16, 64]
  111989. */
  111990. motionBlurSamples: number;
  111991. /**
  111992. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111993. */
  111994. samples: number;
  111995. /**
  111996. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111997. * @constructor
  111998. * @param name The rendering pipeline name
  111999. * @param scene The scene linked to this pipeline
  112000. * @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)
  112001. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  112002. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112003. */
  112004. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  112005. private _buildPipeline;
  112006. private _createDownSampleX4PostProcess;
  112007. private _createBrightPassPostProcess;
  112008. private _createBlurPostProcesses;
  112009. private _createTextureAdderPostProcess;
  112010. private _createVolumetricLightPostProcess;
  112011. private _createLuminancePostProcesses;
  112012. private _createHdrPostProcess;
  112013. private _createLensFlarePostProcess;
  112014. private _createDepthOfFieldPostProcess;
  112015. private _createMotionBlurPostProcess;
  112016. private _getDepthTexture;
  112017. private _disposePostProcesses;
  112018. /**
  112019. * Dispose of the pipeline and stop all post processes
  112020. */
  112021. dispose(): void;
  112022. /**
  112023. * Serialize the rendering pipeline (Used when exporting)
  112024. * @returns the serialized object
  112025. */
  112026. serialize(): any;
  112027. /**
  112028. * Parse the serialized pipeline
  112029. * @param source Source pipeline.
  112030. * @param scene The scene to load the pipeline to.
  112031. * @param rootUrl The URL of the serialized pipeline.
  112032. * @returns An instantiated pipeline from the serialized object.
  112033. */
  112034. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  112035. /**
  112036. * Luminance steps
  112037. */
  112038. static LuminanceSteps: number;
  112039. }
  112040. }
  112041. declare module BABYLON {
  112042. /** @hidden */
  112043. export var tonemapPixelShader: {
  112044. name: string;
  112045. shader: string;
  112046. };
  112047. }
  112048. declare module BABYLON {
  112049. /** Defines operator used for tonemapping */
  112050. export enum TonemappingOperator {
  112051. /** Hable */
  112052. Hable = 0,
  112053. /** Reinhard */
  112054. Reinhard = 1,
  112055. /** HejiDawson */
  112056. HejiDawson = 2,
  112057. /** Photographic */
  112058. Photographic = 3
  112059. }
  112060. /**
  112061. * Defines a post process to apply tone mapping
  112062. */
  112063. export class TonemapPostProcess extends PostProcess {
  112064. private _operator;
  112065. /** Defines the required exposure adjustement */
  112066. exposureAdjustment: number;
  112067. /**
  112068. * Creates a new TonemapPostProcess
  112069. * @param name defines the name of the postprocess
  112070. * @param _operator defines the operator to use
  112071. * @param exposureAdjustment defines the required exposure adjustement
  112072. * @param camera defines the camera to use (can be null)
  112073. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  112074. * @param engine defines the hosting engine (can be ignore if camera is set)
  112075. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112076. */
  112077. constructor(name: string, _operator: TonemappingOperator,
  112078. /** Defines the required exposure adjustement */
  112079. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  112080. }
  112081. }
  112082. declare module BABYLON {
  112083. /** @hidden */
  112084. export var depthVertexShader: {
  112085. name: string;
  112086. shader: string;
  112087. };
  112088. }
  112089. declare module BABYLON {
  112090. /** @hidden */
  112091. export var volumetricLightScatteringPixelShader: {
  112092. name: string;
  112093. shader: string;
  112094. };
  112095. }
  112096. declare module BABYLON {
  112097. /** @hidden */
  112098. export var volumetricLightScatteringPassPixelShader: {
  112099. name: string;
  112100. shader: string;
  112101. };
  112102. }
  112103. declare module BABYLON {
  112104. /**
  112105. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  112106. */
  112107. export class VolumetricLightScatteringPostProcess extends PostProcess {
  112108. private _volumetricLightScatteringPass;
  112109. private _volumetricLightScatteringRTT;
  112110. private _viewPort;
  112111. private _screenCoordinates;
  112112. private _cachedDefines;
  112113. /**
  112114. * If not undefined, the mesh position is computed from the attached node position
  112115. */
  112116. attachedNode: {
  112117. position: Vector3;
  112118. };
  112119. /**
  112120. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  112121. */
  112122. customMeshPosition: Vector3;
  112123. /**
  112124. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  112125. */
  112126. useCustomMeshPosition: boolean;
  112127. /**
  112128. * If the post-process should inverse the light scattering direction
  112129. */
  112130. invert: boolean;
  112131. /**
  112132. * The internal mesh used by the post-process
  112133. */
  112134. mesh: Mesh;
  112135. /**
  112136. * @hidden
  112137. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  112138. */
  112139. useDiffuseColor: boolean;
  112140. /**
  112141. * Array containing the excluded meshes not rendered in the internal pass
  112142. */
  112143. excludedMeshes: AbstractMesh[];
  112144. /**
  112145. * Controls the overall intensity of the post-process
  112146. */
  112147. exposure: number;
  112148. /**
  112149. * Dissipates each sample's contribution in range [0, 1]
  112150. */
  112151. decay: number;
  112152. /**
  112153. * Controls the overall intensity of each sample
  112154. */
  112155. weight: number;
  112156. /**
  112157. * Controls the density of each sample
  112158. */
  112159. density: number;
  112160. /**
  112161. * @constructor
  112162. * @param name The post-process name
  112163. * @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)
  112164. * @param camera The camera that the post-process will be attached to
  112165. * @param mesh The mesh used to create the light scattering
  112166. * @param samples The post-process quality, default 100
  112167. * @param samplingModeThe post-process filtering mode
  112168. * @param engine The babylon engine
  112169. * @param reusable If the post-process is reusable
  112170. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  112171. */
  112172. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  112173. /**
  112174. * Returns the string "VolumetricLightScatteringPostProcess"
  112175. * @returns "VolumetricLightScatteringPostProcess"
  112176. */
  112177. getClassName(): string;
  112178. private _isReady;
  112179. /**
  112180. * Sets the new light position for light scattering effect
  112181. * @param position The new custom light position
  112182. */
  112183. setCustomMeshPosition(position: Vector3): void;
  112184. /**
  112185. * Returns the light position for light scattering effect
  112186. * @return Vector3 The custom light position
  112187. */
  112188. getCustomMeshPosition(): Vector3;
  112189. /**
  112190. * Disposes the internal assets and detaches the post-process from the camera
  112191. */
  112192. dispose(camera: Camera): void;
  112193. /**
  112194. * Returns the render target texture used by the post-process
  112195. * @return the render target texture used by the post-process
  112196. */
  112197. getPass(): RenderTargetTexture;
  112198. private _meshExcluded;
  112199. private _createPass;
  112200. private _updateMeshScreenCoordinates;
  112201. /**
  112202. * Creates a default mesh for the Volumeric Light Scattering post-process
  112203. * @param name The mesh name
  112204. * @param scene The scene where to create the mesh
  112205. * @return the default mesh
  112206. */
  112207. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  112208. }
  112209. }
  112210. declare module BABYLON {
  112211. interface Scene {
  112212. /** @hidden (Backing field) */
  112213. _boundingBoxRenderer: BoundingBoxRenderer;
  112214. /** @hidden (Backing field) */
  112215. _forceShowBoundingBoxes: boolean;
  112216. /**
  112217. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  112218. */
  112219. forceShowBoundingBoxes: boolean;
  112220. /**
  112221. * Gets the bounding box renderer associated with the scene
  112222. * @returns a BoundingBoxRenderer
  112223. */
  112224. getBoundingBoxRenderer(): BoundingBoxRenderer;
  112225. }
  112226. interface AbstractMesh {
  112227. /** @hidden (Backing field) */
  112228. _showBoundingBox: boolean;
  112229. /**
  112230. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  112231. */
  112232. showBoundingBox: boolean;
  112233. }
  112234. /**
  112235. * Component responsible of rendering the bounding box of the meshes in a scene.
  112236. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  112237. */
  112238. export class BoundingBoxRenderer implements ISceneComponent {
  112239. /**
  112240. * The component name helpfull to identify the component in the list of scene components.
  112241. */
  112242. readonly name: string;
  112243. /**
  112244. * The scene the component belongs to.
  112245. */
  112246. scene: Scene;
  112247. /**
  112248. * Color of the bounding box lines placed in front of an object
  112249. */
  112250. frontColor: Color3;
  112251. /**
  112252. * Color of the bounding box lines placed behind an object
  112253. */
  112254. backColor: Color3;
  112255. /**
  112256. * Defines if the renderer should show the back lines or not
  112257. */
  112258. showBackLines: boolean;
  112259. /**
  112260. * @hidden
  112261. */
  112262. renderList: SmartArray<BoundingBox>;
  112263. private _colorShader;
  112264. private _vertexBuffers;
  112265. private _indexBuffer;
  112266. /**
  112267. * Instantiates a new bounding box renderer in a scene.
  112268. * @param scene the scene the renderer renders in
  112269. */
  112270. constructor(scene: Scene);
  112271. /**
  112272. * Registers the component in a given scene
  112273. */
  112274. register(): void;
  112275. private _evaluateSubMesh;
  112276. private _activeMesh;
  112277. private _prepareRessources;
  112278. private _createIndexBuffer;
  112279. /**
  112280. * Rebuilds the elements related to this component in case of
  112281. * context lost for instance.
  112282. */
  112283. rebuild(): void;
  112284. /**
  112285. * @hidden
  112286. */
  112287. reset(): void;
  112288. /**
  112289. * Render the bounding boxes of a specific rendering group
  112290. * @param renderingGroupId defines the rendering group to render
  112291. */
  112292. render(renderingGroupId: number): void;
  112293. /**
  112294. * In case of occlusion queries, we can render the occlusion bounding box through this method
  112295. * @param mesh Define the mesh to render the occlusion bounding box for
  112296. */
  112297. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  112298. /**
  112299. * Dispose and release the resources attached to this renderer.
  112300. */
  112301. dispose(): void;
  112302. }
  112303. }
  112304. declare module BABYLON {
  112305. /** @hidden */
  112306. export var depthPixelShader: {
  112307. name: string;
  112308. shader: string;
  112309. };
  112310. }
  112311. declare module BABYLON {
  112312. /**
  112313. * This represents a depth renderer in Babylon.
  112314. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  112315. */
  112316. export class DepthRenderer {
  112317. private _scene;
  112318. private _depthMap;
  112319. private _effect;
  112320. private _cachedDefines;
  112321. private _camera;
  112322. /**
  112323. * Specifiess that the depth renderer will only be used within
  112324. * the camera it is created for.
  112325. * This can help forcing its rendering during the camera processing.
  112326. */
  112327. useOnlyInActiveCamera: boolean;
  112328. /** @hidden */
  112329. static _SceneComponentInitialization: (scene: Scene) => void;
  112330. /**
  112331. * Instantiates a depth renderer
  112332. * @param scene The scene the renderer belongs to
  112333. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  112334. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  112335. */
  112336. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  112337. /**
  112338. * Creates the depth rendering effect and checks if the effect is ready.
  112339. * @param subMesh The submesh to be used to render the depth map of
  112340. * @param useInstances If multiple world instances should be used
  112341. * @returns if the depth renderer is ready to render the depth map
  112342. */
  112343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112344. /**
  112345. * Gets the texture which the depth map will be written to.
  112346. * @returns The depth map texture
  112347. */
  112348. getDepthMap(): RenderTargetTexture;
  112349. /**
  112350. * Disposes of the depth renderer.
  112351. */
  112352. dispose(): void;
  112353. }
  112354. }
  112355. declare module BABYLON {
  112356. interface Scene {
  112357. /** @hidden (Backing field) */
  112358. _depthRenderer: {
  112359. [id: string]: DepthRenderer;
  112360. };
  112361. /**
  112362. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  112363. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  112364. * @returns the created depth renderer
  112365. */
  112366. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  112367. /**
  112368. * Disables a depth renderer for a given camera
  112369. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  112370. */
  112371. disableDepthRenderer(camera?: Nullable<Camera>): void;
  112372. }
  112373. /**
  112374. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  112375. * in several rendering techniques.
  112376. */
  112377. export class DepthRendererSceneComponent implements ISceneComponent {
  112378. /**
  112379. * The component name helpfull to identify the component in the list of scene components.
  112380. */
  112381. readonly name: string;
  112382. /**
  112383. * The scene the component belongs to.
  112384. */
  112385. scene: Scene;
  112386. /**
  112387. * Creates a new instance of the component for the given scene
  112388. * @param scene Defines the scene to register the component in
  112389. */
  112390. constructor(scene: Scene);
  112391. /**
  112392. * Registers the component in a given scene
  112393. */
  112394. register(): void;
  112395. /**
  112396. * Rebuilds the elements related to this component in case of
  112397. * context lost for instance.
  112398. */
  112399. rebuild(): void;
  112400. /**
  112401. * Disposes the component and the associated ressources
  112402. */
  112403. dispose(): void;
  112404. private _gatherRenderTargets;
  112405. private _gatherActiveCameraRenderTargets;
  112406. }
  112407. }
  112408. declare module BABYLON {
  112409. /** @hidden */
  112410. export var outlinePixelShader: {
  112411. name: string;
  112412. shader: string;
  112413. };
  112414. }
  112415. declare module BABYLON {
  112416. /** @hidden */
  112417. export var outlineVertexShader: {
  112418. name: string;
  112419. shader: string;
  112420. };
  112421. }
  112422. declare module BABYLON {
  112423. interface Scene {
  112424. /** @hidden */
  112425. _outlineRenderer: OutlineRenderer;
  112426. /**
  112427. * Gets the outline renderer associated with the scene
  112428. * @returns a OutlineRenderer
  112429. */
  112430. getOutlineRenderer(): OutlineRenderer;
  112431. }
  112432. interface AbstractMesh {
  112433. /** @hidden (Backing field) */
  112434. _renderOutline: boolean;
  112435. /**
  112436. * Gets or sets a boolean indicating if the outline must be rendered as well
  112437. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  112438. */
  112439. renderOutline: boolean;
  112440. /** @hidden (Backing field) */
  112441. _renderOverlay: boolean;
  112442. /**
  112443. * Gets or sets a boolean indicating if the overlay must be rendered as well
  112444. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  112445. */
  112446. renderOverlay: boolean;
  112447. }
  112448. /**
  112449. * This class is responsible to draw bothe outline/overlay of meshes.
  112450. * It should not be used directly but through the available method on mesh.
  112451. */
  112452. export class OutlineRenderer implements ISceneComponent {
  112453. /**
  112454. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  112455. */
  112456. private static _StencilReference;
  112457. /**
  112458. * The name of the component. Each component must have a unique name.
  112459. */
  112460. name: string;
  112461. /**
  112462. * The scene the component belongs to.
  112463. */
  112464. scene: Scene;
  112465. /**
  112466. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  112467. */
  112468. zOffset: number;
  112469. private _engine;
  112470. private _effect;
  112471. private _cachedDefines;
  112472. private _savedDepthWrite;
  112473. /**
  112474. * Instantiates a new outline renderer. (There could be only one per scene).
  112475. * @param scene Defines the scene it belongs to
  112476. */
  112477. constructor(scene: Scene);
  112478. /**
  112479. * Register the component to one instance of a scene.
  112480. */
  112481. register(): void;
  112482. /**
  112483. * Rebuilds the elements related to this component in case of
  112484. * context lost for instance.
  112485. */
  112486. rebuild(): void;
  112487. /**
  112488. * Disposes the component and the associated ressources.
  112489. */
  112490. dispose(): void;
  112491. /**
  112492. * Renders the outline in the canvas.
  112493. * @param subMesh Defines the sumesh to render
  112494. * @param batch Defines the batch of meshes in case of instances
  112495. * @param useOverlay Defines if the rendering is for the overlay or the outline
  112496. */
  112497. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  112498. /**
  112499. * Returns whether or not the outline renderer is ready for a given submesh.
  112500. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  112501. * @param subMesh Defines the submesh to check readyness for
  112502. * @param useInstances Defines wheter wee are trying to render instances or not
  112503. * @returns true if ready otherwise false
  112504. */
  112505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112506. private _beforeRenderingMesh;
  112507. private _afterRenderingMesh;
  112508. }
  112509. }
  112510. declare module BABYLON {
  112511. /**
  112512. * Defines the list of states available for a task inside a AssetsManager
  112513. */
  112514. export enum AssetTaskState {
  112515. /**
  112516. * Initialization
  112517. */
  112518. INIT = 0,
  112519. /**
  112520. * Running
  112521. */
  112522. RUNNING = 1,
  112523. /**
  112524. * Done
  112525. */
  112526. DONE = 2,
  112527. /**
  112528. * Error
  112529. */
  112530. ERROR = 3
  112531. }
  112532. /**
  112533. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  112534. */
  112535. export abstract class AbstractAssetTask {
  112536. /**
  112537. * Task name
  112538. */ name: string;
  112539. /**
  112540. * Callback called when the task is successful
  112541. */
  112542. onSuccess: (task: any) => void;
  112543. /**
  112544. * Callback called when the task is not successful
  112545. */
  112546. onError: (task: any, message?: string, exception?: any) => void;
  112547. /**
  112548. * Creates a new AssetsManager
  112549. * @param name defines the name of the task
  112550. */
  112551. constructor(
  112552. /**
  112553. * Task name
  112554. */ name: string);
  112555. private _isCompleted;
  112556. private _taskState;
  112557. private _errorObject;
  112558. /**
  112559. * Get if the task is completed
  112560. */
  112561. readonly isCompleted: boolean;
  112562. /**
  112563. * Gets the current state of the task
  112564. */
  112565. readonly taskState: AssetTaskState;
  112566. /**
  112567. * Gets the current error object (if task is in error)
  112568. */
  112569. readonly errorObject: {
  112570. message?: string;
  112571. exception?: any;
  112572. };
  112573. /**
  112574. * Internal only
  112575. * @hidden
  112576. */
  112577. _setErrorObject(message?: string, exception?: any): void;
  112578. /**
  112579. * Execute the current task
  112580. * @param scene defines the scene where you want your assets to be loaded
  112581. * @param onSuccess is a callback called when the task is successfully executed
  112582. * @param onError is a callback called if an error occurs
  112583. */
  112584. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112585. /**
  112586. * Execute the current task
  112587. * @param scene defines the scene where you want your assets to be loaded
  112588. * @param onSuccess is a callback called when the task is successfully executed
  112589. * @param onError is a callback called if an error occurs
  112590. */
  112591. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112592. /**
  112593. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  112594. * This can be used with failed tasks that have the reason for failure fixed.
  112595. */
  112596. reset(): void;
  112597. private onErrorCallback;
  112598. private onDoneCallback;
  112599. }
  112600. /**
  112601. * Define the interface used by progress events raised during assets loading
  112602. */
  112603. export interface IAssetsProgressEvent {
  112604. /**
  112605. * Defines the number of remaining tasks to process
  112606. */
  112607. remainingCount: number;
  112608. /**
  112609. * Defines the total number of tasks
  112610. */
  112611. totalCount: number;
  112612. /**
  112613. * Defines the task that was just processed
  112614. */
  112615. task: AbstractAssetTask;
  112616. }
  112617. /**
  112618. * Class used to share progress information about assets loading
  112619. */
  112620. export class AssetsProgressEvent implements IAssetsProgressEvent {
  112621. /**
  112622. * Defines the number of remaining tasks to process
  112623. */
  112624. remainingCount: number;
  112625. /**
  112626. * Defines the total number of tasks
  112627. */
  112628. totalCount: number;
  112629. /**
  112630. * Defines the task that was just processed
  112631. */
  112632. task: AbstractAssetTask;
  112633. /**
  112634. * Creates a AssetsProgressEvent
  112635. * @param remainingCount defines the number of remaining tasks to process
  112636. * @param totalCount defines the total number of tasks
  112637. * @param task defines the task that was just processed
  112638. */
  112639. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  112640. }
  112641. /**
  112642. * Define a task used by AssetsManager to load meshes
  112643. */
  112644. export class MeshAssetTask extends AbstractAssetTask {
  112645. /**
  112646. * Defines the name of the task
  112647. */
  112648. name: string;
  112649. /**
  112650. * Defines the list of mesh's names you want to load
  112651. */
  112652. meshesNames: any;
  112653. /**
  112654. * Defines the root url to use as a base to load your meshes and associated resources
  112655. */
  112656. rootUrl: string;
  112657. /**
  112658. * Defines the filename of the scene to load from
  112659. */
  112660. sceneFilename: string;
  112661. /**
  112662. * Gets the list of loaded meshes
  112663. */
  112664. loadedMeshes: Array<AbstractMesh>;
  112665. /**
  112666. * Gets the list of loaded particle systems
  112667. */
  112668. loadedParticleSystems: Array<IParticleSystem>;
  112669. /**
  112670. * Gets the list of loaded skeletons
  112671. */
  112672. loadedSkeletons: Array<Skeleton>;
  112673. /**
  112674. * Gets the list of loaded animation groups
  112675. */
  112676. loadedAnimationGroups: Array<AnimationGroup>;
  112677. /**
  112678. * Callback called when the task is successful
  112679. */
  112680. onSuccess: (task: MeshAssetTask) => void;
  112681. /**
  112682. * Callback called when the task is successful
  112683. */
  112684. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  112685. /**
  112686. * Creates a new MeshAssetTask
  112687. * @param name defines the name of the task
  112688. * @param meshesNames defines the list of mesh's names you want to load
  112689. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  112690. * @param sceneFilename defines the filename of the scene to load from
  112691. */
  112692. constructor(
  112693. /**
  112694. * Defines the name of the task
  112695. */
  112696. name: string,
  112697. /**
  112698. * Defines the list of mesh's names you want to load
  112699. */
  112700. meshesNames: any,
  112701. /**
  112702. * Defines the root url to use as a base to load your meshes and associated resources
  112703. */
  112704. rootUrl: string,
  112705. /**
  112706. * Defines the filename of the scene to load from
  112707. */
  112708. sceneFilename: string);
  112709. /**
  112710. * Execute the current task
  112711. * @param scene defines the scene where you want your assets to be loaded
  112712. * @param onSuccess is a callback called when the task is successfully executed
  112713. * @param onError is a callback called if an error occurs
  112714. */
  112715. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112716. }
  112717. /**
  112718. * Define a task used by AssetsManager to load text content
  112719. */
  112720. export class TextFileAssetTask extends AbstractAssetTask {
  112721. /**
  112722. * Defines the name of the task
  112723. */
  112724. name: string;
  112725. /**
  112726. * Defines the location of the file to load
  112727. */
  112728. url: string;
  112729. /**
  112730. * Gets the loaded text string
  112731. */
  112732. text: string;
  112733. /**
  112734. * Callback called when the task is successful
  112735. */
  112736. onSuccess: (task: TextFileAssetTask) => void;
  112737. /**
  112738. * Callback called when the task is successful
  112739. */
  112740. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  112741. /**
  112742. * Creates a new TextFileAssetTask object
  112743. * @param name defines the name of the task
  112744. * @param url defines the location of the file to load
  112745. */
  112746. constructor(
  112747. /**
  112748. * Defines the name of the task
  112749. */
  112750. name: string,
  112751. /**
  112752. * Defines the location of the file to load
  112753. */
  112754. url: string);
  112755. /**
  112756. * Execute the current task
  112757. * @param scene defines the scene where you want your assets to be loaded
  112758. * @param onSuccess is a callback called when the task is successfully executed
  112759. * @param onError is a callback called if an error occurs
  112760. */
  112761. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112762. }
  112763. /**
  112764. * Define a task used by AssetsManager to load binary data
  112765. */
  112766. export class BinaryFileAssetTask extends AbstractAssetTask {
  112767. /**
  112768. * Defines the name of the task
  112769. */
  112770. name: string;
  112771. /**
  112772. * Defines the location of the file to load
  112773. */
  112774. url: string;
  112775. /**
  112776. * Gets the lodaded data (as an array buffer)
  112777. */
  112778. data: ArrayBuffer;
  112779. /**
  112780. * Callback called when the task is successful
  112781. */
  112782. onSuccess: (task: BinaryFileAssetTask) => void;
  112783. /**
  112784. * Callback called when the task is successful
  112785. */
  112786. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  112787. /**
  112788. * Creates a new BinaryFileAssetTask object
  112789. * @param name defines the name of the new task
  112790. * @param url defines the location of the file to load
  112791. */
  112792. constructor(
  112793. /**
  112794. * Defines the name of the task
  112795. */
  112796. name: string,
  112797. /**
  112798. * Defines the location of the file to load
  112799. */
  112800. url: string);
  112801. /**
  112802. * Execute the current task
  112803. * @param scene defines the scene where you want your assets to be loaded
  112804. * @param onSuccess is a callback called when the task is successfully executed
  112805. * @param onError is a callback called if an error occurs
  112806. */
  112807. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112808. }
  112809. /**
  112810. * Define a task used by AssetsManager to load images
  112811. */
  112812. export class ImageAssetTask extends AbstractAssetTask {
  112813. /**
  112814. * Defines the name of the task
  112815. */
  112816. name: string;
  112817. /**
  112818. * Defines the location of the image to load
  112819. */
  112820. url: string;
  112821. /**
  112822. * Gets the loaded images
  112823. */
  112824. image: HTMLImageElement;
  112825. /**
  112826. * Callback called when the task is successful
  112827. */
  112828. onSuccess: (task: ImageAssetTask) => void;
  112829. /**
  112830. * Callback called when the task is successful
  112831. */
  112832. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  112833. /**
  112834. * Creates a new ImageAssetTask
  112835. * @param name defines the name of the task
  112836. * @param url defines the location of the image to load
  112837. */
  112838. constructor(
  112839. /**
  112840. * Defines the name of the task
  112841. */
  112842. name: string,
  112843. /**
  112844. * Defines the location of the image to load
  112845. */
  112846. url: string);
  112847. /**
  112848. * Execute the current task
  112849. * @param scene defines the scene where you want your assets to be loaded
  112850. * @param onSuccess is a callback called when the task is successfully executed
  112851. * @param onError is a callback called if an error occurs
  112852. */
  112853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112854. }
  112855. /**
  112856. * Defines the interface used by texture loading tasks
  112857. */
  112858. export interface ITextureAssetTask<TEX extends BaseTexture> {
  112859. /**
  112860. * Gets the loaded texture
  112861. */
  112862. texture: TEX;
  112863. }
  112864. /**
  112865. * Define a task used by AssetsManager to load 2D textures
  112866. */
  112867. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  112868. /**
  112869. * Defines the name of the task
  112870. */
  112871. name: string;
  112872. /**
  112873. * Defines the location of the file to load
  112874. */
  112875. url: string;
  112876. /**
  112877. * Defines if mipmap should not be generated (default is false)
  112878. */
  112879. noMipmap?: boolean | undefined;
  112880. /**
  112881. * Defines if texture must be inverted on Y axis (default is false)
  112882. */
  112883. invertY?: boolean | undefined;
  112884. /**
  112885. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112886. */
  112887. samplingMode: number;
  112888. /**
  112889. * Gets the loaded texture
  112890. */
  112891. texture: Texture;
  112892. /**
  112893. * Callback called when the task is successful
  112894. */
  112895. onSuccess: (task: TextureAssetTask) => void;
  112896. /**
  112897. * Callback called when the task is successful
  112898. */
  112899. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  112900. /**
  112901. * Creates a new TextureAssetTask object
  112902. * @param name defines the name of the task
  112903. * @param url defines the location of the file to load
  112904. * @param noMipmap defines if mipmap should not be generated (default is false)
  112905. * @param invertY defines if texture must be inverted on Y axis (default is false)
  112906. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112907. */
  112908. constructor(
  112909. /**
  112910. * Defines the name of the task
  112911. */
  112912. name: string,
  112913. /**
  112914. * Defines the location of the file to load
  112915. */
  112916. url: string,
  112917. /**
  112918. * Defines if mipmap should not be generated (default is false)
  112919. */
  112920. noMipmap?: boolean | undefined,
  112921. /**
  112922. * Defines if texture must be inverted on Y axis (default is false)
  112923. */
  112924. invertY?: boolean | undefined,
  112925. /**
  112926. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112927. */
  112928. samplingMode?: number);
  112929. /**
  112930. * Execute the current task
  112931. * @param scene defines the scene where you want your assets to be loaded
  112932. * @param onSuccess is a callback called when the task is successfully executed
  112933. * @param onError is a callback called if an error occurs
  112934. */
  112935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112936. }
  112937. /**
  112938. * Define a task used by AssetsManager to load cube textures
  112939. */
  112940. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  112941. /**
  112942. * Defines the name of the task
  112943. */
  112944. name: string;
  112945. /**
  112946. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112947. */
  112948. url: string;
  112949. /**
  112950. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112951. */
  112952. extensions?: string[] | undefined;
  112953. /**
  112954. * Defines if mipmaps should not be generated (default is false)
  112955. */
  112956. noMipmap?: boolean | undefined;
  112957. /**
  112958. * Defines the explicit list of files (undefined by default)
  112959. */
  112960. files?: string[] | undefined;
  112961. /**
  112962. * Gets the loaded texture
  112963. */
  112964. texture: CubeTexture;
  112965. /**
  112966. * Callback called when the task is successful
  112967. */
  112968. onSuccess: (task: CubeTextureAssetTask) => void;
  112969. /**
  112970. * Callback called when the task is successful
  112971. */
  112972. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  112973. /**
  112974. * Creates a new CubeTextureAssetTask
  112975. * @param name defines the name of the task
  112976. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112977. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112978. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112979. * @param files defines the explicit list of files (undefined by default)
  112980. */
  112981. constructor(
  112982. /**
  112983. * Defines the name of the task
  112984. */
  112985. name: string,
  112986. /**
  112987. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112988. */
  112989. url: string,
  112990. /**
  112991. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112992. */
  112993. extensions?: string[] | undefined,
  112994. /**
  112995. * Defines if mipmaps should not be generated (default is false)
  112996. */
  112997. noMipmap?: boolean | undefined,
  112998. /**
  112999. * Defines the explicit list of files (undefined by default)
  113000. */
  113001. files?: string[] | undefined);
  113002. /**
  113003. * Execute the current task
  113004. * @param scene defines the scene where you want your assets to be loaded
  113005. * @param onSuccess is a callback called when the task is successfully executed
  113006. * @param onError is a callback called if an error occurs
  113007. */
  113008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113009. }
  113010. /**
  113011. * Define a task used by AssetsManager to load HDR cube textures
  113012. */
  113013. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  113014. /**
  113015. * Defines the name of the task
  113016. */
  113017. name: string;
  113018. /**
  113019. * Defines the location of the file to load
  113020. */
  113021. url: string;
  113022. /**
  113023. * Defines the desired size (the more it increases the longer the generation will be)
  113024. */
  113025. size: number;
  113026. /**
  113027. * Defines if mipmaps should not be generated (default is false)
  113028. */
  113029. noMipmap: boolean;
  113030. /**
  113031. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113032. */
  113033. generateHarmonics: boolean;
  113034. /**
  113035. * 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)
  113036. */
  113037. gammaSpace: boolean;
  113038. /**
  113039. * Internal Use Only
  113040. */
  113041. reserved: boolean;
  113042. /**
  113043. * Gets the loaded texture
  113044. */
  113045. texture: HDRCubeTexture;
  113046. /**
  113047. * Callback called when the task is successful
  113048. */
  113049. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  113050. /**
  113051. * Callback called when the task is successful
  113052. */
  113053. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  113054. /**
  113055. * Creates a new HDRCubeTextureAssetTask object
  113056. * @param name defines the name of the task
  113057. * @param url defines the location of the file to load
  113058. * @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.
  113059. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113060. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113061. * @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)
  113062. * @param reserved Internal use only
  113063. */
  113064. constructor(
  113065. /**
  113066. * Defines the name of the task
  113067. */
  113068. name: string,
  113069. /**
  113070. * Defines the location of the file to load
  113071. */
  113072. url: string,
  113073. /**
  113074. * Defines the desired size (the more it increases the longer the generation will be)
  113075. */
  113076. size: number,
  113077. /**
  113078. * Defines if mipmaps should not be generated (default is false)
  113079. */
  113080. noMipmap?: boolean,
  113081. /**
  113082. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113083. */
  113084. generateHarmonics?: boolean,
  113085. /**
  113086. * 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)
  113087. */
  113088. gammaSpace?: boolean,
  113089. /**
  113090. * Internal Use Only
  113091. */
  113092. reserved?: boolean);
  113093. /**
  113094. * Execute the current task
  113095. * @param scene defines the scene where you want your assets to be loaded
  113096. * @param onSuccess is a callback called when the task is successfully executed
  113097. * @param onError is a callback called if an error occurs
  113098. */
  113099. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113100. }
  113101. /**
  113102. * This class can be used to easily import assets into a scene
  113103. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  113104. */
  113105. export class AssetsManager {
  113106. private _scene;
  113107. private _isLoading;
  113108. protected _tasks: AbstractAssetTask[];
  113109. protected _waitingTasksCount: number;
  113110. protected _totalTasksCount: number;
  113111. /**
  113112. * Callback called when all tasks are processed
  113113. */
  113114. onFinish: (tasks: AbstractAssetTask[]) => void;
  113115. /**
  113116. * Callback called when a task is successful
  113117. */
  113118. onTaskSuccess: (task: AbstractAssetTask) => void;
  113119. /**
  113120. * Callback called when a task had an error
  113121. */
  113122. onTaskError: (task: AbstractAssetTask) => void;
  113123. /**
  113124. * Callback called when a task is done (whatever the result is)
  113125. */
  113126. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  113127. /**
  113128. * Observable called when all tasks are processed
  113129. */
  113130. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  113131. /**
  113132. * Observable called when a task had an error
  113133. */
  113134. onTaskErrorObservable: Observable<AbstractAssetTask>;
  113135. /**
  113136. * Observable called when all tasks were executed
  113137. */
  113138. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  113139. /**
  113140. * Observable called when a task is done (whatever the result is)
  113141. */
  113142. onProgressObservable: Observable<IAssetsProgressEvent>;
  113143. /**
  113144. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  113145. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113146. */
  113147. useDefaultLoadingScreen: boolean;
  113148. /**
  113149. * Creates a new AssetsManager
  113150. * @param scene defines the scene to work on
  113151. */
  113152. constructor(scene: Scene);
  113153. /**
  113154. * Add a MeshAssetTask to the list of active tasks
  113155. * @param taskName defines the name of the new task
  113156. * @param meshesNames defines the name of meshes to load
  113157. * @param rootUrl defines the root url to use to locate files
  113158. * @param sceneFilename defines the filename of the scene file
  113159. * @returns a new MeshAssetTask object
  113160. */
  113161. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  113162. /**
  113163. * Add a TextFileAssetTask to the list of active tasks
  113164. * @param taskName defines the name of the new task
  113165. * @param url defines the url of the file to load
  113166. * @returns a new TextFileAssetTask object
  113167. */
  113168. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  113169. /**
  113170. * Add a BinaryFileAssetTask to the list of active tasks
  113171. * @param taskName defines the name of the new task
  113172. * @param url defines the url of the file to load
  113173. * @returns a new BinaryFileAssetTask object
  113174. */
  113175. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  113176. /**
  113177. * Add a ImageAssetTask to the list of active tasks
  113178. * @param taskName defines the name of the new task
  113179. * @param url defines the url of the file to load
  113180. * @returns a new ImageAssetTask object
  113181. */
  113182. addImageTask(taskName: string, url: string): ImageAssetTask;
  113183. /**
  113184. * Add a TextureAssetTask to the list of active tasks
  113185. * @param taskName defines the name of the new task
  113186. * @param url defines the url of the file to load
  113187. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  113188. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  113189. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113190. * @returns a new TextureAssetTask object
  113191. */
  113192. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  113193. /**
  113194. * Add a CubeTextureAssetTask to the list of active tasks
  113195. * @param taskName defines the name of the new task
  113196. * @param url defines the url of the file to load
  113197. * @param extensions defines the extension to use to load the cube map (can be null)
  113198. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  113199. * @param files defines the list of files to load (can be null)
  113200. * @returns a new CubeTextureAssetTask object
  113201. */
  113202. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  113203. /**
  113204. *
  113205. * Add a HDRCubeTextureAssetTask to the list of active tasks
  113206. * @param taskName defines the name of the new task
  113207. * @param url defines the url of the file to load
  113208. * @param size defines the size you want for the cubemap (can be null)
  113209. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  113210. * @param generateHarmonics defines if you want to automatically generate (true by default)
  113211. * @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)
  113212. * @param reserved Internal use only
  113213. * @returns a new HDRCubeTextureAssetTask object
  113214. */
  113215. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  113216. /**
  113217. * Remove a task from the assets manager.
  113218. * @param task the task to remove
  113219. */
  113220. removeTask(task: AbstractAssetTask): void;
  113221. private _decreaseWaitingTasksCount;
  113222. private _runTask;
  113223. /**
  113224. * Reset the AssetsManager and remove all tasks
  113225. * @return the current instance of the AssetsManager
  113226. */
  113227. reset(): AssetsManager;
  113228. /**
  113229. * Start the loading process
  113230. * @return the current instance of the AssetsManager
  113231. */
  113232. load(): AssetsManager;
  113233. /**
  113234. * Start the loading process as an async operation
  113235. * @return a promise returning the list of failed tasks
  113236. */
  113237. loadAsync(): Promise<void>;
  113238. }
  113239. }
  113240. declare module BABYLON {
  113241. /**
  113242. * Wrapper class for promise with external resolve and reject.
  113243. */
  113244. export class Deferred<T> {
  113245. /**
  113246. * The promise associated with this deferred object.
  113247. */
  113248. readonly promise: Promise<T>;
  113249. private _resolve;
  113250. private _reject;
  113251. /**
  113252. * The resolve method of the promise associated with this deferred object.
  113253. */
  113254. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  113255. /**
  113256. * The reject method of the promise associated with this deferred object.
  113257. */
  113258. readonly reject: (reason?: any) => void;
  113259. /**
  113260. * Constructor for this deferred object.
  113261. */
  113262. constructor();
  113263. }
  113264. }
  113265. declare module BABYLON {
  113266. /**
  113267. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  113268. */
  113269. export class MeshExploder {
  113270. private _centerMesh;
  113271. private _meshes;
  113272. private _meshesOrigins;
  113273. private _toCenterVectors;
  113274. private _scaledDirection;
  113275. private _newPosition;
  113276. private _centerPosition;
  113277. /**
  113278. * Explodes meshes from a center mesh.
  113279. * @param meshes The meshes to explode.
  113280. * @param centerMesh The mesh to be center of explosion.
  113281. */
  113282. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  113283. private _setCenterMesh;
  113284. /**
  113285. * Get class name
  113286. * @returns "MeshExploder"
  113287. */
  113288. getClassName(): string;
  113289. /**
  113290. * "Exploded meshes"
  113291. * @returns Array of meshes with the centerMesh at index 0.
  113292. */
  113293. getMeshes(): Array<Mesh>;
  113294. /**
  113295. * Explodes meshes giving a specific direction
  113296. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  113297. */
  113298. explode(direction?: number): void;
  113299. }
  113300. }
  113301. declare module BABYLON {
  113302. /**
  113303. * Class used to help managing file picking and drag'n'drop
  113304. */
  113305. export class FilesInput {
  113306. /**
  113307. * List of files ready to be loaded
  113308. */
  113309. static readonly FilesToLoad: {
  113310. [key: string]: File;
  113311. };
  113312. /**
  113313. * Callback called when a file is processed
  113314. */
  113315. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  113316. private _engine;
  113317. private _currentScene;
  113318. private _sceneLoadedCallback;
  113319. private _progressCallback;
  113320. private _additionalRenderLoopLogicCallback;
  113321. private _textureLoadingCallback;
  113322. private _startingProcessingFilesCallback;
  113323. private _onReloadCallback;
  113324. private _errorCallback;
  113325. private _elementToMonitor;
  113326. private _sceneFileToLoad;
  113327. private _filesToLoad;
  113328. /**
  113329. * Creates a new FilesInput
  113330. * @param engine defines the rendering engine
  113331. * @param scene defines the hosting scene
  113332. * @param sceneLoadedCallback callback called when scene is loaded
  113333. * @param progressCallback callback called to track progress
  113334. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  113335. * @param textureLoadingCallback callback called when a texture is loading
  113336. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  113337. * @param onReloadCallback callback called when a reload is requested
  113338. * @param errorCallback callback call if an error occurs
  113339. */
  113340. 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);
  113341. private _dragEnterHandler;
  113342. private _dragOverHandler;
  113343. private _dropHandler;
  113344. /**
  113345. * Calls this function to listen to drag'n'drop events on a specific DOM element
  113346. * @param elementToMonitor defines the DOM element to track
  113347. */
  113348. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  113349. /**
  113350. * Release all associated resources
  113351. */
  113352. dispose(): void;
  113353. private renderFunction;
  113354. private drag;
  113355. private drop;
  113356. private _traverseFolder;
  113357. private _processFiles;
  113358. /**
  113359. * Load files from a drop event
  113360. * @param event defines the drop event to use as source
  113361. */
  113362. loadFiles(event: any): void;
  113363. private _processReload;
  113364. /**
  113365. * Reload the current scene from the loaded files
  113366. */
  113367. reload(): void;
  113368. }
  113369. }
  113370. declare module BABYLON {
  113371. /**
  113372. * Defines the root class used to create scene optimization to use with SceneOptimizer
  113373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113374. */
  113375. export class SceneOptimization {
  113376. /**
  113377. * Defines the priority of this optimization (0 by default which means first in the list)
  113378. */
  113379. priority: number;
  113380. /**
  113381. * Gets a string describing the action executed by the current optimization
  113382. * @returns description string
  113383. */
  113384. getDescription(): string;
  113385. /**
  113386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113387. * @param scene defines the current scene where to apply this optimization
  113388. * @param optimizer defines the current optimizer
  113389. * @returns true if everything that can be done was applied
  113390. */
  113391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113392. /**
  113393. * Creates the SceneOptimization object
  113394. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113395. * @param desc defines the description associated with the optimization
  113396. */
  113397. constructor(
  113398. /**
  113399. * Defines the priority of this optimization (0 by default which means first in the list)
  113400. */
  113401. priority?: number);
  113402. }
  113403. /**
  113404. * Defines an optimization used to reduce the size of render target textures
  113405. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113406. */
  113407. export class TextureOptimization extends SceneOptimization {
  113408. /**
  113409. * Defines the priority of this optimization (0 by default which means first in the list)
  113410. */
  113411. priority: number;
  113412. /**
  113413. * 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
  113414. */
  113415. maximumSize: number;
  113416. /**
  113417. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113418. */
  113419. step: number;
  113420. /**
  113421. * Gets a string describing the action executed by the current optimization
  113422. * @returns description string
  113423. */
  113424. getDescription(): string;
  113425. /**
  113426. * Creates the TextureOptimization object
  113427. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113428. * @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
  113429. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113430. */
  113431. constructor(
  113432. /**
  113433. * Defines the priority of this optimization (0 by default which means first in the list)
  113434. */
  113435. priority?: number,
  113436. /**
  113437. * 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
  113438. */
  113439. maximumSize?: number,
  113440. /**
  113441. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113442. */
  113443. step?: number);
  113444. /**
  113445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113446. * @param scene defines the current scene where to apply this optimization
  113447. * @param optimizer defines the current optimizer
  113448. * @returns true if everything that can be done was applied
  113449. */
  113450. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113451. }
  113452. /**
  113453. * Defines an optimization used to increase or decrease the rendering resolution
  113454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113455. */
  113456. export class HardwareScalingOptimization extends SceneOptimization {
  113457. /**
  113458. * Defines the priority of this optimization (0 by default which means first in the list)
  113459. */
  113460. priority: number;
  113461. /**
  113462. * Defines the maximum scale to use (2 by default)
  113463. */
  113464. maximumScale: number;
  113465. /**
  113466. * Defines the step to use between two passes (0.5 by default)
  113467. */
  113468. step: number;
  113469. private _currentScale;
  113470. private _directionOffset;
  113471. /**
  113472. * Gets a string describing the action executed by the current optimization
  113473. * @return description string
  113474. */
  113475. getDescription(): string;
  113476. /**
  113477. * Creates the HardwareScalingOptimization object
  113478. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113479. * @param maximumScale defines the maximum scale to use (2 by default)
  113480. * @param step defines the step to use between two passes (0.5 by default)
  113481. */
  113482. constructor(
  113483. /**
  113484. * Defines the priority of this optimization (0 by default which means first in the list)
  113485. */
  113486. priority?: number,
  113487. /**
  113488. * Defines the maximum scale to use (2 by default)
  113489. */
  113490. maximumScale?: number,
  113491. /**
  113492. * Defines the step to use between two passes (0.5 by default)
  113493. */
  113494. step?: number);
  113495. /**
  113496. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113497. * @param scene defines the current scene where to apply this optimization
  113498. * @param optimizer defines the current optimizer
  113499. * @returns true if everything that can be done was applied
  113500. */
  113501. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113502. }
  113503. /**
  113504. * Defines an optimization used to remove shadows
  113505. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113506. */
  113507. export class ShadowsOptimization extends SceneOptimization {
  113508. /**
  113509. * Gets a string describing the action executed by the current optimization
  113510. * @return description string
  113511. */
  113512. getDescription(): string;
  113513. /**
  113514. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113515. * @param scene defines the current scene where to apply this optimization
  113516. * @param optimizer defines the current optimizer
  113517. * @returns true if everything that can be done was applied
  113518. */
  113519. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113520. }
  113521. /**
  113522. * Defines an optimization used to turn post-processes off
  113523. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113524. */
  113525. export class PostProcessesOptimization extends SceneOptimization {
  113526. /**
  113527. * Gets a string describing the action executed by the current optimization
  113528. * @return description string
  113529. */
  113530. getDescription(): string;
  113531. /**
  113532. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113533. * @param scene defines the current scene where to apply this optimization
  113534. * @param optimizer defines the current optimizer
  113535. * @returns true if everything that can be done was applied
  113536. */
  113537. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113538. }
  113539. /**
  113540. * Defines an optimization used to turn lens flares off
  113541. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113542. */
  113543. export class LensFlaresOptimization extends SceneOptimization {
  113544. /**
  113545. * Gets a string describing the action executed by the current optimization
  113546. * @return description string
  113547. */
  113548. getDescription(): string;
  113549. /**
  113550. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113551. * @param scene defines the current scene where to apply this optimization
  113552. * @param optimizer defines the current optimizer
  113553. * @returns true if everything that can be done was applied
  113554. */
  113555. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113556. }
  113557. /**
  113558. * Defines an optimization based on user defined callback.
  113559. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113560. */
  113561. export class CustomOptimization extends SceneOptimization {
  113562. /**
  113563. * Callback called to apply the custom optimization.
  113564. */
  113565. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  113566. /**
  113567. * Callback called to get custom description
  113568. */
  113569. onGetDescription: () => string;
  113570. /**
  113571. * Gets a string describing the action executed by the current optimization
  113572. * @returns description string
  113573. */
  113574. getDescription(): string;
  113575. /**
  113576. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113577. * @param scene defines the current scene where to apply this optimization
  113578. * @param optimizer defines the current optimizer
  113579. * @returns true if everything that can be done was applied
  113580. */
  113581. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113582. }
  113583. /**
  113584. * Defines an optimization used to turn particles off
  113585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113586. */
  113587. export class ParticlesOptimization extends SceneOptimization {
  113588. /**
  113589. * Gets a string describing the action executed by the current optimization
  113590. * @return description string
  113591. */
  113592. getDescription(): string;
  113593. /**
  113594. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113595. * @param scene defines the current scene where to apply this optimization
  113596. * @param optimizer defines the current optimizer
  113597. * @returns true if everything that can be done was applied
  113598. */
  113599. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113600. }
  113601. /**
  113602. * Defines an optimization used to turn render targets off
  113603. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113604. */
  113605. export class RenderTargetsOptimization extends SceneOptimization {
  113606. /**
  113607. * Gets a string describing the action executed by the current optimization
  113608. * @return description string
  113609. */
  113610. getDescription(): string;
  113611. /**
  113612. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113613. * @param scene defines the current scene where to apply this optimization
  113614. * @param optimizer defines the current optimizer
  113615. * @returns true if everything that can be done was applied
  113616. */
  113617. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113618. }
  113619. /**
  113620. * Defines an optimization used to merge meshes with compatible materials
  113621. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113622. */
  113623. export class MergeMeshesOptimization extends SceneOptimization {
  113624. private static _UpdateSelectionTree;
  113625. /**
  113626. * Gets or sets a boolean which defines if optimization octree has to be updated
  113627. */
  113628. /**
  113629. * Gets or sets a boolean which defines if optimization octree has to be updated
  113630. */
  113631. static UpdateSelectionTree: boolean;
  113632. /**
  113633. * Gets a string describing the action executed by the current optimization
  113634. * @return description string
  113635. */
  113636. getDescription(): string;
  113637. private _canBeMerged;
  113638. /**
  113639. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113640. * @param scene defines the current scene where to apply this optimization
  113641. * @param optimizer defines the current optimizer
  113642. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113643. * @returns true if everything that can be done was applied
  113644. */
  113645. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  113646. }
  113647. /**
  113648. * Defines a list of options used by SceneOptimizer
  113649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113650. */
  113651. export class SceneOptimizerOptions {
  113652. /**
  113653. * Defines the target frame rate to reach (60 by default)
  113654. */
  113655. targetFrameRate: number;
  113656. /**
  113657. * Defines the interval between two checkes (2000ms by default)
  113658. */
  113659. trackerDuration: number;
  113660. /**
  113661. * Gets the list of optimizations to apply
  113662. */
  113663. optimizations: SceneOptimization[];
  113664. /**
  113665. * Creates a new list of options used by SceneOptimizer
  113666. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113667. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113668. */
  113669. constructor(
  113670. /**
  113671. * Defines the target frame rate to reach (60 by default)
  113672. */
  113673. targetFrameRate?: number,
  113674. /**
  113675. * Defines the interval between two checkes (2000ms by default)
  113676. */
  113677. trackerDuration?: number);
  113678. /**
  113679. * Add a new optimization
  113680. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113681. * @returns the current SceneOptimizerOptions
  113682. */
  113683. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  113684. /**
  113685. * Add a new custom optimization
  113686. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113687. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113688. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113689. * @returns the current SceneOptimizerOptions
  113690. */
  113691. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  113692. /**
  113693. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113694. * @param targetFrameRate defines the target frame rate (60 by default)
  113695. * @returns a SceneOptimizerOptions object
  113696. */
  113697. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113698. /**
  113699. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113700. * @param targetFrameRate defines the target frame rate (60 by default)
  113701. * @returns a SceneOptimizerOptions object
  113702. */
  113703. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113704. /**
  113705. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113706. * @param targetFrameRate defines the target frame rate (60 by default)
  113707. * @returns a SceneOptimizerOptions object
  113708. */
  113709. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113710. }
  113711. /**
  113712. * Class used to run optimizations in order to reach a target frame rate
  113713. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113714. */
  113715. export class SceneOptimizer implements IDisposable {
  113716. private _isRunning;
  113717. private _options;
  113718. private _scene;
  113719. private _currentPriorityLevel;
  113720. private _targetFrameRate;
  113721. private _trackerDuration;
  113722. private _currentFrameRate;
  113723. private _sceneDisposeObserver;
  113724. private _improvementMode;
  113725. /**
  113726. * Defines an observable called when the optimizer reaches the target frame rate
  113727. */
  113728. onSuccessObservable: Observable<SceneOptimizer>;
  113729. /**
  113730. * Defines an observable called when the optimizer enables an optimization
  113731. */
  113732. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  113733. /**
  113734. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113735. */
  113736. onFailureObservable: Observable<SceneOptimizer>;
  113737. /**
  113738. * Gets a boolean indicating if the optimizer is in improvement mode
  113739. */
  113740. readonly isInImprovementMode: boolean;
  113741. /**
  113742. * Gets the current priority level (0 at start)
  113743. */
  113744. readonly currentPriorityLevel: number;
  113745. /**
  113746. * Gets the current frame rate checked by the SceneOptimizer
  113747. */
  113748. readonly currentFrameRate: number;
  113749. /**
  113750. * Gets or sets the current target frame rate (60 by default)
  113751. */
  113752. /**
  113753. * Gets or sets the current target frame rate (60 by default)
  113754. */
  113755. targetFrameRate: number;
  113756. /**
  113757. * Gets or sets the current interval between two checks (every 2000ms by default)
  113758. */
  113759. /**
  113760. * Gets or sets the current interval between two checks (every 2000ms by default)
  113761. */
  113762. trackerDuration: number;
  113763. /**
  113764. * Gets the list of active optimizations
  113765. */
  113766. readonly optimizations: SceneOptimization[];
  113767. /**
  113768. * Creates a new SceneOptimizer
  113769. * @param scene defines the scene to work on
  113770. * @param options defines the options to use with the SceneOptimizer
  113771. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113772. * @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)
  113773. */
  113774. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  113775. /**
  113776. * Stops the current optimizer
  113777. */
  113778. stop(): void;
  113779. /**
  113780. * Reset the optimizer to initial step (current priority level = 0)
  113781. */
  113782. reset(): void;
  113783. /**
  113784. * Start the optimizer. By default it will try to reach a specific framerate
  113785. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113786. */
  113787. start(): void;
  113788. private _checkCurrentState;
  113789. /**
  113790. * Release all resources
  113791. */
  113792. dispose(): void;
  113793. /**
  113794. * Helper function to create a SceneOptimizer with one single line of code
  113795. * @param scene defines the scene to work on
  113796. * @param options defines the options to use with the SceneOptimizer
  113797. * @param onSuccess defines a callback to call on success
  113798. * @param onFailure defines a callback to call on failure
  113799. * @returns the new SceneOptimizer object
  113800. */
  113801. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  113802. }
  113803. }
  113804. declare module BABYLON {
  113805. /**
  113806. * Class used to serialize a scene into a string
  113807. */
  113808. export class SceneSerializer {
  113809. /**
  113810. * Clear cache used by a previous serialization
  113811. */
  113812. static ClearCache(): void;
  113813. /**
  113814. * Serialize a scene into a JSON compatible object
  113815. * @param scene defines the scene to serialize
  113816. * @returns a JSON compatible object
  113817. */
  113818. static Serialize(scene: Scene): any;
  113819. /**
  113820. * Serialize a mesh into a JSON compatible object
  113821. * @param toSerialize defines the mesh to serialize
  113822. * @param withParents defines if parents must be serialized as well
  113823. * @param withChildren defines if children must be serialized as well
  113824. * @returns a JSON compatible object
  113825. */
  113826. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  113827. }
  113828. }
  113829. declare module BABYLON {
  113830. /**
  113831. * This represents the different options avilable for the video capture.
  113832. */
  113833. export interface VideoRecorderOptions {
  113834. /** Defines the mime type of the video */
  113835. mimeType: string;
  113836. /** Defines the video the video should be recorded at */
  113837. fps: number;
  113838. /** Defines the chunk size for the recording data */
  113839. recordChunckSize: number;
  113840. /** The audio tracks to attach to the record */
  113841. audioTracks?: MediaStreamTrack[];
  113842. }
  113843. /**
  113844. * This can helps recording videos from BabylonJS.
  113845. * This is based on the available WebRTC functionalities of the browser.
  113846. *
  113847. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  113848. */
  113849. export class VideoRecorder {
  113850. private static readonly _defaultOptions;
  113851. /**
  113852. * Returns wehther or not the VideoRecorder is available in your browser.
  113853. * @param engine Defines the Babylon Engine to check the support for
  113854. * @returns true if supported otherwise false
  113855. */
  113856. static IsSupported(engine: Engine): boolean;
  113857. private readonly _options;
  113858. private _canvas;
  113859. private _mediaRecorder;
  113860. private _recordedChunks;
  113861. private _fileName;
  113862. private _resolve;
  113863. private _reject;
  113864. /**
  113865. * True wether a recording is already in progress.
  113866. */
  113867. readonly isRecording: boolean;
  113868. /**
  113869. * Create a new VideoCapture object which can help converting what you see in Babylon to
  113870. * a video file.
  113871. * @param engine Defines the BabylonJS Engine you wish to record
  113872. * @param options Defines options that can be used to customized the capture
  113873. */
  113874. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  113875. /**
  113876. * Stops the current recording before the default capture timeout passed in the startRecording
  113877. * functions.
  113878. */
  113879. stopRecording(): void;
  113880. /**
  113881. * Starts recording the canvas for a max duration specified in parameters.
  113882. * @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.
  113883. * @param maxDuration Defines the maximum recording time in seconds.
  113884. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  113885. * @return a promise callback at the end of the recording with the video data in Blob.
  113886. */
  113887. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  113888. /**
  113889. * Releases internal resources used during the recording.
  113890. */
  113891. dispose(): void;
  113892. private _handleDataAvailable;
  113893. private _handleError;
  113894. private _handleStop;
  113895. }
  113896. }
  113897. declare module BABYLON {
  113898. /**
  113899. * Helper class to push actions to a pool of workers.
  113900. */
  113901. export class WorkerPool implements IDisposable {
  113902. private _workerInfos;
  113903. private _pendingActions;
  113904. /**
  113905. * Constructor
  113906. * @param workers Array of workers to use for actions
  113907. */
  113908. constructor(workers: Array<Worker>);
  113909. /**
  113910. * Terminates all workers and clears any pending actions.
  113911. */
  113912. dispose(): void;
  113913. /**
  113914. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113915. * pended until a worker has completed its action.
  113916. * @param action The action to perform. Call onComplete when the action is complete.
  113917. */
  113918. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113919. private _execute;
  113920. }
  113921. }
  113922. declare module BABYLON {
  113923. /**
  113924. * Class containing a set of static utilities functions for screenshots
  113925. */
  113926. export class ScreenshotTools {
  113927. /**
  113928. * Captures a screenshot of the current rendering
  113929. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113930. * @param engine defines the rendering engine
  113931. * @param camera defines the source camera
  113932. * @param size This parameter can be set to a single number or to an object with the
  113933. * following (optional) properties: precision, width, height. If a single number is passed,
  113934. * it will be used for both width and height. If an object is passed, the screenshot size
  113935. * will be derived from the parameters. The precision property is a multiplier allowing
  113936. * rendering at a higher or lower resolution
  113937. * @param successCallback defines the callback receives a single parameter which contains the
  113938. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113939. * src parameter of an <img> to display it
  113940. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  113941. * Check your browser for supported MIME types
  113942. */
  113943. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  113944. /**
  113945. * Generates an image screenshot from the specified camera.
  113946. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113947. * @param engine The engine to use for rendering
  113948. * @param camera The camera to use for rendering
  113949. * @param size This parameter can be set to a single number or to an object with the
  113950. * following (optional) properties: precision, width, height. If a single number is passed,
  113951. * it will be used for both width and height. If an object is passed, the screenshot size
  113952. * will be derived from the parameters. The precision property is a multiplier allowing
  113953. * rendering at a higher or lower resolution
  113954. * @param successCallback The callback receives a single parameter which contains the
  113955. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113956. * src parameter of an <img> to display it
  113957. * @param mimeType The MIME type of the screenshot image (default: image/png).
  113958. * Check your browser for supported MIME types
  113959. * @param samples Texture samples (default: 1)
  113960. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  113961. * @param fileName A name for for the downloaded file.
  113962. */
  113963. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  113964. }
  113965. }
  113966. declare module BABYLON {
  113967. /**
  113968. * A cursor which tracks a point on a path
  113969. */
  113970. export class PathCursor {
  113971. private path;
  113972. /**
  113973. * Stores path cursor callbacks for when an onchange event is triggered
  113974. */
  113975. private _onchange;
  113976. /**
  113977. * The value of the path cursor
  113978. */
  113979. value: number;
  113980. /**
  113981. * The animation array of the path cursor
  113982. */
  113983. animations: Animation[];
  113984. /**
  113985. * Initializes the path cursor
  113986. * @param path The path to track
  113987. */
  113988. constructor(path: Path2);
  113989. /**
  113990. * Gets the cursor point on the path
  113991. * @returns A point on the path cursor at the cursor location
  113992. */
  113993. getPoint(): Vector3;
  113994. /**
  113995. * Moves the cursor ahead by the step amount
  113996. * @param step The amount to move the cursor forward
  113997. * @returns This path cursor
  113998. */
  113999. moveAhead(step?: number): PathCursor;
  114000. /**
  114001. * Moves the cursor behind by the step amount
  114002. * @param step The amount to move the cursor back
  114003. * @returns This path cursor
  114004. */
  114005. moveBack(step?: number): PathCursor;
  114006. /**
  114007. * Moves the cursor by the step amount
  114008. * If the step amount is greater than one, an exception is thrown
  114009. * @param step The amount to move the cursor
  114010. * @returns This path cursor
  114011. */
  114012. move(step: number): PathCursor;
  114013. /**
  114014. * Ensures that the value is limited between zero and one
  114015. * @returns This path cursor
  114016. */
  114017. private ensureLimits;
  114018. /**
  114019. * Runs onchange callbacks on change (used by the animation engine)
  114020. * @returns This path cursor
  114021. */
  114022. private raiseOnChange;
  114023. /**
  114024. * Executes a function on change
  114025. * @param f A path cursor onchange callback
  114026. * @returns This path cursor
  114027. */
  114028. onchange(f: (cursor: PathCursor) => void): PathCursor;
  114029. }
  114030. }
  114031. declare module BABYLON {
  114032. /** @hidden */
  114033. export var blurPixelShader: {
  114034. name: string;
  114035. shader: string;
  114036. };
  114037. }
  114038. declare module BABYLON {
  114039. /** @hidden */
  114040. export var vrMultiviewToSingleviewPixelShader: {
  114041. name: string;
  114042. shader: string;
  114043. };
  114044. }
  114045. declare module BABYLON {
  114046. /** @hidden */
  114047. export var bones300Declaration: {
  114048. name: string;
  114049. shader: string;
  114050. };
  114051. }
  114052. declare module BABYLON {
  114053. /** @hidden */
  114054. export var instances300Declaration: {
  114055. name: string;
  114056. shader: string;
  114057. };
  114058. }
  114059. declare module BABYLON {
  114060. /** @hidden */
  114061. export var pointCloudVertexDeclaration: {
  114062. name: string;
  114063. shader: string;
  114064. };
  114065. }
  114066. // Mixins
  114067. interface Window {
  114068. mozIndexedDB: IDBFactory;
  114069. webkitIndexedDB: IDBFactory;
  114070. msIndexedDB: IDBFactory;
  114071. webkitURL: typeof URL;
  114072. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  114073. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  114074. WebGLRenderingContext: WebGLRenderingContext;
  114075. MSGesture: MSGesture;
  114076. CANNON: any;
  114077. AudioContext: AudioContext;
  114078. webkitAudioContext: AudioContext;
  114079. PointerEvent: any;
  114080. Math: Math;
  114081. Uint8Array: Uint8ArrayConstructor;
  114082. Float32Array: Float32ArrayConstructor;
  114083. mozURL: typeof URL;
  114084. msURL: typeof URL;
  114085. VRFrameData: any; // WebVR, from specs 1.1
  114086. DracoDecoderModule: any;
  114087. setImmediate(handler: (...args: any[]) => void): number;
  114088. }
  114089. interface HTMLCanvasElement {
  114090. requestPointerLock(): void;
  114091. msRequestPointerLock?(): void;
  114092. mozRequestPointerLock?(): void;
  114093. webkitRequestPointerLock?(): void;
  114094. /** Track wether a record is in progress */
  114095. isRecording: boolean;
  114096. /** Capture Stream method defined by some browsers */
  114097. captureStream(fps?: number): MediaStream;
  114098. }
  114099. interface CanvasRenderingContext2D {
  114100. msImageSmoothingEnabled: boolean;
  114101. }
  114102. interface MouseEvent {
  114103. mozMovementX: number;
  114104. mozMovementY: number;
  114105. webkitMovementX: number;
  114106. webkitMovementY: number;
  114107. msMovementX: number;
  114108. msMovementY: number;
  114109. }
  114110. interface Navigator {
  114111. mozGetVRDevices: (any: any) => any;
  114112. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  114113. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  114114. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  114115. webkitGetGamepads(): Gamepad[];
  114116. msGetGamepads(): Gamepad[];
  114117. webkitGamepads(): Gamepad[];
  114118. }
  114119. interface HTMLVideoElement {
  114120. mozSrcObject: any;
  114121. }
  114122. interface Math {
  114123. fround(x: number): number;
  114124. imul(a: number, b: number): number;
  114125. }
  114126. interface WebGLProgram {
  114127. context?: WebGLRenderingContext;
  114128. vertexShader?: WebGLShader;
  114129. fragmentShader?: WebGLShader;
  114130. isParallelCompiled: boolean;
  114131. onCompiled?: () => void;
  114132. }
  114133. interface WebGLRenderingContext {
  114134. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  114135. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  114136. vertexAttribDivisor(index: number, divisor: number): void;
  114137. createVertexArray(): any;
  114138. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  114139. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  114140. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  114141. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  114142. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  114143. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  114144. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  114145. // Queries
  114146. createQuery(): WebGLQuery;
  114147. deleteQuery(query: WebGLQuery): void;
  114148. beginQuery(target: number, query: WebGLQuery): void;
  114149. endQuery(target: number): void;
  114150. getQueryParameter(query: WebGLQuery, pname: number): any;
  114151. getQuery(target: number, pname: number): any;
  114152. MAX_SAMPLES: number;
  114153. RGBA8: number;
  114154. READ_FRAMEBUFFER: number;
  114155. DRAW_FRAMEBUFFER: number;
  114156. UNIFORM_BUFFER: number;
  114157. HALF_FLOAT_OES: number;
  114158. RGBA16F: number;
  114159. RGBA32F: number;
  114160. R32F: number;
  114161. RG32F: number;
  114162. RGB32F: number;
  114163. R16F: number;
  114164. RG16F: number;
  114165. RGB16F: number;
  114166. RED: number;
  114167. RG: number;
  114168. R8: number;
  114169. RG8: number;
  114170. UNSIGNED_INT_24_8: number;
  114171. DEPTH24_STENCIL8: number;
  114172. /* Multiple Render Targets */
  114173. drawBuffers(buffers: number[]): void;
  114174. readBuffer(src: number): void;
  114175. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  114176. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  114177. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  114178. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  114179. // Occlusion Query
  114180. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  114181. ANY_SAMPLES_PASSED: number;
  114182. QUERY_RESULT_AVAILABLE: number;
  114183. QUERY_RESULT: number;
  114184. }
  114185. interface WebGLBuffer {
  114186. references: number;
  114187. capacity: number;
  114188. is32Bits: boolean;
  114189. }
  114190. interface WebGLProgram {
  114191. transformFeedback?: WebGLTransformFeedback | null;
  114192. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  114193. }
  114194. interface EXT_disjoint_timer_query {
  114195. QUERY_COUNTER_BITS_EXT: number;
  114196. TIME_ELAPSED_EXT: number;
  114197. TIMESTAMP_EXT: number;
  114198. GPU_DISJOINT_EXT: number;
  114199. QUERY_RESULT_EXT: number;
  114200. QUERY_RESULT_AVAILABLE_EXT: number;
  114201. queryCounterEXT(query: WebGLQuery, target: number): void;
  114202. createQueryEXT(): WebGLQuery;
  114203. beginQueryEXT(target: number, query: WebGLQuery): void;
  114204. endQueryEXT(target: number): void;
  114205. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  114206. deleteQueryEXT(query: WebGLQuery): void;
  114207. }
  114208. interface WebGLUniformLocation {
  114209. _currentState: any;
  114210. }
  114211. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  114212. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  114213. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  114214. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  114215. interface WebGLRenderingContext {
  114216. readonly RASTERIZER_DISCARD: number;
  114217. readonly DEPTH_COMPONENT24: number;
  114218. readonly TEXTURE_3D: number;
  114219. readonly TEXTURE_2D_ARRAY: number;
  114220. readonly TEXTURE_COMPARE_FUNC: number;
  114221. readonly TEXTURE_COMPARE_MODE: number;
  114222. readonly COMPARE_REF_TO_TEXTURE: number;
  114223. readonly TEXTURE_WRAP_R: number;
  114224. readonly HALF_FLOAT: number;
  114225. readonly RGB8: number;
  114226. readonly RED_INTEGER: number;
  114227. readonly RG_INTEGER: number;
  114228. readonly RGB_INTEGER: number;
  114229. readonly RGBA_INTEGER: number;
  114230. readonly R8_SNORM: number;
  114231. readonly RG8_SNORM: number;
  114232. readonly RGB8_SNORM: number;
  114233. readonly RGBA8_SNORM: number;
  114234. readonly R8I: number;
  114235. readonly RG8I: number;
  114236. readonly RGB8I: number;
  114237. readonly RGBA8I: number;
  114238. readonly R8UI: number;
  114239. readonly RG8UI: number;
  114240. readonly RGB8UI: number;
  114241. readonly RGBA8UI: number;
  114242. readonly R16I: number;
  114243. readonly RG16I: number;
  114244. readonly RGB16I: number;
  114245. readonly RGBA16I: number;
  114246. readonly R16UI: number;
  114247. readonly RG16UI: number;
  114248. readonly RGB16UI: number;
  114249. readonly RGBA16UI: number;
  114250. readonly R32I: number;
  114251. readonly RG32I: number;
  114252. readonly RGB32I: number;
  114253. readonly RGBA32I: number;
  114254. readonly R32UI: number;
  114255. readonly RG32UI: number;
  114256. readonly RGB32UI: number;
  114257. readonly RGBA32UI: number;
  114258. readonly RGB10_A2UI: number;
  114259. readonly R11F_G11F_B10F: number;
  114260. readonly RGB9_E5: number;
  114261. readonly RGB10_A2: number;
  114262. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  114263. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  114264. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  114265. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114266. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  114267. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  114268. 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;
  114269. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  114270. readonly TRANSFORM_FEEDBACK: number;
  114271. readonly INTERLEAVED_ATTRIBS: number;
  114272. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  114273. createTransformFeedback(): WebGLTransformFeedback;
  114274. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  114275. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  114276. beginTransformFeedback(primitiveMode: number): void;
  114277. endTransformFeedback(): void;
  114278. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  114279. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114280. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114281. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114282. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  114283. }
  114284. interface ImageBitmap {
  114285. readonly width: number;
  114286. readonly height: number;
  114287. close(): void;
  114288. }
  114289. interface WebGLQuery extends WebGLObject {
  114290. }
  114291. declare var WebGLQuery: {
  114292. prototype: WebGLQuery;
  114293. new(): WebGLQuery;
  114294. };
  114295. interface WebGLSampler extends WebGLObject {
  114296. }
  114297. declare var WebGLSampler: {
  114298. prototype: WebGLSampler;
  114299. new(): WebGLSampler;
  114300. };
  114301. interface WebGLSync extends WebGLObject {
  114302. }
  114303. declare var WebGLSync: {
  114304. prototype: WebGLSync;
  114305. new(): WebGLSync;
  114306. };
  114307. interface WebGLTransformFeedback extends WebGLObject {
  114308. }
  114309. declare var WebGLTransformFeedback: {
  114310. prototype: WebGLTransformFeedback;
  114311. new(): WebGLTransformFeedback;
  114312. };
  114313. interface WebGLVertexArrayObject extends WebGLObject {
  114314. }
  114315. declare var WebGLVertexArrayObject: {
  114316. prototype: WebGLVertexArrayObject;
  114317. new(): WebGLVertexArrayObject;
  114318. };
  114319. // Type definitions for WebVR API
  114320. // Project: https://w3c.github.io/webvr/
  114321. // Definitions by: six a <https://github.com/lostfictions>
  114322. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  114323. interface VRDisplay extends EventTarget {
  114324. /**
  114325. * Dictionary of capabilities describing the VRDisplay.
  114326. */
  114327. readonly capabilities: VRDisplayCapabilities;
  114328. /**
  114329. * z-depth defining the far plane of the eye view frustum
  114330. * enables mapping of values in the render target depth
  114331. * attachment to scene coordinates. Initially set to 10000.0.
  114332. */
  114333. depthFar: number;
  114334. /**
  114335. * z-depth defining the near plane of the eye view frustum
  114336. * enables mapping of values in the render target depth
  114337. * attachment to scene coordinates. Initially set to 0.01.
  114338. */
  114339. depthNear: number;
  114340. /**
  114341. * An identifier for this distinct VRDisplay. Used as an
  114342. * association point in the Gamepad API.
  114343. */
  114344. readonly displayId: number;
  114345. /**
  114346. * A display name, a user-readable name identifying it.
  114347. */
  114348. readonly displayName: string;
  114349. readonly isConnected: boolean;
  114350. readonly isPresenting: boolean;
  114351. /**
  114352. * If this VRDisplay supports room-scale experiences, the optional
  114353. * stage attribute contains details on the room-scale parameters.
  114354. */
  114355. readonly stageParameters: VRStageParameters | null;
  114356. /**
  114357. * Passing the value returned by `requestAnimationFrame` to
  114358. * `cancelAnimationFrame` will unregister the callback.
  114359. * @param handle Define the hanle of the request to cancel
  114360. */
  114361. cancelAnimationFrame(handle: number): void;
  114362. /**
  114363. * Stops presenting to the VRDisplay.
  114364. * @returns a promise to know when it stopped
  114365. */
  114366. exitPresent(): Promise<void>;
  114367. /**
  114368. * Return the current VREyeParameters for the given eye.
  114369. * @param whichEye Define the eye we want the parameter for
  114370. * @returns the eye parameters
  114371. */
  114372. getEyeParameters(whichEye: string): VREyeParameters;
  114373. /**
  114374. * Populates the passed VRFrameData with the information required to render
  114375. * the current frame.
  114376. * @param frameData Define the data structure to populate
  114377. * @returns true if ok otherwise false
  114378. */
  114379. getFrameData(frameData: VRFrameData): boolean;
  114380. /**
  114381. * Get the layers currently being presented.
  114382. * @returns the list of VR layers
  114383. */
  114384. getLayers(): VRLayer[];
  114385. /**
  114386. * Return a VRPose containing the future predicted pose of the VRDisplay
  114387. * when the current frame will be presented. The value returned will not
  114388. * change until JavaScript has returned control to the browser.
  114389. *
  114390. * The VRPose will contain the position, orientation, velocity,
  114391. * and acceleration of each of these properties.
  114392. * @returns the pose object
  114393. */
  114394. getPose(): VRPose;
  114395. /**
  114396. * Return the current instantaneous pose of the VRDisplay, with no
  114397. * prediction applied.
  114398. * @returns the current instantaneous pose
  114399. */
  114400. getImmediatePose(): VRPose;
  114401. /**
  114402. * The callback passed to `requestAnimationFrame` will be called
  114403. * any time a new frame should be rendered. When the VRDisplay is
  114404. * presenting the callback will be called at the native refresh
  114405. * rate of the HMD. When not presenting this function acts
  114406. * identically to how window.requestAnimationFrame acts. Content should
  114407. * make no assumptions of frame rate or vsync behavior as the HMD runs
  114408. * asynchronously from other displays and at differing refresh rates.
  114409. * @param callback Define the eaction to run next frame
  114410. * @returns the request handle it
  114411. */
  114412. requestAnimationFrame(callback: FrameRequestCallback): number;
  114413. /**
  114414. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  114415. * Repeat calls while already presenting will update the VRLayers being displayed.
  114416. * @param layers Define the list of layer to present
  114417. * @returns a promise to know when the request has been fulfilled
  114418. */
  114419. requestPresent(layers: VRLayer[]): Promise<void>;
  114420. /**
  114421. * Reset the pose for this display, treating its current position and
  114422. * orientation as the "origin/zero" values. VRPose.position,
  114423. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  114424. * updated when calling resetPose(). This should be called in only
  114425. * sitting-space experiences.
  114426. */
  114427. resetPose(): void;
  114428. /**
  114429. * The VRLayer provided to the VRDisplay will be captured and presented
  114430. * in the HMD. Calling this function has the same effect on the source
  114431. * canvas as any other operation that uses its source image, and canvases
  114432. * created without preserveDrawingBuffer set to true will be cleared.
  114433. * @param pose Define the pose to submit
  114434. */
  114435. submitFrame(pose?: VRPose): void;
  114436. }
  114437. declare var VRDisplay: {
  114438. prototype: VRDisplay;
  114439. new(): VRDisplay;
  114440. };
  114441. interface VRLayer {
  114442. leftBounds?: number[] | Float32Array | null;
  114443. rightBounds?: number[] | Float32Array | null;
  114444. source?: HTMLCanvasElement | null;
  114445. }
  114446. interface VRDisplayCapabilities {
  114447. readonly canPresent: boolean;
  114448. readonly hasExternalDisplay: boolean;
  114449. readonly hasOrientation: boolean;
  114450. readonly hasPosition: boolean;
  114451. readonly maxLayers: number;
  114452. }
  114453. interface VREyeParameters {
  114454. /** @deprecated */
  114455. readonly fieldOfView: VRFieldOfView;
  114456. readonly offset: Float32Array;
  114457. readonly renderHeight: number;
  114458. readonly renderWidth: number;
  114459. }
  114460. interface VRFieldOfView {
  114461. readonly downDegrees: number;
  114462. readonly leftDegrees: number;
  114463. readonly rightDegrees: number;
  114464. readonly upDegrees: number;
  114465. }
  114466. interface VRFrameData {
  114467. readonly leftProjectionMatrix: Float32Array;
  114468. readonly leftViewMatrix: Float32Array;
  114469. readonly pose: VRPose;
  114470. readonly rightProjectionMatrix: Float32Array;
  114471. readonly rightViewMatrix: Float32Array;
  114472. readonly timestamp: number;
  114473. }
  114474. interface VRPose {
  114475. readonly angularAcceleration: Float32Array | null;
  114476. readonly angularVelocity: Float32Array | null;
  114477. readonly linearAcceleration: Float32Array | null;
  114478. readonly linearVelocity: Float32Array | null;
  114479. readonly orientation: Float32Array | null;
  114480. readonly position: Float32Array | null;
  114481. readonly timestamp: number;
  114482. }
  114483. interface VRStageParameters {
  114484. sittingToStandingTransform?: Float32Array;
  114485. sizeX?: number;
  114486. sizeY?: number;
  114487. }
  114488. interface Navigator {
  114489. getVRDisplays(): Promise<VRDisplay[]>;
  114490. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  114491. }
  114492. interface Window {
  114493. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  114494. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  114495. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  114496. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114497. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114498. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  114499. }
  114500. interface Gamepad {
  114501. readonly displayId: number;
  114502. }
  114503. interface XRDevice {
  114504. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  114505. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  114506. }
  114507. interface XRSession {
  114508. getInputSources(): Array<any>;
  114509. baseLayer: XRWebGLLayer;
  114510. requestFrameOfReference(type: string): Promise<void>;
  114511. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  114512. end(): Promise<void>;
  114513. requestAnimationFrame: Function;
  114514. addEventListener: Function;
  114515. }
  114516. interface XRSessionCreationOptions {
  114517. outputContext?: WebGLRenderingContext | null;
  114518. immersive?: boolean;
  114519. environmentIntegration?: boolean;
  114520. }
  114521. interface XRLayer {
  114522. getViewport: Function;
  114523. framebufferWidth: number;
  114524. framebufferHeight: number;
  114525. }
  114526. interface XRView {
  114527. projectionMatrix: Float32Array;
  114528. }
  114529. interface XRFrame {
  114530. getDevicePose: Function;
  114531. getInputPose: Function;
  114532. views: Array<XRView>;
  114533. baseLayer: XRLayer;
  114534. }
  114535. interface XRFrameOfReference {
  114536. }
  114537. interface XRWebGLLayer extends XRLayer {
  114538. framebuffer: WebGLFramebuffer;
  114539. }
  114540. declare var XRWebGLLayer: {
  114541. prototype: XRWebGLLayer;
  114542. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  114543. };